public ActionResult UpdateResident(int id, ResidentUpdateDTO model) { var modelFromRepo = _repo.GetResidentByID(id); if (modelFromRepo == null) { return(NotFound()); } if (_apartmentRepo.GetApartmentByID(model.ID_Apartment) == null) { return(BadRequest($"Apartment With ID {model.ID_Apartment} was not found \n Use https://localhost:44359/api/apartments from list of avalibale apartments! ")); } _mapper.Map(model, modelFromRepo); _repo.UpdateResident(modelFromRepo); _repo.SaveChanges(); return(NoContent()); }
public async Task UpdateResident(ResidentDTO dto) { var resident = _mapper.Map <Resident>(dto); await _repo.UpdateResident(resident); }