public async Task <IResult> AddUserClaim(User user) { var operationClaim = (await _operationClaimService.GetByName("user")).Data; var userOperationClaim = new UserOperationClaim { OperationClaimId = operationClaim.Id, UserId = user.Id }; await _userOperationClaimDal.AddAsync(userOperationClaim); return(new SuccessResult(Messages.UserOperationClaimAdded)); }
public async Task <IResult> AddAsync(UserOperationClaimAddDto userOperationClaimAddDto) { var rulesResult = BusinessRules.Run(await this.CheckClaimExistByUser(userOperationClaimAddDto.UserId, userOperationClaimAddDto.OperationClaimId)); if (!rulesResult.Success) { return(rulesResult); } var userOperationClaimToAdd = _mapper.Map <UserOperationClaim>(userOperationClaimAddDto); var addResult = await _userOperationClaimDal.AddAsync(userOperationClaimToAdd); if (!addResult) { return(new ErrorResult(Messages.UserOperationClaimNotAdded)); } return(new SuccessResult(Messages.UserOperationClaimAdded)); }
public async Task <IResult> Register(User user) { await _userDal.AddAsync(user); var defaultOperationClaim = await _operationClaimDal.GetAsync(o => o.Name == "user"); if (defaultOperationClaim is null) { defaultOperationClaim = new OperationClaim { Name = "user" }; await _operationClaimDal.AddAsync(defaultOperationClaim); } await _userOperationClaimDal.AddAsync(new UserOperationClaim { UserId = user.Id, OperationClaimId = defaultOperationClaim.Id }); return(new SuccessResult(Messages.UserCreated)); }
public async Task <IResult> AddAsync(UserOperationClaim userOperationClaim) { await _userOperationClaimDal.AddAsync(userOperationClaim); return(new SuccessResult(Messages.UserOperationClaim.AddSuccess)); }