Exemple #1
0
        public async Task <IActionResult> GetEditSingleItem(string key)
        {
            // add distincted from edit, by presence of key parameter
            // further on they distincted by ViewData[SaveRoute]
            if (key != null)
            {
                int id = Int32.Parse(key);
                ViewData["SaveRoute"] = StoragesRouting.EditSingleItem;
                var statusMessage = await logicValidation.CheckGetSingleUpdateModelAsync(id);

                if (statusMessage.IsCompleted)
                {
                    var model = await logic.GetSingleUpdateModelAsync(id);

                    return(View("EditSingleItem", model));
                }
                else
                {
                    return(View("CustomError", statusMessage));
                }
            }
            else
            {
                ViewData["SaveRoute"] = StoragesRouting.AddSingleItem;
                return(View("EditSingleItem"));
            }
        }
Exemple #2
0
        public async void GetStorage_FromInitializedDbTable_LogicStorageEqualExpectedStorage()
        {
            // arrange
            var expected = GetStorage();

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

            // act
            var actual = await logic.GetSingleUpdateModelAsync(expected.Id);

            // assert
            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);
        }