Пример #1
0
        public async void UpdateOperation_AtInitializedDbTable_UpdatedOperationEqualExpectedOperation()
        {
            // arrange
            var operation = GetOperation();

            fixture.db.Add(operation);
            await fixture.db.SaveChangesAsync();

            var expected = new Operation
            {
                Id            = 44440,
                ProductId     = 44440,
                Price         = 220,
                Quantity      = 220,
                StorageFromId = 44440,
                StorageToId   = 44441,
                TransactionId = 44440
            };

            // act
            await logic.UpdateDataModelAsync(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);
        }
Пример #2
0
        public async Task <IActionResult> EditSingleItem(Operation model)
        {
            var statusMessage = await logicValidation.CheckUpdateDataModelAsync(model.Id);

            if (statusMessage.IsCompleted)
            {
                await logic.UpdateDataModelAsync(model);

                await logProvider.AddToLogAsync($"Updated operation information (Id: {model.Id}).");

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