Exemplo n.º 1
0
        public IActionResult Index()
        {
            List <ViewIndexTimetableVM> viewIndexTimetableVMs = new List <ViewIndexTimetableVM>();
            var timetableList = _timetableRepository.GetAllTimetable().GroupBy(g => g.DateOrder);

            foreach (var itemDate in timetableList)
            {
                var listBuilding = new List <int>();

                foreach (var valueInfo in itemDate)
                {
                    bool bExist   = false;
                    var  building = new Building();
                    building = _buildingRepository.GetBuildingWithId(valueInfo.BuildingId);

                    var workersList  = _timetableRepository.GetWorkersWithTimetable(valueInfo.BuildingId, valueInfo.DateOrder).ToList();
                    var vehiclesList = _timetableRepository.GetVehiclesWithTimetable(valueInfo.BuildingId, valueInfo.DateOrder).ToList();

                    bExist = listBuilding.Contains(valueInfo.BuildingId);

                    if (bExist == false)
                    {
                        var timetableBuildingVM = new ViewIndexTimetableVM();
                        timetableBuildingVM.DateOrder    = valueInfo.DateOrder;
                        timetableBuildingVM.BuildingId   = valueInfo.BuildingId;
                        timetableBuildingVM.BuildingName = building.Name;
                        timetableBuildingVM.Workers      = workersList;
                        timetableBuildingVM.Vehicles     = vehiclesList;
                        viewIndexTimetableVMs.Add(timetableBuildingVM);
                        listBuilding.Add(valueInfo.BuildingId);
                    }
                }
            }

            return(View(viewIndexTimetableVMs));
        }
Exemplo n.º 2
0
        public IActionResult Edit(int id)
        {
            var building = _buildingRepostiory.GetBuildingWithId(id);

            return(View(building));
        }