public bool AddEntries(Entries entries) { using (var ctx = new FoodCaloriesEntities()) { ctx.Entries.Add(entries); ctx.SaveChanges(); } return true; }
public bool DeleteEntrie(DateTime dairyid, int entrieid) { using (var ctx = new FoodCaloriesEntities()) { var entity = ctx.Entries.FirstOrDefault(b => b.IdEntry == entrieid); ctx.Entries.Remove(entity); ctx.SaveChanges(); } return true; }
public void UpdateEntrie(Entries entity,DateTime dairyid, int entrieid ) { using (var ctx = new FoodCaloriesEntities()) { var entrie = ctx.Entries.Include("Diary").FirstOrDefault(b=>b.IdEntry==entrieid && b.Diary.CurrentDate==dairyid); entrie.Quantity = entity.Quantity; ctx.SaveChanges(); } }