Exemplo n.º 1
0
        public ApplicationDomainDtoContainer GetUserAppDomainList(long userId)
        {
            ApplicationDomainDtoContainer container = new ApplicationDomainDtoContainer();
            AccountTDataAccess            accDa     = new AccountTDataAccess();
            var accounts = accDa.GetAll(it => it.UserId == userId);

            foreach (var acc in accounts)
            {
                foreach (var app in acc.ApplicationDomainDtoList)
                {
                    if (!container.ApplicationDomainDtoList.Exists(it => it.ApplicationDomainId == app.ApplicationDomainId))
                    {
                        container.ApplicationDomainDtoList.Add(app);
                    }
                }
            }
            LoginTypeTDataAccess loginTypeDa = new LoginTypeTDataAccess();
            var loginTypeList = loginTypeDa.GetAll();

            if (loginTypeList != null && loginTypeList.Count > 0)
            {
                container.LoginTypeDtoList.AddRange(loginTypeList);
            }
            return(container);
        }
Exemplo n.º 2
0
        public Common.DTOContainer.AccountDtoContainer GetUserAccounts(Common.DTO.UserDto userMember)
        {
            AccountTDataAccess accountDa = new AccountTDataAccess();
            var accounts = accountDa.GetAll(it => it.UserId == userMember.UserId && it.ExpiredDate == null).ToList();
            AccountDtoContainer container = new AccountDtoContainer();

            container.AccountDtoList.AddRange(accounts);
            return(container);
        }
Exemplo n.º 3
0
        public Framework.Common.Service.Message.ResponseDto DeAssignAccountAppDomain(Common.DTO.AccountDto account, int appDomain)
        {
            AccountTDataAccess accountDa = new AccountTDataAccess();
            ResponseDto        response  = new ResponseDto();
            var dbAccount = accountDa.GetSingle(it => it.AccountId == account.AccountId);

            if (dbAccount != null)
            {
                AccountToAppDomainTDataAccess accToDomainDa = new AccountToAppDomainTDataAccess();
                var dbAccToDomain = accToDomainDa.GetSingle(it => it.AccountId == account.AccountId && it.AppDomainId == appDomain && it.ExpireDate == null);
                dbAccToDomain.ExpireDate = null;
                accToDomainDa.Update(dbAccToDomain);
            }
            else
            {
                response.Response.AddBusinessException("حساب کاربری وجود ندارد!", BusinessExceptionEnum.Operational);
            }
            return(response);
        }
Exemplo n.º 4
0
        public Framework.Common.Service.Message.ResponseDto UnRegisterUser(Common.DTO.UserDto userMember)
        {
            ResponseDto response = new ResponseDto();
            var         user     = ((SecurityUserTDataAccess)this.dataAccess).GetSingle(it => it.UserId == userMember.UserId);

            if (user != null)
            {
                AccountTDataAccess accountDa = new AccountTDataAccess();
                var accounts = accountDa.GetAll(it => it.UserId == user.UserId).ToList();
                foreach (var account in accounts)
                {
                    account.ExpiredDate = DateTime.Now;
                }
                this.Update(user);
                accountDa.Update(accounts);
            }
            else
            {
                response.Response.AddBusinessException("!چنین کاربری وجود ندارد", BusinessExceptionEnum.Validation);
            }
            return(response);
        }
Exemplo n.º 5
0
        public ResponseDto RegisterUser(UserDto user)
        {
            AccountTDataAccess accountDa = new AccountTDataAccess();
            ResponseDto        response  = new ResponseDto();

            try
            {
                if (ValidateNewUser(user))
                {
                    bool existUser = ((SecurityUserTDataAccess)this.dataAccess).ExistUser(user);
                    if (!existUser)
                    {
                        if (user.Accounts.Count() > 0)
                        {
                            var account      = user.Accounts.FirstOrDefault();
                            var existAccount = accountDa.ExistAccount(account.Username);
                            if (!existAccount)
                            {
                                this.Insert(user);
                                foreach (var newAccount in user.Accounts)
                                {
                                    newAccount.UserId = user.UserId;
                                }
                                try
                                {
                                    accountDa.Insert(user.Accounts.ToList());
                                }
                                catch
                                {
                                    accountDa.Delete(user.Accounts.ToList());
                                    this.Delete(user);
                                    response.Response.AddBusinessException("ثبت کاربر جدید با شکست مواجه شد!", BusinessExceptionEnum.Operational);
                                }
                            }
                            else
                            {
                                response.Response.AddBusinessException("کاربر با این حساب کاربری قبلا ثبت شده است!", BusinessExceptionEnum.Validation);
                            }
                        }
                        else
                        {
                            response.Response.AddBusinessException("کاربر باید دارای حساب کاربری پیش فرض باشد!", BusinessExceptionEnum.Validation);
                        }
                    }
                    else
                    {
                        response.Response.AddBusinessException("!کاربر با این کد ملی قبلا ثبت شده است", BusinessExceptionEnum.Validation);
                    }
                }
                else
                {
                    response.SetResponse(user.Response);
                }
            }
            catch (Exception ex)
            {
                response.Response.AddBusinessException(ex.Message, BusinessExceptionEnum.Operational);
            }

            return(response);
        }