public void DeleteRole(Role role) { using (var dbContext = new DatabaseContext()) { var rDel = dbContext.Roles.Include(r => r.UserRoles).FirstOrDefault(r => r.Id.Equals(role.Id)); if (rDel != null) { dbContext.Roles.Remove(rDel); dbContext.SaveChanges(); } } }
public JsonResult GetCurrentRole() { var uid = User.Identity.GetUserId(); var currentRole = accountService.GetRoles(uid).FirstOrDefault(); if (currentRole == null) currentRole = new Role(); var role = new RoleViewModel() { Name = currentRole.Name, Description = currentRole.Description, Predefined = currentRole.Predefined, AccountCanEdit = currentRole.AccountCanEdit, AccountCanView = currentRole.AccountCanView, AgentCanCreate = currentRole.AgentCanCreate, MedallionCanDelete = currentRole.MedallionCanDelete, BillOutMember = currentRole.BillOutMember, ViewMemberData = currentRole.ViewMemberData, ViewDeletedMembers = currentRole.ViewDeletedMembers, ViewMemberCashiering = currentRole.ViewMemberCashiering, EditMemberData = currentRole.EditMemberData, DeleteMemberData = currentRole.DeleteMemberData, ReportCanMakeReport = currentRole.ReportCanMakeReport, ReportCanMakeEndOfDayTrans = currentRole.ReportCanMakeEndOfDayTrans, RoleCanViewList = currentRole.RoleCanViewList, RoleCanEdit = currentRole.RoleCanEdit, RoleCanCreate = currentRole.RoleCanCreate, RoleCanDelete = currentRole.RoleCanDelete, UserCanViewList = currentRole.UserCanViewList, UserCanEdit = currentRole.UserCanEdit, UserCanCreate = currentRole.UserCanCreate, UserCanDelete = currentRole.UserCanDelete, ReferenceCanEdit = currentRole.ReferenceCanEdit, AllowDashboard = currentRole.AllowDashboard, IsAdmin = currentRole.Name == UserRoles.Administrator.ToString() }; return Json(role, JsonRequestBehavior.AllowGet); }
public ActionResult Edit(Role role) { accountService.UpdateRole(role); return Json(true); }
public ActionResult Delete(Role role) { accountService.DeleteRole(role); return Json(true); }
public void CreateRole(Role role) { roleRepository.Add(role); }
public void UpdateRole(Role role) { roleRepository.Update(role); }