public ActionResult CreateCashAsset(CashAssetViewModel cashAssetView)
 {
     cashAssetView.inCash = true;
     var cashAsset = mapper.GetCashAssetDomainModelWithoutAccount(cashAssetView);
     assetService.CreateCashAsset(cashAsset);
     return RedirectToAction("Index");
 }
 public ActionResult UpdateCashAsset(CashAssetViewModel cashAssetView)
 {
     var cashAsset = mapper.GetCashAssetDomainModelWithoutAccount(cashAssetView);
     BankAccount account = (cashAssetView.BankId == 0 || cashAssetView.NumberAccount == 0) ? null : bankService.GetBankAccount(cashAssetView.BankId, cashAssetView.NumberAccount);
     cashAsset.Account = account;
     assetService.UpdateCashAsset(cashAsset);
     return RedirectToAction("Index");
 }
 public CashAsset GetCashAssetDomainModelWithoutAccount(CashAssetViewModel cashAssetViewModel)
 {
     var cashAsset = new CashAsset();
     cashAsset.Id = cashAssetViewModel.Id;
     cashAsset.Name = cashAssetViewModel.Name.Trim();
     cashAsset.Amount = cashAssetViewModel.Amount;
     cashAsset.Unit = cashAssetViewModel.Unit;
     cashAsset.Cost = cashAssetViewModel.Cost;
     cashAsset.Currency = cashAssetViewModel.Currency;
     cashAsset.inCash = cashAssetViewModel.inCash;
     return cashAsset;
 }
 public CashAssetViewModel GetCashAssetViewModel(CashAsset cashAsset)
 {
     var cashAssetViewModel = new CashAssetViewModel();
     cashAssetViewModel.Id = cashAsset.Id;
     cashAssetViewModel.Name = cashAsset.Name;
     cashAssetViewModel.Amount = cashAsset.Amount;
     cashAssetViewModel.Unit = cashAsset.Unit;
     cashAssetViewModel.Cost = cashAsset.Cost;
     cashAssetViewModel.Currency = cashAsset.Currency;
     cashAssetViewModel.inCash = cashAsset.inCash;
     cashAssetViewModel.BankId = (cashAsset.Account == null) ? 0 : cashAsset.Account.Bank.Id;
     cashAssetViewModel.NumberAccount = (cashAsset.Account == null) ? 0 : cashAsset.Account.Number;
     cashAssetViewModel.Status = (cashAsset.inCash) ? "В кассе" : "Банк - " + cashAsset.Account.Bank.ToString() +  ", номер счета - " + cashAsset.Account.Number;
     return cashAssetViewModel;
 }
 public ActionResult CreateCashAsset()
 {
     var cashAssetView = new CashAssetViewModel();
     return View("CreateCashAsset", cashAssetView);
 }