public static bool Update(CuisineModel cuisine) { try { if (cuisine.CuisineID != 0) { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { TblCuisine tblCuisine = rc.TblCuisines.FirstOrDefault(u => u.CuisineID == cuisine.CuisineID); if (tblCuisine != null) { tblCuisine.CuisineID = cuisine.CuisineID; tblCuisine.VendorID = cuisine.VendorID; tblCuisine.MenuID = cuisine.MenuID; tblCuisine.CuisineName = cuisine.CuisineName; rc.SaveChanges(); return(true); } else { throw new Exception("Item was not found"); } } } else { throw new Exception("Must have a valid id"); } } catch (Exception ex) { throw ex; } }
public static bool Insert(string cuisinename, int menuID, int vendorID) { try { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { PL.TblCuisine newRow = new TblCuisine() { CuisineID = rc.TblCuisines.Any() ? rc.TblCuisines.Max(u => u.CuisineID) + 1 : 1, VendorID = vendorID, MenuID = menuID, CuisineName = cuisinename }; rc.TblCuisines.Add(newRow); rc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }