public IHttpActionResult Put(RentEdit editRent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateRentService(); if (!service.UpdateRent(editRent)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateRent(RentEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .RealEstateRent .Single(e => e.RentId == model.RentId); entity.DateAvailable = model.DateAvailable; entity.PricePerMonth = model.PricePerMonth; entity.Description = model.Description; entity.UtilitiesIncluded = model.UtilitiesIncluded; entity.PetsAllowed = model.PetsAllowed; entity.IsRentFavorite = model.IsRentFavorite; entity.RealEstatePropertyId = model.RealEstatePropertyId; return(ctx.SaveChanges() == 1); } }