Ejemplo n.º 1
0
        public Task <ClientApplication> CreateAsync(ClientApplicationRequest request)
        {
            return(CommonOperationAsync(async() =>
            {
                var result = Mapper.Map <ClientApplication>(request);

                var tempResult = await _uow.ClientApplications.GetByNameAsync(result.ClientApplicationName);
                tempResult.CheckUniqueValue(AuthorizationConstants.ClientApplicationName);

                tempResult = await _uow.ClientApplications.GetByCodeAsync(result.ClientApplicationCode);
                tempResult.CheckUniqueValue(AuthorizationConstants.ClientApplicationCode);

                var salt = HashString.GetSalt();
                var hashPassword = HashString.Hash(result.ClientApplicationPassword, salt,
                                                   AuthorizationUtilConstants.IterationCountForHashing);

                result.ClientApplicationPassword = hashPassword;

                _uow.ClientApplications.Add(result, GetLoggedInUserId());

                CreateClientApplicationUtil(result.Id, salt);

                await _uow.SaveChangesAsync();
                return result;
            }, new BusinessBaseRequest {
                MethodBase = MethodBase.GetCurrentMethod()
            }));
        }
Ejemplo n.º 2
0
        public Task <ApplicationUser> CreateAsync(ApplicationUserRequest request)
        {
            return(CommonOperationAsync(async() =>
            {
                var result = new ApplicationUser
                {
                    UserId = request.UserId,
                    ApplicationId = request.ApplicationId,
                };

                /******************References Table Check Values****************/
                /***************************************************************/
                (await _uow.Roles.GetByIdAsync(result.ApplicationId)).CheckRecordIsExist(typeof(Application).Name);
                (await _uow.Users.GetByIdAsync(result.UserId)).CheckRecordIsExist(typeof(User).Name);
                /***************************************************************/
                /***************************************************************/

                var tempResult = await _uow.ApplicationUsers.GetByUserIdAndApplicationIdAsync(result.UserId, result.ApplicationId);
                tempResult.CheckUniqueValue(GetType().Name);

                _uow.ApplicationUsers.Add(result, GetLoggedInUserId());
                await _uow.SaveChangesAsync();
                return result;
            }, new BusinessBaseRequest {
                MethodBase = MethodBase.GetCurrentMethod()
            }));
        }
Ejemplo n.º 3
0
        public Task <Role> CreateAsync(RoleRequest request)
        {
            return(CommonOperationAsync(async() =>
            {
                var result = Mapper.Map <Role>(request);

                var tempResult = await _uow.Roles.GetByNameAsync(result.RoleName);
                tempResult.CheckUniqueValue(AuthorizationConstants.RoleName);

                _uow.Roles.Add(result, GetLoggedInUserId());
                await _uow.SaveChangesAsync();
                return result;
            }, new BusinessBaseRequest {
                MethodBase = MethodBase.GetCurrentMethod()
            }));
        }
Ejemplo n.º 4
0
        public Task <UserUtil> CreateAsync(UserUtilRequest request)
        {
            return(CommonOperationAsync(async() =>
            {
                var result = Mapper.Map <UserUtil>(request);

                /******************References Table Check Values****************/
                /***************************************************************/
                (await _uow.Users.GetByIdAsync(result.UserId)).CheckRecordIsExist(typeof(User).Name);
                /***************************************************************/
                /***************************************************************/

                _uow.UserUtils.Add(result, GetLoggedInUserId());
                await _uow.SaveChangesAsync();
                return result;
            }, new BusinessBaseRequest {
                MethodBase = MethodBase.GetCurrentMethod()
            }));
        }
        public Task <UserEntityClaim> CreateAsync(UserEntityClaimRequest request)
        {
            return(CommonOperationAsync(async() =>
            {
                var result = Mapper.Map <UserEntityClaim>(request);

                /******************References Table Check Values****************/
                /***************************************************************/
                (await _uow.Applications.GetByIdAsync(result.ApplicationId)).CheckRecordIsExist(typeof(Application).Name);
                (await _uow.Users.GetByIdAsync(result.UserId)).CheckRecordIsExist(typeof(User).Name);
                /***************************************************************/
                /***************************************************************/

                var tempResult = await _uow.UserEntityClaims.GetByApplicationIdAndUserIdAndEntityAsync(result.ApplicationId, result.UserId, result.Entity);
                tempResult.CheckUniqueValue(AuthorizationConstants.Entity);

                _uow.UserEntityClaims.Add(result, GetLoggedInUserId());
                await _uow.SaveChangesAsync();
                return result;
            }, new BusinessBaseRequest {
                MethodBase = MethodBase.GetCurrentMethod()
            }));
        }
        public Task <RoleClaim> CreateAsync(RoleClaimRequest request)
        {
            return(CommonOperationAsync(async() =>
            {
                var result = Mapper.Map <RoleClaim>(request);

                /******************References Table Check Values****************/
                /***************************************************************/
                (await _uow.Applications.GetByIdAsync(result.ApplicationId)).CheckRecordIsExist(typeof(Application).Name);
                (await _uow.Roles.GetByIdAsync(result.RoleId)).CheckRecordIsExist(typeof(Role).Name);
                (await _uow.Claims.GetByIdAsync(result.ClaimId)).CheckRecordIsExist(typeof(Claim).Name);
                /***************************************************************/
                /***************************************************************/

                var tempResult = await _uow.RoleClaims.GetByApplicationIdAndRoleIdAndClaimIdAsync(result.ApplicationId, result.RoleId, result.ClaimId);
                tempResult.CheckUniqueValue(GetType().Name);

                _uow.RoleClaims.Add(result, GetLoggedInUserId());
                await _uow.SaveChangesAsync();
                return result;
            }, new BusinessBaseRequest {
                MethodBase = MethodBase.GetCurrentMethod()
            }));
        }