public ActionResult UpdateApartment(int id, ApartmentUpdateDTO model) { var modelFromRepo = _repo.GetApartmentByID(id); if (modelFromRepo == null) { return(NotFound()); } if (_houseRepo.GetHouseById(model.ID_House) == null) { return(BadRequest($"House With ID {model.ID_House} was not found \n Use https://localhost:44359/api/houses from list of avalibale houses! ")); } _mapper.Map(model, modelFromRepo); _repo.UpdateApartment(modelFromRepo); _repo.SaveChanges(); return(NoContent()); }
public ActionResult EditApartment(Apartment CurrentApt) { _aptRepo.UpdateApartment(CurrentApt); return(RedirectToAction("ApartmentDetails", new { AptID = CurrentApt.AptID })); }