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 GetById(int id) { var list = await _repo.GetByIdAsync(id); return Ok(list); } [HttpGet("[action]/{id}")] public async Task GetByPersonId(int id) { var list = await _repo.GetByPersonIdAsync(id); return Ok(list); } [HttpPost("[action]/{id}")] public async Task DeleteById(int id) { var list = await _repo.GetByIdAsync(id); return Ok(list); } [HttpPost("[action]")] public async Task 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); } }