public IHttpActionResult Put(LiquorEdit liquor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = new LiquorService(); if (!service.UpdateLiquor(liquor)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateLiquor(LiquorEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Liquors .Single(e => e.Id == model.Id); entity.Name = model.Name; entity.Category = model.Category; entity.PercentAlcohol = model.PercentAlcohol; entity.Origin = model.Origin; return(ctx.SaveChanges() == 1); } }