Пример #1
0
        public async void CheckCloseTransaction_FromInitializedDbTable_ErrorHandlerIsCompletedTrue()
        {
            // arrange
            var productsCatalog = GetProductCatalog();
            var products        = GetProducts();
            var storages        = GetStorages();
            var transactions    = GetTransaction();
            var operations      = GetOperationIncome();

            fixture.db.AddRange(productsCatalog);
            fixture.db.AddRange(products);
            fixture.db.AddRange(storages);
            fixture.db.AddRange(transactions);
            fixture.db.AddRange(operations);
            await fixture.db.SaveChangesAsync();

            // act
            var statusMessage = await logicValidation.CheckCloseTransactionAsync(transactions.Id);

            // assert
            Assert.True(statusMessage.IsCompleted);
        }
Пример #2
0
        public async Task <IActionResult> CloseTransaction(string key)
        {
            int id            = Int32.Parse(key);
            var statusMessage = await logicValidation.CheckCloseTransactionAsync(id);

            if (statusMessage.IsCompleted)
            {
                await logic.CloseTransactionAsync(id);

                await logProvider.AddToLogAsync($"Closed transaction (Id: {key}).");

                return(RedirectToRoute(TransactionsRouting.SingleItem, new { key }));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }