public bool Save_MenuItems_tables(menuItem model) { using (RMSDBEntities db = new RMSDBEntities()) { if (model.id == 0) { db.menuItems.Add(model); db.SaveChanges(); return(true); } else if (model.id > 0) { menuItem RowinDb = db.menuItems.Where(d => d.id == model.id).SingleOrDefault(); RowinDb.itemName = model.itemName; RowinDb.color = model.color; RowinDb.Price = model.Price; RowinDb.discountpercnt = model.discountpercnt; RowinDb.status = model.status; RowinDb.cat_id = model.cat_id; RowinDb.section_id = model.section_id; db.SaveChanges(); return(true); } return(false); } }
public bool Delete_MenuItems_tables(int id) { using (RMSDBEntities db = new RMSDBEntities()) { if (id > 0) { menuItem RowinDb = db.menuItems.Where(d => d.id == id).SingleOrDefault(); if (RowinDb != null) { db.menuItems.Remove(RowinDb); db.SaveChanges(); return(true); } return(false); } return(false); } }