Example #1
0
 public async Task <JsonResult> OnPostConfirmAsync()
 {
     return(await this.ProcessAjaxPostRequestAsync(async request =>
     {
         try
         {
             var args = request.FromJson <ConfirmBillArgs>();
             if (args.Account.IsNullOrEmpty())
             {
                 return AjaxResponse.ErrorResponse("Выберите счет");
             }
             var account = await _accountQueries.GetByName(args.Account);
             if (account == null)
             {
                 return AjaxResponse.ErrorResponse($"Нет счета с именем \"{args.Account}\"");
             }
             var bill = args.Bill.FromJson <ExpenseBillModel>();
             if (bill.Items.Count == 0)
             {
                 return AjaxResponse.ErrorResponse("Добавьте в чек хотя бы один товар");
             }
             bill.ExpenseFlowId = Good.FlowId;
             bill.AccountId = account.Id;
             await _expensesBillCommands.Save(bill);
             return AjaxResponse.SuccessResponse();
         }
         catch (Exception exc)
         {
             return AjaxResponse.ErrorResponse(exc.Message);
         }
     }));
 }
Example #2
0
 public async Task <JsonResult> OnPostSaveAsync()
 {
     return(await this.ProcessAjaxPostRequestAsync(async request =>
     {
         try
         {
             var board = request.FromJson <DistributionBoard>();
             await _distributionCommands.Save(board);
             return AjaxResponse.SuccessResponse();
         }
         catch (Exception exc)
         {
             return AjaxResponse.ErrorResponse(exc.ToString());
         }
     }));
 }