Пример #1
0
        public RedirectToRouteResult Transfer(TransferViewModel model)
        {
            if (ModelState.IsValid)
            {
                var sender = _bank.Accounts.FirstOrDefault(acc => acc.Number == model.From);
                var receiver = _bank.Accounts.FirstOrDefault(acc => acc.Number == model.To);
                if (sender != null && receiver != null)
                {
                    if (!sender.Transfer(model.Amount, receiver))
                        return RedirectToAction("Index", new { message = "Die Deckung des Kontos reicht nicht aus.", error = true });
                }
                else
                    return RedirectToAction("Index", new { message = "Konto nicht gefunden.", error = true });

                _bank.SaveChanges();
            }
            return RedirectToAction("Index", new { message = "Betrag erfolgreich überwiesen.", success = true });
        }
Пример #2
0
 public ActionResult Transfer(int account)
 {
     var model = new TransferViewModel { From = account };
     return View(model);
 }