Пример #1
0
        public async Task <List <IOperationalTaskModel> > GetByDepartmentIdYearWeek(Guid departmentId, int year, int weekNumber)
        {
            List <IOperationalTaskModel> viewModelList = new List <IOperationalTaskModel>();

            List <JobAssign> jobAssigns = jobAssignProvider.GetByDepartmentWeekAndYear(departmentId, year, weekNumber);

            foreach (var jobAssign in jobAssigns)
            {
                foreach (var jobId in jobAssign.JobIdList)
                {
                    IOperationalTaskModel viewModel = new OperationalTaskModel();

                    FillJobAssignData(viewModel, jobAssign, departmentId, JobTypeEnum.AdHock);

                    List <IDayAssign> dayAssignList = dayAssignService.GetDayAssigns(jobAssign.Id, jobId, departmentId, weekNumber);
                    IDayAssign        dayAssign     = dayAssignList.FirstOrDefault(); // adhock tasks have only one day assign
                    FillDayAssignData(viewModel, dayAssign, JobTypeEnum.AdHock);

                    Job job = await jobProvider.Get(jobId);

                    FillJobData(viewModel, job, departmentId, JobTypeEnum.AdHock);

                    FillCategory(viewModel);

                    viewModelList.Add(viewModel);
                }
            }

            return(viewModelList);
        }
Пример #2
0
        public HousingDepartmentYearPlanModel GetAllData(Guid departmentId, int year)
        {
            IEnumerable <ICategoryModel>        categories   = categoryService.GetTree();
            List <Tuple <ICategoryModel, int> > categoryList = categories.FlattenWithLevel(c => c.Children).ToList();
            IEnumerable <Guid> categoryIds = categoryList.Select(c => c.Item1.Id);
            IMemberModel       currentUser = memberService.GetCurrentUser();
            List <Job>         jobList     = currentUser.IsAdmin()
                ? jobProvider.Get(categoryIds, onlyFacilityTask: true)
                : jobProvider.GetByCategoryIdsForCoordinator(categoryIds, currentUser, true);

            IEnumerable <YearPlanItemViewModel>            yearPlanItems    = GetYearPlanItems(currentUser, categoryList, jobList);
            IDictionary <string, List <YearPlanWeekData> > yearPlanWeekData = GetYearPlanWeekData(departmentId, year, jobList);

            var result = new HousingDepartmentYearPlanModel
            {
                YearPlanItems = yearPlanItems,
                WeeksData     = yearPlanWeekData
            };

            return(result);
        }