Пример #1
0
        public async void UpdateTechProcess_AtInitializedDbTable_UpdatedTechProcessEqualExpectedTechProcess()
        {
            // arrange
            var techProcess = GetTechProcess();

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

            var expected = new TechProcess
            {
                FacilityId    = techProcess.FacilityId,
                RecipeId      = techProcess.RecipeId,
                DayEfficiency = (decimal)78.9012
            };

            // act
            await logic.UpdateDataModelAsync(expected);

            // assert
            var actual = await fixture.db.TechProcess.FirstOrDefaultAsync(i => i.FacilityId == techProcess.FacilityId && i.RecipeId == techProcess.RecipeId);

            Assert.Equal(expected.FacilityId, actual.FacilityId);
            Assert.Equal(expected.RecipeId, actual.RecipeId);
            Assert.Equal(expected.DayEfficiency, actual.DayEfficiency);
        }
        public async Task <IActionResult> EditSingleItem(TechProcess model)
        {
            var statusMessage = await logicValidation.CheckUpdateDataModelAsync((model.FacilityId, model.RecipeId));

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

                await logProvider.AddToLogAsync($"Updated technological process information (Facility Id: {model.FacilityId}; Recipe Id: {model.RecipeId}).");

                return(RedirectToRoute(FacilityTechProcessesRouting.Index, new { key = model.FacilityId }));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }