public ActionResult Index(string mod = "") { //ReportSalary List <string> leaveEmpList = new List <string>(); leaveEmpList = (from emp in ctx.Users.Where(u => u.status != 1) select emp.workNo).ToList <string>(); foreach (var item in ctx.permList) { if (leaveEmpList.Contains(item.workNo)) { ctx.permList.Remove(item); } } ctx.SaveChanges(); List <string> userList = ctx.permList.Where(x => x.mod == mod).Select(x => x.workNo).ToList <string>(); List <ApplicationUser> permUserList = (from user in ctx.Users where userList.Contains(user.workNo) select user).OrderBy(x => x.workNo).ToList <ApplicationUser>(); ViewBag.Title = "權限管理"; permMod modObj = ctx.permModList.Where(x => x.mod == mod).FirstOrDefault(); if (modObj != null) { ViewBag.Title = modObj.modCname; ViewBag.mod = modObj.mod; } return(View(permUserList)); }
static void createPermMod(ApplicationDbContext ctx) { if (ctx.permModList.Where(x => x.mod == "PrjCreateCode").Count() == 0) { permMod obj = new permMod { mod = "PrjCreateCode", modCname = "專案代碼管理" }; ctx.permModList.Add(obj); ctx.SaveChanges(); } else { permMod obj = ctx.permModList.Where(x => x.mod == "PrjCreate").FirstOrDefault(); obj.modCname = "專案代碼管理"; ctx.SaveChanges(); } }
public ActionResult Create(string mod) { permission model = new permission(); model.mod = mod; permMod modObj = ctx.permModList.Where(x => x.mod == mod).FirstOrDefault(); if (modObj != null) { ViewBag.Title = modObj.modCname + "-新增"; ViewBag.modObj = modObj; return(View(model)); } else { return(RedirectToAction("All")); } }