public async Task <IActionResult> Index(string key, int currentPage = 1, int itemsOnPage = 20)
        {
            int facilityId = Int32.Parse(key);

            ViewData["FacilityId"] = facilityId;
            var model = await logic.GetAllDataModelAsync(facilityId);

            // form pagenation model
            var pagenationModel = new Pagenation <FacilityTechProcessesDataModel>(model, itemsOnPage, currentPage);

            return(View(pagenationModel));
        }
예제 #2
0
        public async void GetListFacilityTechProcessesDataModel_FromInitializedDbTables_LogicFacilityTechProcessesDataModelsEqualExpectedFacilityTechProcessesDataModels()
        {
            var facilities    = GetFacilities();
            var recipes       = GetRecipes();
            var techProcesses = GetTechProcesses();

            fixture.db.Facility.AddRange(facilities);
            fixture.db.Recipe.AddRange(recipes);
            fixture.db.TechProcess.AddRange(techProcesses);
            await fixture.db.SaveChangesAsync();

            var expected = new List <FacilityTechProcessesDataModel>
            {
                new FacilityTechProcessesDataModel
                {
                    FacilityId       = 44440,
                    FacilityName     = "Test facility",
                    DayEfficiency    = 41,
                    RecipeId         = 44440,
                    RecipeContent    = "Im recipe #1 content",
                    RecipeGovApprov  = true,
                    RecipeTechApprov = true
                },
                new FacilityTechProcessesDataModel
                {
                    FacilityId       = 44440,
                    FacilityName     = "Test facility",
                    DayEfficiency    = 42,
                    RecipeId         = 44441,
                    RecipeContent    = "Im recipe #2 content",
                    RecipeGovApprov  = true,
                    RecipeTechApprov = false
                },
                new FacilityTechProcessesDataModel
                {
                    FacilityId       = 44440,
                    FacilityName     = "Test facility",
                    DayEfficiency    = 43,
                    RecipeId         = 44442,
                    RecipeContent    = "Im recipe #3 content",
                    RecipeGovApprov  = false,
                    RecipeTechApprov = true
                }
            };

            // act
            var actual = (await logic.GetAllDataModelAsync(expected.First().FacilityId)).ToList();

            // assert
            foreach (var expectedItem in expected)
            {
                Assert.Contains(actual, actualItem =>
                                expectedItem.RecipeId == actualItem.RecipeId &&
                                expectedItem.FacilityId == actualItem.FacilityId &&
                                expectedItem.FacilityName == actualItem.FacilityName &&
                                expectedItem.DayEfficiency == actualItem.DayEfficiency &&
                                expectedItem.RecipeContent == actualItem.RecipeContent &&
                                expectedItem.RecipeGovApprov == actualItem.RecipeGovApprov &&
                                expectedItem.RecipeTechApprov == actualItem.RecipeTechApprov);
            }
        }