public async Task <ResultCrmDb> AddRoleForLevelOrgAsync(RoleCreateArgs args) { var result = new ResultCrmDb(); try { if ((await _crmDbContext.userrole.FirstOrDefaultAsync(r => r.LevelOrgId == args.IdLevelorg & r.Name == args.CaptionRole)) != null) { result.AddError("", "Такая роль уже существует!"); return(result); } var role = new userrole(); role.LevelOrgId = args.IdLevelorg; role.Name = args.CaptionRole; role.Sysname = args.CaptionRole; await _crmDbContext.userrole.AddAsync(role); await _crmDbContext.SaveChangesAsync(); } catch (Exception e) { result.AddError("", e.Message); } return(result); }
public async Task <ResultCrmDb> AddRoleForLevelOrgAsync(RoleCreateArgs args) { var result = new ResultCrmDb(); try { var role = new userrole(); role.LevelOrgId = args.IdLevelorg; role.Name = args.CaptionRole; role.Sysname = args.CaptionRole; await _crmDbContext.userrole.AddAsync(role); await _crmDbContext.SaveChangesAsync(); } catch (Exception e) { result.AddError("", e.Message); } return(result); }
public async Task <IActionResult> AddRole(RoleCreateArgs args) { return(Tools.CreateResult(true, "", await _roles.AddRoleForLevelOrgAsync(args))); }