Esempio n. 1
0
        private IEnumerable <Guid> GetEmployeeIdListForCurrentUser()
        {
            IMemberModel currentUser = memberService.GetCurrentUser();

            return(currentUser.IsAdmin()
                ? memberService.GetAll().Select(x => x.MemberId)
                : memberService.GetEmployeesByManagementDepartment(currentUser.ActiveManagementDepartmentId.Value).Select(x => x.MemberId));
        }
Esempio n. 2
0
        private List <Job> GetJobs(IEnumerable <Guid> categoryIds, IMemberModel user)
        {
            List <Job> jobs = user.IsAdmin()
                    ? jobProvider.Get(categoryIds)
                    : jobProvider.GetByCategoryIdsForCoordinator(categoryIds, user);

            return(jobs);
        }
Esempio n. 3
0
        private IEnumerable <IMemberModel> GetMembers(IMemberModel member)
        {
            if (member.IsAdmin())
            {
                return(memberService.GetAll());
            }

            return(memberService.GetAllowedMembersForJobByDepartmentId(member.ActiveManagementDepartmentId.Value));
        }
Esempio n. 4
0
        private IEnumerable <IGroupModel> GetGroups(IMemberModel member)
        {
            if (member.IsAdmin())
            {
                return(groupService.GetAll());
            }

            return(groupService.GetByManagementId(member.ActiveManagementDepartmentId.Value));
        }
        public IEnumerable <HousingDepartmentViewModel> GetHousingDepartments()
        {
            IMemberModel currentMember = memberService.GetCurrentUser();

            IEnumerable <IHousingDepartmentModel> housingDepartments = currentMember.IsAdmin()
                ? managementDepartmentService.GetAllHousingDepartments()
                : managementDepartmentService.GetHousingDepartments(currentMember.ActiveManagementDepartmentId.Value);

            var housingDepartmentsView = housingDepartments.Map <IEnumerable <HousingDepartmentViewModel> >();

            return(housingDepartmentsView.OrderBy(x => x.Name));
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public async Task <FormattedJobAssignViewModel> GetJobAssigns(string jobId, UploadedContentEnum?contentType)
        {
            IMemberModel currentUser = memberService.GetCurrentUser();
            IJob         job         = await jobService.GetJobById(jobId);

            var result = new FormattedJobAssignViewModel();

            if (job.RelationGroupList.Any() && job.ParentId != null)
            {
                Guid housingDepartmentId = job.RelationGroupList.First().HousingDepartmentId;
                IEnumerable <Guid> relationGroupIdList    = job.RelationGroupList.Select(x => x.RelationGroupId).ToList();
                JobAssign          globalGroupedJobAssign = jobService.GetGlobalJobAssignForGroupedTask(job);
                List <JobAssign>   jobAssigns             = jobService.GetJobAssignList(relationGroupIdList);
                result.GlobalAssign = globalGroupedJobAssign.Map <JobAssignViewModel>();
                result.Assigns      = jobAssigns.Where(i => !i.IsGlobal && i.HousingDepartmentIdList.Contains(housingDepartmentId)).Select(i => i.Map <JobAssignViewModel>()).ToList();
                result.AddressList  = jobService.GetRelatedAddressListForHousingDepartment(relationGroupIdList, housingDepartmentId, isParent: false);
                result.IsGroupedJob = true;
                result.IsChildJob   = job.ParentId != null;
            }
            else
            {
                IFormattedJobAssign jobAssign = jobService.GetAllByJobIdFormatted(jobId, currentUser.IsAdmin() ? null : currentUser.ActiveManagementDepartmentId);
                result = Mapper.Map <FormattedJobAssignViewModel>(jobAssign);
            }

            result.CurrentUser             = currentUser;
            result.GlobalAssign.UploadList = GetUploadListModel(result.GlobalAssign.UploadList, contentType);

            foreach (var assign in result.Assigns)
            {
                assign.UploadList = GetUploadListModel(assign.UploadList, contentType);
            }

            return(result);
        }