コード例 #1
0
        public async Task <ActionResult> ApproveChangeEmail(int approvalId)
        {
            var model = await AdminApprovalReader.GetApproval(approvalId);

            if (model == null)
            {
                return
                    (ViewMessageModal(new ViewMessageModel(ViewMessageType.Warning, "Approval Not Found!",
                                                           $"Could not find EmailChange approval #{approvalId}")));
            }

            var user = await UserReader.GetUserByName(model.DataUser);

            return(View("ChangeEmailApproveModal", new AdminChangeEmailApproveModel
            {
                Status = model.Status,
                Requestor = model.RequestUser,
                Requested = model.Created,
                Approved = model.Approved,
                Approver = model.ApprovalUser,
                Message = model.Message,
                UserName = model.DataUser,
                NewEmailAddress = model.Data,
                OldEmailAddress = user.Email,
                ApprovalId = approvalId
            }));
        }
コード例 #2
0
        public async Task <ActionResult> Create(string currency, string userName, string returnUrl)
        {
            var user = await UserManager.FindValidByIdAsync(User.Identity.GetUserId());

            var currencyData = await CurrencyReader.GetCurrency(currency);

            if (currencyData == null || user == null)
            {
                ViewBag.Message = String.Format(Resources.UserWallet.transferCurrencyNotFoundError, currency);
                return(View("Error"));
            }

            if (currencyData.Status == CurrencyStatus.Maintenance || currencyData.Status == CurrencyStatus.Offline)
            {
                ViewBag.HideSupportLink = true;
                ViewBag.SubTitle        = String.Format("{0}: {1}", Resources.UserWallet.transferCreateStatusLabel, currencyData.Status);
                ViewBag.Message         = $"{Resources.UserWallet.transferCreateErrorMessage} <br /><br /> {Resources.UserWallet.transferCreateStatusLabel}: {currencyData.Status}<br />{Resources.UserWallet.transferCreateReasonLabel}: {(string.IsNullOrEmpty(currencyData.StatusMessage) ? Resources.UserWallet.transferCreateUnknownError : currencyData.StatusMessage)}";
                return(View("Error"));
            }

            var checkUser = await UserReader.GetUserByName(userName);

            return(View(await CreateTransferModel(user, new TransferCurrencyModel
            {
                Name = currencyData.Name,
                Symbol = currencyData.Symbol,
                ReturnUrl = GetLocalReturnUrl(returnUrl),
                UserName = checkUser?.UserName
            })));
        }
コード例 #3
0
        public async Task <CreateTransferResponseModel> SubmitUserTransfer(ApiSubmitUserTransferRequest request)
        {
            var currency = request.CurrencyId.HasValue
                                ? await CurrencyReader.GetCurrency(request.CurrencyId.Value).ConfigureAwait(false)
                                : await CurrencyReader.GetCurrency(request.Currency).ConfigureAwait(false);

            if (currency == null)
            {
                return new CreateTransferResponseModel {
                           Error = "Currency not found."
                }
            }
            ;

            var receiver = await UserReader.GetUserByName(request.UserName).ConfigureAwait(false);

            if (receiver == null)
            {
                return new CreateTransferResponseModel {
                           Error = "Receiver not found."
                }
            }
            ;

            var response = await TradeService.CreateTransfer(request.UserId.ToString(), new CreateTransferModel
            {
                CurrencyId   = currency.CurrencyId,
                Amount       = request.Amount,
                TransferType = TransferType.User,
                Receiver     = receiver.UserId
            }, true).ConfigureAwait(false);

            return(response);
        }
コード例 #4
0
        public async Task <ActionResult> Create(TransferCurrencyModel model)
        {
            var currencyData = await CurrencyReader.GetCurrency(model.Symbol);

            var user = await UserManager.FindValidByIdAsync(User.Identity.GetUserId());

            if (currencyData == null || user == null)
            {
                ViewBag.Message = String.Format(Resources.UserWallet.transferCurrencyNotFoundError, model.Symbol);
                return(View("Error"));
            }

            // Verify User
            var receivingUser = await UserReader.GetUserByName(model.UserName);

            if (receivingUser == null)
            {
                ModelState.AddModelError("UserName", String.Format(Resources.UserWallet.transferUserNotFoundError, model.UserName));
                return(View(await CreateTransferModel(user, model)));
            }
            if (receivingUser.UserId.Equals(User.Identity.GetUserId(), StringComparison.OrdinalIgnoreCase))
            {
                ModelState.AddModelError("UserName", Resources.UserWallet.transferUserIgnoredError);
                return(View(await CreateTransferModel(user, model)));
            }

            // Verify Amount
            if (model.Amount < 0.00000001m)
            {
                ModelState.AddModelError("Amount", String.Format(Resources.UserWallet.transferMinAmountError, "0.00000001", currencyData.Symbol));
                return(View(await CreateTransferModel(user, model)));
            }

            // Verify Two Factor
            if (!await UserManager.VerifyUserTwoFactorCodeAsync(TwoFactorComponent.Transfer, user.Id, model.Code1, model.Code2))
            {
                ModelState.AddModelError("TwoFactorError", Resources.UserWallet.transferTwoFactorFailedError);
                return(View(await CreateTransferModel(user, model)));
            }

            // Create transfer
            var result = await TradeService.CreateTransfer(User.Identity.GetUserId(), new CreateTransferModel
            {
                Receiver     = receivingUser.UserId,
                Amount       = model.Amount,
                CurrencyId   = model.CurrencyId,
                TransferType = TransferType.User
            });

            if (result.IsError)
            {
                ModelState.AddModelError("Error", result.Error);
                return(View(await CreateTransferModel(user, model)));
            }

            return(RedirectToAction("Summary", new { transferId = result.TransferId, returnUrl = GetLocalReturnUrl(model.ReturnUrl) }));
        }
コード例 #5
0
        public async Task <ActionResult> CheckUser(string userName)
        {
            var checkUser = await UserReader.GetUserByName(userName);

            if (checkUser != null)
            {
                return(JsonSuccess());
            }

            return(JsonError());
        }
コード例 #6
0
ファイル: UserService.cs プロジェクト: JohnCulv/Hangman
        public static void CreateUser(string name)
        {
            //Check to see if we have an existing name
            Components.Models.User user = UserReader.GetUserByName(name);

            if (user == null)
            {
                user = new Components.Models.User(name);
                UserWriter.CreateUser(user);
            }
            else
            {
                throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateUserName);
            }
        }