public virtual ActionResult Payoff(PayoffForm form) { var user = AuthenticationHelper.CurrentUser; if (!ModelState.IsValid) return PartialView(MVC.Profile.Views.PayoffForm, form); if (form.PayoffValue == decimal.Zero) return null; var availableCash = user.GetAvailableCash(); if (availableCash < form.PayoffValue) { ModelState.AddModelError("PayoffValue",string.Format(Resources.Account.PayoffValueToHigh,availableCash)); form.PayoffValue = availableCash; return PartialView(MVC.Profile.Views.PayoffForm,form); } var transfer = new Transfer { Value = -form.PayoffValue.Value, Title = Resources.Payment.TransferCashPayoff, OrderDate = DateTime.Now, TransferDate = null, Payment = null, IsPending = false, Comment = null }; //AuthenticationHelper.CurrentUser.Transfers.Add(Transfer.Cash(-form.PayoffValue.Value, Resources.Payment.TransferCashPayoff, isTransfered: false)); //AuthenticationHelper.CurrentUser.BankAccountNumber = form.BankAccount; user.Transfers.Add(transfer); user.BankAccountNumber = form.BankAccount; Repository.User.Update(AuthenticationHelper.CurrentUser); Email.Send<UserPayoffConfirmationEmail>(user); EventLog.Event<CashPaymentEvent>(user, additionalId: transfer.Id); Flash.Success(string.Format(Resources.Payment.FlashPayoffOrderSuccess, form.PayoffValue,form.BankAccount)); return null; }
public virtual ActionResult PayoffForm(PayoffForm form = null) { return PartialView(form ?? new PayoffForm { PayoffValue = AuthenticationHelper.CurrentUser.GetAvailableCash(), BankAccount = AuthenticationHelper.CurrentUser.BankAccountNumber }); }