public Boolean edit(menu menu) { MenuIM im = new MenuIM(db); menu dbVersion = im.find(menu.id); if (dbVersion.version == menu.version) { //Activate / Deactivate the menu means changing the active feild to all menu categories inside it //if (dbVersion.is_active != menu.is_active) //{ MenuCategoryOM om = new MenuCategoryOM(db); IList<menu_category> menu_category_list = menu.menu_category.ToList(); for (int i = 0; i < menu_category_list.Count; i++) { menu_category mc = menu_category_list.ElementAt(i); mc.is_active = menu.is_active; om.edit(mc); } // } ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion); db.Entry(menu).State = EntityState.Modified; menu.version = menu.version + 1; db.SaveChanges(); return true; } return false; }
public MenuController() { im = new MenuIM(db); om = new MenuOM(db); }
public ActionResult CreatePartial(int menu_id) { MenuIM im = new MenuIM(db); CategoryFilterVM catFilter = new CategoryFilterVM(); menu m = im.find(menu_id); catFilter.m_menu = m; catFilter.addCategory(new category()); return PartialView("_CategoryCreate", catFilter); }