public ActionResult Index(ControllerActionViewModel[] controllers) { foreach (var cont in controllers) { GEN_CONTROLLER_ACTION record = db.GEN_CONTROLLER_ACTION. Where(a => a.ACTION_NAME == cont.actionName && a.CONTROLLER_NAME == cont.controllerName). FirstOrDefault(); if (record == null) { GEN_CONTROLLER_ACTION conac = new GEN_CONTROLLER_ACTION(); conac.ACTION_NAME = cont.actionName; conac.CONTROLLER_NAME = cont.controllerName; conac.IS_AUTO_INCLUDE = cont.IsAutoInclude == true ? 1 : 0; conac.IS_ACTIVE = cont.IsActive == true ? 1 : 0; conac.IS_PUBLIC = cont.IsPublic == true ? 1 : 0; conac.IS_MENU = cont.IsMenu == true ? 1 : 0; conac.MENU_NAME = cont.menuName; db.GEN_CONTROLLER_ACTION_INSERT(conac.CONTROLLER_NAME, conac.ACTION_NAME, conac.IS_ACTIVE, conac.IS_PUBLIC, conac.IS_AUTO_INCLUDE, conac.PARENT_ACTION_NO, conac.IS_MENU, conac.MENU_NAME, conac.PARENT_MENU_NO, conac.IS_SUB_MENU, conac.DETAILS, conac.SL_NUM); } else { record.IS_AUTO_INCLUDE = cont.IsAutoInclude == true ? 1 : 0; record.IS_ACTIVE = cont.IsActive == true ? 1 : 0; record.IS_PUBLIC = cont.IsPublic == true ? 1 : 0; record.IS_MENU = cont.IsMenu == true ? 1 : 0; record.MENU_NAME = cont.menuName; db.GEN_CONTROLLER_ACTION_UPDATE(record.ACTION_NO, record.CONTROLLER_NAME, record.ACTION_NAME, record.IS_ACTIVE, record.IS_PUBLIC, record.IS_AUTO_INCLUDE, record.PARENT_ACTION_NO, record.IS_MENU, record.MENU_NAME, record.PARENT_MENU_NO, record.IS_SUB_MENU, record.DETAILS, record.SL_NUM); } } //db.SaveChanges(); ControllerList list = new ControllerList(); List <ControllerActionViewModel> clist = list.GetControllerActions().OrderBy(a => a.actionName).OrderBy(a => a.controllerName).ToList(); return(View(clist)); }