47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
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);
|
|
}
|
|
} |