public IActionResult RoleList() { if (HttpContext.Session.GetString("UserRole") == "1") { var item1 = _context.RoleTypes.AsNoTracking().ToList(); var sent = new List <RoleTypeVm>(); int c = 1; foreach (var item in item1) { RoleTypeVm b = new RoleTypeVm() { RoleName = item.RoleName, RoleTypeId = item.RoleTypeId, Serial = c }; sent.Add(b); c++; } return(View(sent)); } else { return(RedirectToAction("Index", "Home")); } }
public IActionResult UpdateRole(RoleTypeVm item) { RoleType b = new RoleType() { RoleName = item.RoleName, RoleTypeId = item.RoleTypeId, }; _context.RoleTypes.Update(b); _context.SaveChanges(); return(RedirectToAction("RoleList")); }
public IActionResult AddRole(RoleTypeVm a) { RoleType b = new RoleType() { RoleName = a.RoleName, RoleTypeId = a.RoleTypeId }; _context.RoleTypes.Add(b); _context.SaveChanges(); ModelState.Clear(); return(View()); }
public IActionResult UpdateRole(int id) { if (HttpContext.Session.GetString("UserRole") == "1") { var item = _context.RoleTypes.AsNoTracking().Where(a => a.RoleTypeId == id).FirstOrDefault(); RoleTypeVm b = new RoleTypeVm() { RoleName = item.RoleName, RoleTypeId = item.RoleTypeId, }; return(View(b)); } else { return(RedirectToAction("Index", "Home")); } }