public static bool Update(MenuSectionModel menuSection) { try { if (menuSection.MenuSectionID != 0) { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { TblMenuSection tblMenuSection = rc.TblMenuSections.FirstOrDefault(u => u.MenuSectionID == menuSection.MenuSectionID); if (tblMenuSection != null) { tblMenuSection.DisplayOrderNum = menuSection.DisplayOrderNum; tblMenuSection.MenuSectionName = menuSection.MenuSectionName; rc.SaveChanges(); return(true); } else { throw new Exception("Menu section was not found"); } } } else { throw new Exception("Must have a valid ID"); } } catch (Exception ex) { throw ex; } }
public static bool Insert(int menu, int order, string menuSectionName) { try { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { PL.TblMenuSection newRow = new TblMenuSection() { MenuSectionID = rc.TblMenuSections.Any() ? rc.TblMenuSections.Max(u => u.MenuSectionID) + 1 : 1, MenuID = menu, DisplayOrderNum = order, MenuSectionName = menuSectionName }; rc.TblMenuSections.Add(newRow); rc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }