public async Task <ActionResult <CheckAccountResponse> > CheckAccount([FromBody] CheckAccountRequest requestBody)
        {
            try
            {
                CheckAccountResponse response;
                AccountInfo          account = await userManager.FindByEmailAsync(requestBody.Email);

                if (account == null)
                {
                    response = new CheckAccountResponse(false, "Email or password are wrong", null);
                    return(BadRequest(response));
                }
                var passwordValid = await userManager.CheckPasswordAsync(account, requestBody.Password);

                if (!passwordValid)
                {
                    response = new CheckAccountResponse(false, "Email or password are wrong", null);
                    return(BadRequest(response));
                }
                if (!account.AccountIsActive)
                {
                    response = new CheckAccountResponse(false, "Account is not activate", null);
                    return(BadRequest(response));
                }
                List <string>  roles      = userManager.GetRolesAsync(account).Result.ToList();
                AccountInfoDto accountDto = new AccountInfoDto(roles[0], account.Id);
                response = new CheckAccountResponse(true, "Successful check", accountDto);
                return(Ok(response));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error occured"));
            }
        }
示例#2
0
        public int RegisterUser(AccountInfoDto newUser, string registrationUrlPrefix)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                var userManager = AppUserManager();
                var user        = userManager.FindByName(newUser.UserName);

                if (user != null)
                {
                    throw new UIException("Užívateľ s týmo nickom už existuje.");
                }

                if (userManager.FindByEmail(newUser.Email) != null)
                {
                    throw new UIException("Užívateľ s týmo mailom už existuje.");
                }
                // create the user
                user = new User()
                {
                    Email    = newUser.Email,
                    UserName = newUser.UserName,
                };

                userManager.Create(user);

                uow.Commit();

                // send registration e-mail
                var registrationUrl = registrationUrlPrefix + "?username="******"&token=" + userManager.GeneratePasswordResetToken(user.Id);
                MailerService.SendNewAccountEmail(newUser.Email, registrationUrl);

                return(user.Id);
            }
        }
示例#3
0
 public async Task <IActionResult> Post([FromBody] AccountInfoDto account)
 {
     try
     {
         return(Ok(await _userService.AddAccount(_mapper.Map <AccountInfo>(account))));
     } catch (Exception ex) {
         return(BadRequest(ex.ToString()));
     }
 }
示例#4
0
 public void UpdateUserInfo(int currentUserId, AccountInfoDto userInfo)
 {
     using (var uow = UnitOfWorkProvider.Create())
     {
         var userManager = AppUserManager();
         var user        = userManager.FindById(currentUserId);
         Mapper.Map(userInfo, user);
         uow.Commit();
     }
 }
示例#5
0
        public AccountInfoDto GetAccountInfo()
        {
            var data    = accountClientProxy.GetAccountInfo(_code, _key);
            var account = new AccountInfoDto
            {
                ReadyInfo = new ReadyAccountDto
                {
                    ReadyBalance = data.ReadyInfo.ReadyBalance,
                    FreezeAmount = data.ReadyInfo.FreezeAmount
                },
                CreditInfo = new CreditAccountDto
                {
                    CreditBalance = data.CreditInfo.CreditBalance,
                    CreditQuota   = data.CreditInfo.CreditQuota,
                    TempQuota     = data.CreditInfo.TempQuota,
                    Status        = data.CreditInfo.Status
                },
                ScoreInfo = new ScoreAccountDto
                {
                    FinancialScore = data.ScoreInfo.FinancialScore
                },
                FinancialInfo = new FinancialAccountDto
                {
                    FinancialMoney = data.FinancialInfo.FinancialMoney,
                }
            };

            account.FinancialInfo.FinancialProducts = new List <CurrentFinancialProductDto>();
            foreach (var p in data.FinancialInfo.FinancialProducts)
            {
                account.FinancialInfo.FinancialProducts.Add(new CurrentFinancialProductDto
                {
                    BuyTime            = p.BuyTime,
                    FinancialMoney     = p.FinancialMoney,
                    ProductName        = p.ProductName,
                    SerialNum          = p.SerialNum,
                    ImageUrl           = p.ImageUrl,
                    Content            = p.Content,
                    ProductID          = p.ProductID,
                    ReturnRate         = p.ReturnRate,
                    Day                = p.Day,
                    StarDate           = p.StarDate,
                    PreProfit          = p.PreProfit,
                    BuyDay             = p.BuyDay,
                    MinRate            = p.MinRate,
                    PreEndDate         = p.PreEndDate,
                    Status             = p.Status,
                    TradeID            = p.TradeID,
                    CanSettleInAdvance = p.CanSettleInAdvance
                });
            }
            return(account);
        }
示例#6
0
        public async Task <ApiRequestResult> GetUserInfo([FromBody] AccountInfoDto param)
        {
            var user = await _userRepository.GetAsync(c => c.Id == Guid.Parse(param.UserId));

            //var user = await _userManager.FindByIdAsync(userId);
            if (user == null)
            {
                return(ApiRequestResult.Error("未登录"));
            }
            var dto = user.EntityMap <TUser, UserInfoDto>();

            return(ApiRequestResult.Success(dto, "获取用户信息成功"));
        }
示例#7
0
        public IActionResult AccountInfoList(int pageIndex = 1)
        {
            int pageSize = 30;
            var openId   = HttpContext.Session.GetString("OpenId");
            var owner    = _context.Menbers.FirstOrDefault(x => x.WeChatOpenId == openId);
            var tempData = _context.AccountInfos.Where(x => x.OwnerId == owner.Id).OrderByDescending(x => x.CreateTime);

            AccountInfoDto vm = new AccountInfoDto();

            vm.AccountInfos = tempData.Skip(pageIndex - 1).Take(pageSize).ToList();
            vm.PageCount    = (tempData.Count() % pageSize > 0) ? ((tempData.Count() / pageSize) + 1) : (tempData.Count() / pageSize);
            vm.PageIndex    = pageIndex;


            return(View(vm));
        }
 public CardholderDto(Cardholder cardholder)
 {
     if (cardholder == null)
     {
         return;
     }
     AccountInfo     = new AccountInfoDto(cardholder.AccountInfo);
     BillingAddress  = new AddressDto(cardholder.BillingAddress);
     Email           = cardholder.Email.ToString();
     FirstName       = cardholder.FirstName;
     HomePhoneNumber = cardholder.HomePhoneNumber.ToString();
     LastName        = cardholder.LastName;
     Msisdn          = cardholder.Msisdn.ToString();
     Shippingaddress = new AddressDto(cardholder.Shippingaddress);
     WorkPhoneNumber = cardholder.WorkPhoneNumber.ToString();
 }
示例#9
0
        public static List <AccountViewProperty> GetAccountProperties(this AccountInfoDto accountInfo)
        {
            var accountProperties = new List <AccountViewProperty>();

            // BattlesCount
            accountProperties.Add(new AccountViewProperty
            {
                Caption          = "Battles",
                IconRelativePath = "/Assets/battles.scale-200.png",
                Scale            = ParameterScale.Undefined,
                Value            = accountInfo.Battles.ToString("N0")
            });
            // WinRate
            accountProperties.Add(new AccountViewProperty
            {
                Caption          = "Winrate",
                IconRelativePath = "/Assets/wins.scale-200.png",
                Scale            = accountInfo.Winrate.WinrateScale(),
                Value            = $"{accountInfo.Winrate:N2} %"
            });
            // AvgDamage
            accountProperties.Add(new AccountViewProperty
            {
                Caption          = "Average damage",
                IconRelativePath = "/Assets/damage.scale-200.png",
                Scale            = ParameterScale.Undefined,
                Value            = accountInfo.AvgDamage.ToString("N0")
            });
            // Wn7
            accountProperties.Add(new AccountViewProperty
            {
                Caption          = "Wn7",
                IconRelativePath = "/Assets/details.global.rating.scale-200.png",
                Scale            = accountInfo.Wn7.Wn7Scale(),
                Value            = accountInfo.Wn7.ToString("N0")
            });
            // AvgXP
            accountProperties.Add(new AccountViewProperty
            {
                Caption          = "Average XP",
                IconRelativePath = "/Assets/xp.avg.scale-200.png",
                Scale            = ParameterScale.Undefined,
                Value            = accountInfo.AvgXp.ToString("N0")
            });

            return(accountProperties);
        }
示例#10
0
        public Result <AccountInfoDto> GetAccountInfo(string accountHash)
        {
            using (var uow = NewUnitOfWork())
            {
                var events = NewRepository <BlockchainEvent>(uow).Get(
                    e => e.Account.Hash == accountHash,
                    e => e.TxAction,
                    e => e.Address,
                    e => e.Account.HoldingEligibilitiesByAccountId);

                if (!events.Any())
                {
                    return(Result.Failure <AccountInfoDto>("Account {0} does not exist.".F(accountHash)));
                }

                var account = events.First().Account;

                var accountDto = AccountInfoDto.FromDomainModel(account);

                accountDto.Holdings = account.HoldingEligibilitiesByAccountId
                                      .Where(h => h.Balance.HasValue)
                                      .Select(h => new HoldingDto {
                    AssetHash = h.AssetHash, Balance = h.Balance.Value
                })
                                      .ToList();

                accountDto.Eligibilities = account.HoldingEligibilitiesByAccountId
                                           .Where(h => h.IsPrimaryEligible.HasValue || h.KycControllerAddress != null)
                                           .Select(h => new EligibilityDto {
                    AssetHash            = h.AssetHash,
                    IsPrimaryEligible    = h.IsPrimaryEligible,
                    IsSecondaryEligible  = h.IsSecondaryEligible,
                    KycControllerAddress = h.KycControllerAddress
                })
                                           .ToList();

                accountDto.ControllerAddresses = events
                                                 .Where(e => e.TxAction.ActionType == ActionType.CreateAccount.ToString() ||
                                                        e.TxAction.ActionType == ActionType.SetAccountController.ToString())
                                                 .Select(e => e.Address.BlockchainAddress).Distinct()
                                                 .Select(s => new ControllerAddressDto {
                    BlockchainAddress = s
                }).ToList();

                return(Result.Success(accountDto));
            }
        }
        public IActionResult Account()
        {
            var            user    = _userManager.FindByNameAsync(User.Identity.Name).Result;
            AccountInfoDto account = new AccountInfoDto()
            {
                Email                = user.Email,
                EmailConfirmed       = user.EmailConfirmed,
                FullName             = user.FullName,
                Id                   = user.Id,
                PhoneNumber          = user.PhoneNumber,
                PhoneNumberConfirmed = user.PhoneNumberConfirmed,
                TwoFactorEnabled     = user.TwoFactorEnabled,
                UserName             = user.UserName,
            };

            return(View(account));
        }
示例#12
0
        public void SetAccountInfoCookie(AccountInfoDto dto)
        {
            HttpContext.Response.Cookies.Remove(accountKey);
            HttpContext.Request.Cookies.Remove(accountKey);
            var timeout   = DateTime.Now.AddDays(10000);
            var inputJson = JsonConvert.SerializeObject(dto);
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, dto.AccountName, DateTime.Now, timeout, true, inputJson);
            HttpCookie cookie = new HttpCookie(accountKey);

            cookie[accountKey] = FormsAuthentication.Encrypt(ticket);
            cookie.HttpOnly    = false;
            cookie.Secure      = FormsAuthentication.RequireSSL;
            cookie.Domain      = FormsAuthentication.CookieDomain;
            cookie.Path        = FormsAuthentication.FormsCookiePath;
            cookie.Expires     = timeout;
            HttpContext.Response.Cookies.Add(cookie);
            HttpContext.Request.Cookies.Add(cookie);
        }
示例#13
0
        public async Task UpdateAccount(AccountInfoDto account)
        {
            var existAccount = _accounts.FirstOrDefault(a => a.Id == account.Id);

            if (existAccount == null)
            {
                return;
            }

            await Task.Delay(1000);

            existAccount.Title      = account.Title;
            existAccount.Balance    = account.Balance;
            existAccount.Currency   = account.Currency;
            existAccount.IsArchived = account.IsArchived;
            existAccount.Type       = account.Type;

            PropertyChanged?.Invoke(this, EventArgs.Empty);
        }
示例#14
0
        public static AccountInfoDto ToAccountInfoDto(
            SysUser user,
            SysDept dept,
            List <SysRole> roles,
            List <string> permissions)
        {
            var dto = new AccountInfoDto
            {
                Name    = user.Name,
                Role    = user.Account, // todo??
                Roles   = roles.Select(it => it.Tips).ToList(),
                Profile = new AccountProfileDto
                {
                    Dept       = dept.Fullname,
                    Deptid     = dept.Id,
                    Account    = user.Account,
                    Sex        = (int)user.Sex,
                    Avatar     = user.Avatar,
                    Birthday   = user.Birthday,
                    Version    = user.Version,
                    CreateBy   = user.CreateBy,
                    CreateTime = user.CreateTime,
                    Email      = user.Email,
                    Id         = user.Id,
                    ModifyBy   = user.ModifyBy,
                    ModifyTime = user.ModifyTime,
                    Name       = user.Name,
                    Phone      = user.Phone,
                    Roleid     = user.Roleid,
                    Roles      = roles.Select(it => it.Name).ToList(),
                    Status     = user.Status == AccountStatus.Active,
                    DeptName   = dept.Simplename,
                    RoleName   = string.Join(',', roles.Select(it => it.Name)),
                },
                Permissions = permissions
            };

            return(dto);
        }
示例#15
0
        public async Task <ApiRequestResult> SignIn([FromBody] SignInParam param)
        {
            var signInResult = await _signInManager.PasswordSignInAsync(param.UserName, param.Password, true, false);

            if (signInResult.Succeeded)
            {
                //var test = HttpContext.Current.User.Identity.GetUserId();
                var userInfo = await _userManager.FindByNameAsync(param.UserName);

                _context.HttpContext.User = await _signInManager.CreateUserPrincipalAsync(userInfo);

                _log.LogInformation("登录成功");

                var dto = new AccountInfoDto
                {
                    UserName = userInfo.UserName,
                    UserId   = userInfo.Id
                };
                return(ApiRequestResult.Success(dto, "登录成功"));
            }
            _log.LogError("登录失败");
            return(ApiRequestResult.Error("登录失败"));
        }
        public List <AccountInfoDto> Execute(int projectId)
        {
            List <AccountInfoDto> info = new List <AccountInfoDto>();
            var accounts = dbContext.MarketingAccountDetails.Where(var => (projectId == 0) || (var.ProjectId ?? 0) == projectId).OrderBy(var => var.StatusInt).ThenBy(var => var.StartDate);

            foreach (var item in accounts)
            {
                var accountInfo = new AccountInfoDto
                {
                    StartDate   = item.StartDate.ToString("dd MMMM yy"),
                    AccountId   = item.AccountId,
                    AccountName = item.AccountName,
                    CreatedOn   = item.CreatedOn,
                    CustomId    = item.CustomAccountId,
                    Status      = item.Status,
                    ProjectId   = item.ProjectId ?? 0,
                    ProjectName = item.ProjectId == 0 ? "" : dbContext.ProjectDetails.Find(item.ProjectId).ProjectName
                };

                accountInfo.ProgressHistory = new List <ProgressHistory>();
                var history = dbContext.AccountTimeLogDetails.Where(x => x.AccountId == item.AccountId);
                if (history != null)
                {
                    foreach (var log in history)
                    {
                        var historyItem = new ProgressHistory
                        {
                            StartTime = log.StartTime,
                            EndTime   = log.EndTime,
                            UserName  = dbContext.UserPersonalDetails.FirstOrDefault(x => x.UserId == log.UserId).FirstName,
                            Comments  = log.Comment
                        };

                        if (log.Status != null)
                        {
                            switch (log.Status)
                            {
                            case 1:
                                historyItem.Status = "New";
                                break;

                            case 2:
                                historyItem.Status = "In progress";
                                break;

                            case 3:
                                historyItem.Status = "Paused";
                                break;

                            case 4:
                                historyItem.Status = "Completed";
                                break;

                            default:
                                historyItem.Status = "New";
                                break;
                            }
                        }

                        accountInfo.ProgressHistory.Add(historyItem);
                    }
                }

                var timelog = dbContext.AccountTimeLogDetails.Where(x => x.AccountId == item.AccountId).OrderByDescending(var => var.StartTime).FirstOrDefault();

                if (timelog != null)
                {
                    accountInfo.PickedBy = timelog != null?dbContext.UserPersonalDetails.FirstOrDefault(x => x.UserId == timelog.UserId).FirstName : null;

                    accountInfo.PickedOn    = timelog != null ? (DateTime?)timelog.StartTime : null;
                    accountInfo.TimeLogId   = timelog != null ? timelog.AccountTimeLogId : 0;
                    accountInfo.CompletedOn = timelog != null ? timelog.EndTime : null;
                }

                info.Add(accountInfo);
            }

            return(info.ToList());
        }
示例#17
0
 public Task AddAccount(AccountInfoDto account)
 {
     throw new System.NotImplementedException();
 }
示例#18
0
 public Task OnSaved(AccountInfoDto savedAccount)
 {
     ShowEditModal = false;
     return(AccountModel.UpdateAccount(savedAccount));
 }
示例#19
0
 public void OnShow(AccountInfoDto selectedAccount)
 {
     SelectedAccount = selectedAccount;
     ShowEditModal   = true;
 }