public House Update(House updatedHouse) { House foundHouse = GetById(updatedHouse.Id); updatedHouse.Bedrooms = updatedHouse.Bedrooms == null ? updatedHouse.Bedrooms : foundHouse.Bedrooms; // DO ALL THE OTHER THINGS bool updated = _repo.Update(updatedHouse); if (!updated) { throw new Exception("Oops ALL BERRIES You are not the owner of this car"); } return(updatedHouse); }
public House Update(House updatedHouse) { House foundHouse = GetById(updatedHouse.Id); updatedHouse.Level = updatedHouse.Level != 0 ? updatedHouse.Level : foundHouse.Level; updatedHouse.Year = updatedHouse.Year != 0 ? updatedHouse.Year : foundHouse.Year; updatedHouse.Price = updatedHouse.Price != 0 ? updatedHouse.Price : foundHouse.Price; updatedHouse.ImgUrl = updatedHouse.ImgUrl != null ? updatedHouse.ImgUrl : foundHouse.ImgUrl; bool updated = _repo.Update(updatedHouse); if (!updated) { throw new Exception("Oops ALL BERRIES You are not the owner of this house"); } return(updatedHouse); }
public House Update(House updatedHouse) { House foundHouse = GetById(updatedHouse.Id); updatedHouse.Title = updatedHouse.Title == null ? foundHouse.Title : updatedHouse.Title; updatedHouse.Price = updatedHouse.Price == 0 ? foundHouse.Price : updatedHouse.Price; updatedHouse.Year = updatedHouse.Year == 0 ? foundHouse.Year : updatedHouse.Year; updatedHouse.Description = updatedHouse.Description == null ? foundHouse.Description : updatedHouse.Description; updatedHouse.ImgUrl = updatedHouse.ImgUrl == null ? foundHouse.ImgUrl : updatedHouse.ImgUrl; updatedHouse.UserId = foundHouse.UserId; // DO ALL THE OTHER THINGS bool updated = _repo.Update(updatedHouse); if (!updated) { throw new Exception("Oops ALL BERRIES You are not the owner of this House"); } return(updatedHouse); }