Exemple #1
0
 public Result <bool> UpdateResident(Resident user)
 {
     try
     {
         return(_residentRepository.UpdateResident(user));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public IActionResult UpdateResident(int ResidentId, [FromBody] ResidentUpdateDto ResidentDto)
        {
            if (ResidentDto == null || ResidentId != ResidentDto.Id)
            {
                return(BadRequest(ModelState));
            }
            var ResidentObj = _mapper.Map <Resident>(ResidentDto);

            if (!_reRepo.UpdateResident(ResidentObj))
            {
                ModelState.AddModelError("", $"Something went wrong when updating the record {ResidentObj.IdentityNumber}");
                return(StatusCode(500, ModelState));
            }
            return(NoContent());
        }