public ActionResult CreateRole(SysRoleDto model) { SysRoleServices sysRoleServices = new SysRoleServices(); var result = sysRoleServices.InertModel(model); return(View("RoleIndex")); }
public bool InertModel(SysRoleDto model) { model.CreateTime = DateTime.Now; model.Id = Guid.NewGuid(); var temp = Mapper.Map <SysRoleDto, SysRole>(model); return(Respository.Insert(temp) > 0 ? true : false); }
public async Task OnGetAsync() { if (!string.IsNullOrEmpty(Id)) { var entity = await _sysRoleService.GetObjectAsync(_ => _.Id == Id); SysRoleDto = _sysRoleService.Mapper.Map <SysRoleDto>(entity); } }
/// <summary> /// 添加/修改角色 /// </summary> /// <param name="userGroupDto"></param> /// <param name="objCheckMenus">角色的菜单权限</param> /// <returns></returns> public string AddorEditRole(string sjson) { var model = JsonHelper.JsonToObject <SysRoleVO>(sjson); if (model == null) { return(JsonHelper.ObjectToJson(new ResponseModel { StateCode = StatesCode.failure, Messages = "数据解析失败" })); } SysRoleDto roleDto = model.roleDto; List <SysMenuDto> objCheckMenus = model.objCheckMenus; bool bResult = true; string sMessage = "保存成功"; var roleBLL = injection.GetT <ISysRoleBLL>(); var role = AutoMapper.Mapper.Map <SysRole>(roleDto); //添加 if (string.IsNullOrEmpty(role.RoleId)) { if (roleBLL.GetCount(t => t.RoleName.Equals(role.RoleName) && !t.RoleId.Equals(role.RoleId) && t.DeleteSign.Equals((int)SysEnum.Enum_DeleteSign.Sing_Deleted)) > 0) { sMessage = "角色名称不能重复"; bResult = !bResult; } else { role.RoleId = Guid.NewGuid().ToString(); role.DeleteSign = (Int32)SysEnum.Enum_DeleteSign.Sing_Deleted; role.CreateUserId = injection.GetT <UserAccount>().GetUserInfo().UserId; role.CreateTime = DateTime.Now; bResult = roleBLL.Add(role); bResult = roleBLL.AddRoleMenu(role.RoleId, objCheckMenus).Result; } } else//修改 { var userRole_Edit = roleBLL.GetModels(t => t.RoleId.Equals(role.RoleId)).SingleOrDefault(); userRole_Edit.RoleName = role.RoleName; userRole_Edit.EditTime = DateTime.Now; userRole_Edit.Note = role.Note; bResult = roleBLL.Update(userRole_Edit); bResult = roleBLL.AddRoleMenu(userRole_Edit.RoleId, objCheckMenus).Result; } return(JsonHelper.ObjectToJson(new ResponseModel { StateCode = bResult ? StatesCode.success : StatesCode.failure, Messages = sMessage })); }
public async Task SaveRole(SysRoleDto roleDto) { var role = _mapper.Map <SysRole>(roleDto); if (roleDto.ID < 1) { await _roleRepository.InsertAsync(role); } else { await _roleRepository.UpdateAsync(role); } }
public async Task CreateOrUpdateAsync(SysRoleDto dto) { SysRole sysRole; if (String.IsNullOrEmpty(dto.Id)) { sysRole = new SysRole(dto); } else { sysRole = await GetObjectAsync(_ => _.Id == dto.Id); sysRole.Update(dto); } await SaveObjectAsync(sysRole); }
/// <summary> /// 添加/修改角色 /// </summary> /// <param name="userGroupDto"></param> /// <param name="objCheckMenus">角色的菜单权限</param> /// <returns></returns> public IActionResult AddorEditRole(SysRoleDto roleDto, List <SysMenuDto> objCheckMenus) { bool bResult = true; string sMessage = "保存成功"; var role = AutoMapper.Mapper.Map <SysRole>(roleDto); if (_sysRoleBLL.GetCount(t => t.RoleName.Equals(role.RoleName) && !t.RoleId.Equals(role.RoleId) && t.DeleteSign.Equals((int)DeleteSign.Sing_Deleted)) > 0) { sMessage = "角色名称不能重复"; bResult = !bResult; } else { //添加 if (string.IsNullOrEmpty(role.RoleId)) { role.DeleteSign = (Int32)DeleteSign.Sing_Deleted; role.CreateUserId = _userAccount.GetUserInfo().UserId; role.CreateTime = DateTime.Now; bResult = _sysRoleBLL.Add(role); bResult = _sysRoleBLL.AddRoleMenu(role.RoleId, objCheckMenus).Result; } else//修改 { var userRole_Edit = _sysRoleBLL.GetModels(t => t.RoleId.Equals(role.RoleId)).SingleOrDefault(); userRole_Edit.RoleName = role.RoleName; userRole_Edit.EditTime = DateTime.Now; userRole_Edit.Note = role.Note; bResult = _sysRoleBLL.Update(userRole_Edit); bResult = _sysRoleBLL.AddRoleMenu(userRole_Edit.RoleId, objCheckMenus).Result; } } return(Ok(new ResponseModel { RetCode = bResult ? StatesCode.success : StatesCode.failure, RetMsg = sMessage })); }
public async Task <IActionResult> OnPostSaveAsync([FromBody] SysRoleDto sysRoleDto) { await _sysRoleService.CreateOrUpdateAsync(sysRoleDto); return(Ok(true)); }
public async Task<ActionResult> SaveRoleData(SysRoleDto[] dtos) { dtos.CheckNotNull("dtos"); OperationResult result = await IdentityContract.SaveRoles(dtos); return Json(result.ToAjaxResult()); }
public async Task SaveRole(SysRoleDto roleDto) { await _roleService.SaveRole(roleDto); }
public async Task SavePermisson(SysRoleDto roleDto) { await _roleService.SavePermisson(roleDto.ID, roleDto.Permissions); }
public ApiResult <List <SysRoleDto> > UpdateRole(SysRoleDto sysRoleDto) { _logger.Info("開始呼叫SysRoleViewService.UpdateRole"); return(_sysRoleViewService.UpdateRoleView(sysRoleDto)); }