put in ignore file
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using FamilyTreeAPI.Entities;
|
||||
using FamilyTreeAPI.Interface;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace FamilyTreeAPI.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class LookupController : ControllerBase
|
||||
{
|
||||
private readonly ILookup _repo;
|
||||
public LookupController(ILookup repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
[HttpGet("[action]")]
|
||||
public async Task<IActionResult> LoadLookup(string type)
|
||||
{
|
||||
var list = await _repo.GetLookupAsync(type);
|
||||
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpGet("[action]")]
|
||||
public async Task<IActionResult> LoadLookupEdit(string type)
|
||||
{
|
||||
var list = await _repo.GetLookupEditAsync(type);
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpGet("[action]")]
|
||||
public async Task<IActionResult> GetPersons()
|
||||
{
|
||||
var list = await _repo.GetPersonsAsync();
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpGet("[action]")]
|
||||
public async Task<IActionResult> GetStaffs()
|
||||
{
|
||||
var list = await _repo.GetStaffAsync();
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Lookup([FromBody] LookupEditDto model)
|
||||
{
|
||||
//var currentUser = (User?)(HttpContext.Items["User"]);
|
||||
//if (null == currentUser)
|
||||
// return Unauthorized(new { message = "Unauthorized" });
|
||||
|
||||
var response = await _repo.SaveLookupAsync(model);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Lookup(int id, string type)
|
||||
{
|
||||
//lookup/id?type='abc'
|
||||
/*
|
||||
// only admins can access other user records
|
||||
var currentUser = (User)HttpContext.Items["User"];
|
||||
if (id != currentUser.Id && currentUser.Role != Role.Admin)
|
||||
return Unauthorized(new { message = "Unauthorized" });
|
||||
*/
|
||||
var retval = await _repo.GetLookupEditByIdAsync(id, type);
|
||||
return Ok(retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using FamilyTreeAPI.Entities;
|
||||
using FamilyTreeAPI.Interface;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace FamilyTreeAPI.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class PersonController : ControllerBase
|
||||
{
|
||||
private readonly IPerson _repo;
|
||||
public PersonController(IPerson repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> UploadImage(IFormFile file)
|
||||
{
|
||||
var keys = Request.Form;
|
||||
var files = Request.Form.Files;
|
||||
ResultModel<string> ret = new();
|
||||
if (files.Count > 0)
|
||||
{
|
||||
StringValues familyId = "";
|
||||
|
||||
keys.TryGetValue("familyId", out familyId);
|
||||
|
||||
UploadCriteria criteria = new();
|
||||
criteria.File = file;
|
||||
criteria.FamilyId = familyId;
|
||||
|
||||
criteria.FileName = file.FileName;
|
||||
|
||||
ret = await _repo.UploadImage(criteria);
|
||||
}
|
||||
return Ok(ret);
|
||||
|
||||
|
||||
}
|
||||
//DeleteUploadFile
|
||||
[HttpPost("[action]")]
|
||||
public ActionResult DeleteUploadFile(DeleteFileCriteria criteria)
|
||||
{
|
||||
|
||||
ResultModel<int> ret = new();
|
||||
if (!string.IsNullOrEmpty(criteria.Filename))
|
||||
{
|
||||
|
||||
ret = _repo.DeleteUploadFile(criteria);
|
||||
}
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> SearchPerson(PersonCriteria criteria)
|
||||
{
|
||||
var list = await _repo.GetPerson(criteria);
|
||||
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> GetChildress(ChildCriteria criteria)
|
||||
{
|
||||
var list = await _repo.GetChildren(criteria);
|
||||
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> GetFamilyTreeBy(FamilyCriteria criteria)
|
||||
{
|
||||
var list = await _repo.GetFamilyTreeBy(criteria);
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpGet("[action]/{id}")]
|
||||
public async Task<IActionResult> GetByPersonFamily(int id)
|
||||
{
|
||||
var list = await _repo.GetByFamilyAsync(id);
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpGet("[action]/{id}")]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
var list = await _repo.GetByIdAsync(id);
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> DeleteById(DeleteCriteria<int> criteria)
|
||||
{
|
||||
var list = await _repo.DeleteAsync(criteria.Id);
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> SavePerson([FromBody] PersonForSave model)
|
||||
{
|
||||
//var currentUser = (User?)(HttpContext.Items["User"]);
|
||||
//if (null == currentUser)
|
||||
// return Unauthorized(new { message = "Unauthorized" });
|
||||
|
||||
var response = await _repo.SaveAsync(model);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using FamilyTreeAPI.Entities;
|
||||
using FamilyTreeAPI.Interface;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace FamilyTreeAPI.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class RelationShipController : ControllerBase
|
||||
{
|
||||
private readonly IRelationShipd _repo;
|
||||
public RelationShipController(IRelationShipd repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
[HttpGet("[action]/{id}")]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
var list = await _repo.GetByIdAsync(id);
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpGet("[action]/{id}")]
|
||||
public async Task<IActionResult> GetByPersonId(int id)
|
||||
{
|
||||
var list = await _repo.GetByPersonIdAsync(id);
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
[HttpPost("[action]/{id}")]
|
||||
public async Task<IActionResult> DeleteById(int id)
|
||||
{
|
||||
var list = await _repo.GetByIdAsync(id);
|
||||
return Ok(list);
|
||||
}
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> SaveRelationShip([FromBody] RelationShiftContainer list)
|
||||
{
|
||||
//var currentUser = (User?)(HttpContext.Items["User"]);
|
||||
//if (null == currentUser)
|
||||
// return Unauthorized(new { message = "Unauthorized" });
|
||||
|
||||
var response = await _repo.SaveAsync(list.relationShips);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using FamilyTreeAPI.Entities;
|
||||
using FamilyTreeAPI.Interface;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FamilyTreeAPI.Controllers;
|
||||
|
||||
// [Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class StaffController : ControllerBase
|
||||
{
|
||||
private readonly IStaff _staff;
|
||||
public StaffController(IStaff staff)
|
||||
{
|
||||
_staff = staff;
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> SaveStaff([FromBody] StaffDto model)
|
||||
{
|
||||
//var currentUser = (User?)HttpContext.Items["User"];
|
||||
//if (null == currentUser)
|
||||
// return Unauthorized(new { message = "Unauthorized" });
|
||||
|
||||
var response = await _staff.SaveStaff(model);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> ResetPassStaff([FromBody] ResetPassDto model)
|
||||
{
|
||||
//var currentUser = (User?)HttpContext.Items["User"];
|
||||
//if (null == currentUser)
|
||||
// return Unauthorized(new { message = "Unauthorized" });
|
||||
|
||||
var response = await _staff.ResetPassword(model);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> SearchStaff([FromBody] StaffCriteria criteria)
|
||||
{
|
||||
|
||||
var retval = await _staff.GetStaff(criteria);
|
||||
return Ok(retval);
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> Staff( int id)
|
||||
{
|
||||
/*
|
||||
// only admins can access other user records
|
||||
var currentUser = (User)HttpContext.Items["User"];
|
||||
if (id != currentUser.Id && currentUser.Role != Role.Admin)
|
||||
return Unauthorized(new { message = "Unauthorized" });
|
||||
*/
|
||||
var retval = await _staff.GetStaffById(id);
|
||||
return Ok(retval);
|
||||
}
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> DeleteStaff(DeleteCriteria<int> criteria)
|
||||
{
|
||||
var currentUser = (UserDto?)HttpContext.Items["User"];
|
||||
if (null == currentUser)
|
||||
return Unauthorized(new { message = "Unauthorized" });
|
||||
|
||||
var retval = await _staff.Delete(criteria.Id);
|
||||
return Ok(retval);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using FamilyTreeAPI.Interface;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using FamilyTreeAPI.Entities;
|
||||
namespace FamilyTreeAPI.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public UsersController(IUserService userService)
|
||||
{
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> Login([FromBody] AuthenticateRequest model)
|
||||
{
|
||||
string remoteIpAddress = HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||
var response = await _userService.Login(model);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
//[AllowAnonymous]
|
||||
//[HttpPost("[action]")]
|
||||
//public async Task<IActionResult> LoginAD(AuthenticateRequest model)
|
||||
//{
|
||||
// var response = await _userService.LoginAD(model);
|
||||
// return Ok(response);
|
||||
//}
|
||||
[AllowAnonymous]
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> LoginApiAD([FromBody] AuthenticateRequest model)
|
||||
{
|
||||
string remoteIpAddress = HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||
var response = await _userService.LoginApiAD(model, remoteIpAddress);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> Logout()
|
||||
{
|
||||
var currentUser = (UserDto)HttpContext.Items["User"];
|
||||
if (null == currentUser)
|
||||
return Unauthorized(new { message = "Unauthorized" });
|
||||
|
||||
string token = Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();
|
||||
string remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
var response = await _userService.Logout(token, currentUser, remoteIpAddress);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
//[AllowAnonymous]
|
||||
//[HttpGet("[action]")]
|
||||
//public async Task<IActionResult> SearchADStaff(string stafflinkNo)
|
||||
//{
|
||||
// var user = await _userService.SearchADStaff(stafflinkNo);
|
||||
// return Ok(user);
|
||||
//}
|
||||
/*
|
||||
[AllowAnonymous]
|
||||
[HttpGet("[action]")]
|
||||
public async Task<ResultModel<User>> SearchADStaff(string stafflinkNo)
|
||||
{
|
||||
var user = await _userService.SearchADStaff(stafflinkNo);
|
||||
return user;
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user