public ActionResult Edit(int id) { UserCrudServices service = new UserCrudServices(); List <TransactionAccount> allacc = serviceAccounts.allTransactionaccounts(); ViewBag.AllAccounts = allacc; string name = (string)Session["name"]; if (name == "Admin") { User user = service.find(id); List <Permission> listPermisons = service.findPermissions(id); ViewBag.Permissions = listPermisons; return(View(user)); } string username = (string)(Session["username"]); User users = service.findByString(username); if (users.option_edit == "Y") { User user = service.find(id); List <Permission> listPermisons = service.findPermissions(id); ViewBag.Permissions = listPermisons; return(View(user)); } return(RedirectToAction("Index", "Home")); }
public ActionResult Create() { UserCrudServices service = new UserCrudServices(); string name = (string)Session["name"]; List <TransactionAccount> allacc = serviceAccounts.allTransactionaccounts(); if (name == "Admin") { return(View(allacc)); } else { string username = (string)(Session["username"]); User user = service.findByString(username); if (user.option_create == "Y") { return(View(allacc)); } } return(RedirectToAction("Index", "Home")); }
public ActionResult userRistrictedView() { Database1Entities1 db = new Database1Entities1(); UserCrudServices service = new UserCrudServices(); string username = (string)(Session["username"]); User user = service.findByString(username); RestrictUser rUser = new RestrictUser(); rUser.allusers = service.findAllUsers(); rUser.edit = user.option_edit; rUser.delete = user.option_delete; return(View(rUser)); }
public ActionResult Delete(int id) { UserCrudServices service = new UserCrudServices(); string name = (string)Session["name"]; if (name == "Admin") { User user = service.find(id); user.is_active = "N"; user.updated_at = DateTime.UtcNow; service.save(); return(RedirectToAction("viewUsers")); } else { try { string username = (string)(Session["username"]); User users = service.findByString(username); if (users.option_delete == "Y") { User user = service.find(id); user.is_active = "N"; user.updated_at = DateTime.UtcNow; service.save(); return(RedirectToAction("viewUsers")); } return(RedirectToAction("Index", "Home")); } catch { return(View()); } } }