public IHttpActionResult Put(SpecialUpdate special) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateSpecialService(); if (!service.UpdateSpecial(special)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateSpecial(SpecialUpdate model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Specials .Single(e => e.SpecialId == model.SpecialId); entity.ProductId = model.ProductId; entity.DayOfWeek = model.DayOfWeek; entity.ProductSpecialPrice = model.ProductSpecialPrice; return(ctx.SaveChanges() == 1); } }