public ActionResult AddReportGroup(RoleDto model, IEnumerable<Guid> reportGroups) { try { using (var service = ServiceLocator.Instance.Resolve<IRoleService>()) { service.SetReportGroupRoles(model.ID, reportGroups, this.LoginUser.Identity.Name); return Json(true); } } catch (Exception) { return Json(false, "Add the report group failure."); } }
public ActionResult AddReportGroup(Guid roleId) { using (var roleService = ServiceLocator.Instance.Resolve<IRoleService>()) using (var repGroupService = ServiceLocator.Instance.Resolve<IReportGroupService>()) { var reportGroups = repGroupService.FindReportGroups(); var reportGroupsOfRole = roleService.FindReportGroupRoles(roleId); var model = new RoleDto { ID = roleId }; ViewBag.ReportGroups = reportGroups; ViewBag.ReportGroupsOfRole = reportGroupsOfRole; return PartialView(model); } }
public ActionResult CreateRole(RoleDto model) { try { using (var service = ServiceLocator.Instance.Resolve<IRoleService>()) { if (service.ExistRole(model.RoleName)) return Json(false, string.Format("Create the role failure, the role name:[{0}] already exists.", model.RoleName)); model.TenantId = this.Tenant.ID; // 将 Role 附加到当前租户中 model.CreatedBy = this.LoginUser.Identity.Name; service.CreateRole(model); return Json(true); } } catch (Exception) { return Json(false, "Create the role failure."); } }
public void UpdateRole(RoleDto roleDto) { var role = this._roleRepository.GetByKey(roleDto.ID); if (role == null) return; role.UpdateRole(roleDto.DisplayName, roleDto.Description, roleDto.UpdatedBy); this._roleRepository.Update(role); }
public void CreateRole(RoleDto roleDto) { var role = new Role(roleDto.RoleName, roleDto.DisplayName, roleDto.Description, roleDto.TenantId, roleDto.CreatedBy); this._roleRepository.Add(role); }
public ActionResult EditRole(RoleDto model) { try { using (var service = ServiceLocator.Instance.Resolve<IRoleService>()) { model.UpdatedBy = this.LoginUser.Identity.Name; service.UpdateRole(model); return Json(true); } } catch (Exception) { return Json(false, "Update the role failure."); } }