예제 #1
0
        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));
        }
예제 #2
0
        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());
        }
예제 #3
0
        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));
        }