public IActionResult GetById([FromServices] LawsuitService service, int id) { Lawsuit lawsuit = service.GetById(x => x.IdLawsuit == id); if (lawsuit == null) { return(NotFound()); } var response = Mapper.Map <Lawsuit, LawsuitView>(lawsuit); return(Ok(response)); }
public IActionResult Delete([FromServices] LawsuitService service, int id) { var lawsuit = service.GetById(x => x.IdLawsuit == id); if (lawsuit == null) { return(NotFound()); } var mapped = Mapper.Map <Lawsuit>(lawsuit); service.Delete(mapped); return(Ok()); }
public IActionResult Update([FromServices] LawsuitService service, [FromBody] LawsuitDTO lawsuitDto, int id) { service.LawsuitPrevalidations(lawsuitDto, id); Lawsuit lawsuit = service.GetById(x => x.IdLawsuit == id); if (lawsuit == null) { return(NotFound()); } var mappedLawsuit = Mapper.Map(lawsuitDto, lawsuit); var updatedLawsuit = service.Update <LawsuitValidator>(mappedLawsuit); var response = Mapper.Map <Lawsuit, LawsuitView>(updatedLawsuit); return(Ok(response)); }