public bool EditADiet(DietEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Diets .Single(e => e.DietId == model.DietId); entity.DietId = model.DietId; entity.Name = model.Name; entity.IsVegetarian = model.IsVegetarian; entity.IsKeto = model.IsKeto; entity.IsLactoseFree = model.IsLactoseFree; entity.IsGlutenFree = model.IsGlutenFree; entity.Description = model.Description; entity.CaloriesPerDay = model.CaloriesPerDay; return(ctx.SaveChanges() == 1); } }