Exemple #1
0
        public async void UpdateStorage_AtInitializedDbTable_UpdatedStorageEqualExpectedStorage()
        {
            // arrange
            var storage = GetStorage();

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

            var expected = new Storage
            {
                Id        = storage.Id,
                Name      = "Tested storage",
                Latitude  = (decimal)12.3456,
                Longitude = (decimal)78.9012,
                CompanyId = 44440
            };

            // act
            await logic.UpdateDataModelAsync(expected);

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

            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Latitude, actual.Latitude);
            Assert.Equal(expected.Longitude, actual.Longitude);
            Assert.Equal(expected.CompanyId, actual.CompanyId);
        }
Exemple #2
0
        public async Task <IActionResult> EditSingleItem(Storage model)
        {
            var statusMessage = await logicValidation.CheckUpdateDataModelAsync(model.Id);

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

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

                return(RedirectToRoute(StoragesRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }