public bool UpdateCustomerRating(CustomerRatingEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .CustomerRatings .Single(e => e.CustomerRatingId == model.CustomerRatingId); entity.Timeliness = model.Timeliness; entity.Care = model.Care; entity.Ease = model.Ease; return(ctx.SaveChanges() == 1); } }
/// <summary> /// Change an existing CustomerRating object in the Database /// </summary> /// <param name="rating">The new CustomerRating, with same id, to replace existing CustomerRating in the Database</param> /// <returns></returns> public IHttpActionResult Put(CustomerRatingEdit rating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCustomerRatingService(); if (!service.UpdateCustomerRating(rating)) { return(InternalServerError()); } return(Ok()); }