public ActionResult NewDeposit(NewDepositViewModel model) { var termsId = Convert.ToByte(Request["termsId"]); ViewData["termsId"] = termsId; var userId = User.Identity.GetUserId(); if (ModelState.IsValid) { var card = NewDepositHandler.GetCardById(model.CardId); if (CardHasEnoughFunds(card.Balance, model.Amount)) { var newDeposit = NewDepositHandler .CreateNewDeposit(model.Amount, model.WayOfAccumulationId, userId,termsId, card.Id); NewDepositHandler.DecreaseCardBalanceByDepositAmount(newDeposit.InitialAmount, card.Id); string cardHistoryDescription = String.Format("Opening deposit #{0} of {1} ({2}).", newDeposit.Id, newDeposit.Balance, NewDepositHandler.GetCurrencyByDepositTermsId(newDeposit.TermId).Abbreviation); NewDepositHandler.AddCardHistoryRecord(card.Id, cardHistoryDescription); } else { return PartialView("_Message", new MessageViewModel("Not enough money.", false)); } return PartialView("_Message", new MessageViewModel("Deposit has been opened successfully.", true)); } var cards = CardsService.CreateUserCardsByCurrencyList(userId, termsId); var waysOfAccumulation = DepositWaysOfAccumulationService.GetList(); model = new NewDepositViewModel(cards, waysOfAccumulation); return PartialView("NewDeposit", model); }
public ActionResult NewDeposit() { var termsId = Convert.ToByte(Request["termsId"]); ViewData["termsId"] = termsId; var userId = User.Identity.GetUserId(); var cards = CardsService.CreateUserCardsByCurrencyList(userId, termsId); var waysOfAccumulation = DepositWaysOfAccumulationService.GetList(); var model = new NewDepositViewModel(cards, waysOfAccumulation); return PartialView("NewDeposit", model); }