Example #1
0
        public IActionResult MakeWithdrawal(MondeyViewModel model)
        {
            if (ModelState.IsValid)
            {
                Withdrawals newWithdrawal = new Withdrawals
                {
                    amount     = double.Parse(model.amount, System.Globalization.CultureInfo.InvariantCulture),
                    created_at = DateTime.Now,
                    updated_at = DateTime.Now
                };
                Accounts currentAccount = _context.Accounts.SingleOrDefault(account => account.id == (int)HttpContext.Session.GetInt32("CurrentAccount"));
                currentAccount.Balance -= newWithdrawal.amount;
                currentAccount.Withdrawals.Add(newWithdrawal);
                Users currentUser = _context.Users.SingleOrDefault(user => user.id == (int)HttpContext.Session.GetInt32("CurrUserId"));
                currentUser.Withdrawals.Add(newWithdrawal);
                _context.SaveChanges();
                return(RedirectToAction("goToWithdrawalPage"));
            }
            List <string> errors = ModelState.Select(x => x.Value.Errors)
                                   .Where(y => y.Count > 0)
                                   .Select(z => z[0].ErrorMessage.ToString())
                                   .ToList();

            TempData["error_list"] = errors;
            return(RedirectToAction("goToWithdrawalPage"));
        }
Example #2
0
 public WithDrawalsManager(long withdrawalsId)
 {
     Withdrawals = MongoHelper.Instance.FindOne <Withdrawals>(withdrawalsId);
     if (Withdrawals == null)
     {
         throw new NotImplementedException();
     }
 }
Example #3
0
        public ActionResult Withdrawals(long id = 0)
        {
            var model = MongoHelper.Instance.FindOne <Withdrawals>(id);

            if (model == null)
            {
                model = new Withdrawals {
                    Id = 0, UserId = CurrentUserId, UserName = User.Identity.Name
                }
            }
            ;
            return(View(model));
        }
Example #4
0
        public bool CreateWithdrawal(Nullable <decimal> amount, int transactionId)
        {
            using (var context = new Bank_LibraryEntities())
            {
                var newWithdrawal =
                    new Withdrawals
                {
                    Amount        = amount,
                    TransactionID = transactionId
                };
                context.Withdrawals.Add(newWithdrawal);

                return(context.SaveChanges() == 1);
            }
        }
Example #5
0
        public JsonResult Withdrawals(Withdrawals model)
        {
            var isNew = model.Id <= 0;

            UpdateModel(model);
            model.UserId   = CurrentUserId;
            model.UserName = User.Identity.Name;
            var wd = new WithDrawalsGenerator(model);

            if (isNew)
            {
                var result = wd.Generator();
                return(Json(new { result = result.Item1, msg = result.Item2, url = "/User/WithdrawalsList" }));
            }
            else
            {
                var result = wd.ReGenerator();
                return(Json(new { result = result.Item1, msg = result.Item2, url = "/User/WithdrawalsList" }));
            }
        }
        public ActionResult Apply(WithdrawalsViewModel model)
        {
            ResponseModel response = new ResponseModel();
            //Guid guid = Guid.NewGuid();
            Account account = accountService.GetById(LoginAccount.Id);

            if (string.IsNullOrEmpty(account.Name) || string.IsNullOrEmpty(account.Bank) || string.IsNullOrEmpty(account.BankBranch) || string.IsNullOrEmpty(account.BankNumber))
            {
                response.Success = false;
                response.Msg     = "您还未进行实名认证!请完善个人信息和银行卡信息";
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    foreach (var item in ModelState)
                    {
                        if (item.Value.Errors.Count > 0)
                        {
                            response.Success = false;
                            response.Msg     = item.Value.Errors.FirstOrDefault().ErrorMessage;
                        }
                    }
                }
                else
                {
                    Withdrawals entity = AutoMapper.Mapper.Map <Withdrawals>(model);
                    entity.AccountId = LoginAccount.Id;
                    entity.IsAudit   = false;
                    withdrawalsService.Add(entity);
                    unitOfWork.Commit();
                    response.Success     = true;
                    response.RedirectUrl = Url.Action("Index");
                    response.Msg         = "已成功申请提现!";
                }
            }
            return(Json(response));
        }
Example #7
0
        public async Task <ActionResult> Check(Guid?id)
        {
            ResponseModel response = new ResponseModel();
            Withdrawals   model    = withdrawalService.GetById(id.Value);
            Account       account  = model.Account;

            if (model.Amount > account.Amount)
            {
                response.Msg     = "提现金额已超限!";
                response.Success = false;
                return(Json(response, JsonRequestBehavior.AllowGet));
            }

            //1.入金mt4金额
            //2.修改account的金额
            //3.修改审核状态
            bool flg = await mt4Service.ModifyBalance(model.Account.MT4Account, model.Amount * -1);

            if (flg)
            {
                account.Amount -= model.Amount;
                model.IsAudit   = true;
                accountService.Update(account);
                withdrawalService.Update(model);
                unitOfWork.Commit();
                response.Msg         = "成功审核提现申请!";
                response.Success     = true;
                response.RedirectUrl = RedirectUrl;
            }
            else
            {
                response.Msg     = "链接交易服务器失败!请重试...";
                response.Success = false;
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
 public void Standard(WithdrawOutput output)
 {
     Withdrawals.Add(output);
 }
Example #9
0
 public void Handle(Application.Boundaries.Withdraw.Output output)
 {
     Withdrawals.Add(output);
 }
 public void Default(Application.Boundaries.Withdraw.WithdrawOutput output)
 {
     Withdrawals.Add(output);
 }
        public async Task <int> InsertAsync(WithdrawalEntity entity)
        {
            var result = await Withdrawals.Upsert(entity).On(e => e.TransactionId).NoUpdate().RunAsync();

            return(result);
        }
 public async Task UpdateAsync(IEnumerable <WithdrawalEntity> entities)
 {
     Withdrawals.UpdateRange(entities);
     await SaveChangesAsync();
 }
 public WithDrawalsGenerator(Withdrawals wd)
 {
     _WithDrawalsIntegral = wd;
     AvaliableIntegral    = new IntegralCalculator(wd.UserId).Integral;
 }
Example #14
0
        public ActionResult Audit(Withdrawals model)
        {
            var result = IWithdrawalsService.Update(model);

            return(JResult(result));
        }