Пример #1
0
        public async Task <IActionResult> AddSingleItem(Operation model)
        {
            var operation = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new operation (Id: {operation.Id}).");

            return(RedirectToRoute(TransactionsRouting.SingleItem, new { key = model.TransactionId }));
        }
Пример #2
0
        public async Task <IActionResult> AddSingleItem(Operation model)
        {
            var statusMessage = await logicValidation.CheckAddDataModelAsync(model);

            logicValidation.ValidateModel(statusMessage, ModelState);
            if (statusMessage.IsCompleted)
            {
                var operation = await logic.AddDataModelAsync(model);

                await logProvider.AddToLogAsync($"Added new operation (Id: {operation.Id}).");

                return(RedirectToRoute(TransactionsRouting.SingleItem, new { key = model.TransactionId }));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }
Пример #3
0
        public async void AddOperation_ToEmptyDbTable_AddedOperationEqualExpectedOperation()
        {
            // arrange
            var expected = GetOperation();

            // act
            await logic.AddDataModelAsync(expected);

            // assert
            var actual = await fixture.db.Operation.FirstOrDefaultAsync(i => i.Id == expected.Id);

            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Price, actual.Price);
            Assert.Equal(expected.ProductId, actual.ProductId);
            Assert.Equal(expected.Quantity, actual.Quantity);
            Assert.Equal(expected.StorageFromId, actual.StorageFromId);
            Assert.Equal(expected.StorageToId, actual.StorageToId);
            Assert.Equal(expected.TransactionId, actual.TransactionId);
        }