Exemplo n.º 1
0
        public async Task <ActionResult> Add(WebUser user, DebtAddModel model)
        {
            if (ModelState.IsValid)
            {
                var debt = new Debt()
                {
                    DateBegin    = DateTime.Now,
                    Person       = model.Person,
                    TypeOfFlowId = model.TypeOfFlowId,
                    AccountId    = model.AccountId,
                    Summ         = model.Summ,
                    UserId       = user.Id
                };
                try
                {
                    await _createCloseDebtService.CreateAsync(debt);
                }
                catch (ServiceException e)
                {
                    throw new WebUiException($"Ошибка в контроллере {nameof(DebtController)} в методе {nameof(Add)}", e);
                }

                return(RedirectToAction("DebtList"));
            }
            model.Accounts = (await AccountList(user.Id)).ToList();
            return(PartialView("_Add", model));
        }
        public async Task CreateAsync(Debt debt)
        {
            await _createCloseDebtService.CreateAsync(debt);

            await CreateOpenedDebtPayingItem(debt);
        }