Exemple #1
0
        public async Task <ListResultDto <ProjectListDto> > GetAll(GetAllProjectsInput input)
        {
            var projects = await this._projectRepository
                           .GetAll()
                           .Include(m => m.AssignedPerson)
                           //.Where(m => m.Title.Contains(input.Title))
                           .WhereIf(!string.IsNullOrEmpty(input.Title), m => m.Title.Contains(input.Title))
                           .OrderByDescending(t => t.CreationTime)
                           .ToListAsync();

            return(new ListResultDto <ProjectListDto>(ObjectMapper.Map <List <ProjectListDto> >(projects)));
        }
Exemple #2
0
        public async Task <PagedResultDto <GetProjectForViewDto> > GetAll(GetAllProjectsInput input)
        {
            var filteredProjects = _projectRepository.GetAll()
                                   .Include(e => e.ManagerFk)
                                   .Include(e => e.LocationFk)
                                   .Include(e => e.OrganizationUnitFk)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.NameAr.Contains(input.Filter) || e.NameEn.Contains(input.Filter))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameArFilter), e => e.NameAr == input.NameArFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameEnFilter), e => e.NameEn == input.NameEnFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.UserNameFilter), e => e.ManagerFk != null && e.ManagerFk.Name == input.UserNameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.LocationTitleEnFilter), e => e.LocationFk != null && e.LocationFk.TitleEn == input.LocationTitleEnFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.OrganizationUnitDisplayNameFilter), e => e.OrganizationUnitFk != null && e.OrganizationUnitFk.DisplayName == input.OrganizationUnitDisplayNameFilter);

            var pagedAndFilteredProjects = filteredProjects
                                           .OrderBy(input.Sorting ?? "id asc")
                                           .PageBy(input);

            var projects = from o in pagedAndFilteredProjects
                           join o1 in _lookup_userRepository.GetAll() on o.ManagerId equals o1.Id into j1
                           from s1 in j1.DefaultIfEmpty()

                           join o2 in _lookup_locationRepository.GetAll() on o.LocationId equals o2.Id into j2
                           from s2 in j2.DefaultIfEmpty()

                           join o3 in _lookup_organizationUnitRepository.GetAll() on o.OrganizationUnitId equals o3.Id into j3
                           from s3 in j3.DefaultIfEmpty()

                           select new GetProjectForViewDto()
            {
                Project = new ProjectDto
                {
                    NameAr = o.NameAr,
                    NameEn = o.NameEn,
                    Id     = o.Id,
                    Code   = o.Code,
                    Number = o.Number
                },
                UserName = s1 == null ? "" : s1.Name.ToString(),
                LocationTitleEn             = s2 == null ? "" : s2.TitleEn.ToString(),
                OrganizationUnitDisplayName = s3 == null ? "" : s3.DisplayName.ToString()
            };

            var totalCount = await filteredProjects.CountAsync();

            return(new PagedResultDto <GetProjectForViewDto>(
                       totalCount,
                       await projects.ToListAsync()
                       ));
        }
        public async Task <PagedResultDto <GetProjectForViewDto> > GetAll(GetAllProjectsInput input)
        {
            var filteredProjects = _projectRepository.GetAll()
                                   .Include(e => e.AccountFk)
                                   .Include(e => e.TeamFk)
                                   .Include(e => e.SysStatusFk)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.Name.Contains(input.Filter) || e.Description.Contains(input.Filter) || e.Remark.Contains(input.Filter))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameFilter), e => e.Name == input.NameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.DescriptionFilter), e => e.Description == input.DescriptionFilter)
                                   .WhereIf(input.MinStartDateFilter != null, e => e.StartDate >= input.MinStartDateFilter)
                                   .WhereIf(input.MaxStartDateFilter != null, e => e.StartDate <= input.MaxStartDateFilter)
                                   .WhereIf(input.MinEndDateFilter != null, e => e.EndDate >= input.MinEndDateFilter)
                                   .WhereIf(input.MaxEndDateFilter != null, e => e.EndDate <= input.MaxEndDateFilter)
                                   .WhereIf(input.IsApproveFilter > -1, e => (input.IsApproveFilter == 1 && e.IsApprove) || (input.IsApproveFilter == 0 && !e.IsApprove))
                                   .WhereIf(input.IsActiveFilter > -1, e => (input.IsActiveFilter == 1 && e.IsActive) || (input.IsActiveFilter == 0 && !e.IsActive))
                                   .WhereIf(input.PublishFilter > -1, e => (input.PublishFilter == 1 && e.Publish) || (input.PublishFilter == 0 && !e.Publish))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.RemarkFilter), e => e.Remark == input.RemarkFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.AccountNameFilter), e => e.AccountFk != null && e.AccountFk.Name == input.AccountNameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.TeamNameFilter), e => e.TeamFk != null && e.TeamFk.Name == input.TeamNameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.SysStatusNameFilter), e => e.SysStatusFk != null && e.SysStatusFk.Name == input.SysStatusNameFilter);

            var pagedAndFilteredProjects = filteredProjects
                                           .OrderBy(input.Sorting ?? "id asc")
                                           .PageBy(input);

            var projects = from o in pagedAndFilteredProjects
                           join o1 in _lookup_accountRepository.GetAll() on o.AccountId equals o1.Id into j1
                           from s1 in j1.DefaultIfEmpty()

                           join o2 in _lookup_teamRepository.GetAll() on o.TeamId equals o2.Id into j2
                           from s2 in j2.DefaultIfEmpty()

                           join o3 in _lookup_sysStatusRepository.GetAll() on o.SysStatusId equals o3.Id into j3
                           from s3 in j3.DefaultIfEmpty()

                           select new GetProjectForViewDto()
            {
                Project = new ProjectDto
                {
                    Name        = o.Name,
                    Description = o.Description,
                    StartDate   = o.StartDate,
                    EndDate     = o.EndDate,
                    IsApprove   = o.IsApprove,
                    IsActive    = o.IsActive,
                    Publish     = o.Publish,
                    Remark      = o.Remark,
                    Id          = o.Id
                },
                AccountName = s1 == null ? "" : s1.Name.ToString(),
                TeamName      = s2 == null ? "" : s2.Name.ToString(),
                SysStatusName = s3 == null ? "" : s3.Name.ToString()
            };

            var totalCount = await filteredProjects.CountAsync();

            return(new PagedResultDto <GetProjectForViewDto>(
                       totalCount,
                       await projects.ToListAsync()
                       ));
        }
Exemple #4
0
        public async Task <PagedResultDto <GetProjectForViewDto> > GetAll(GetAllProjectsInput input)
        {
            var filteredProjects = _projectRepository.GetAll()
                                   .Include(e => e.ManagerFk)
                                   .Include(e => e.Locations)
                                   .Include(e => e.OrganizationUnitFk)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.NameAr.Contains(input.Filter) || e.NameEn.Contains(input.Filter))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameArFilter), e => e.NameAr == input.NameArFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameEnFilter), e => e.NameEn == input.NameEnFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.UserNameFilter), e => e.ManagerFk != null && e.ManagerFk.Name == input.UserNameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.LocationTitleEnFilter), e => e.Locations.Count != 0 && e.Locations.Any(x => x.LocationFk.TitleEn == input.LocationTitleEnFilter))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.OrganizationUnitDisplayNameFilter), e => e.OrganizationUnitFk != null && e.OrganizationUnitFk.DisplayName == input.OrganizationUnitDisplayNameFilter);

            var pagedAndFilteredProjects = filteredProjects
                                           .OrderBy(input.Sorting ?? "id asc")
                                           .PageBy(input);

            var projects = from o in pagedAndFilteredProjects
                           join o1 in _lookup_userRepository.GetAll() on o.ManagerId equals o1.Id into j1
                           from s1 in j1.DefaultIfEmpty()

                           join o3 in _lookup_organizationUnitRepository.GetAll() on o.OrganizationUnitId equals o3.Id into j3
                           from s3 in j3.DefaultIfEmpty()

                           select new GetProjectForViewDto()
            {
                Project = new ProjectDto
                {
                    NameAr = o.NameAr,
                    NameEn = o.NameEn,
                    Id     = o.Id,
                    Code   = o.Code,
                    Number = o.Number
                },
                UserName = s1 == null ? "" : s1.Name.ToString(),
                LocationsTitles = o.Locations.Select(x => x.LocationFk.TitleEn),

                OrganizationUnitDisplayName = s3 == null ? "" : s3.DisplayName.ToString()
            };

            var totalCount = await filteredProjects.CountAsync();

            var projectList = projects.ToList();

            foreach (var obj in projectList)
            {
                var locationIds = _lookup_projectLocationRepository.GetAllList(x => x.ProjectId == obj.Project.Id)?.Select(y => y.LocationId)?.ToList();
                if (locationIds.Count > 0)
                {
                    var locationMachineIds = _locationMachineRepository.GetAllList(x => locationIds.Contains(x.LocationId.Value))?.Select(y => y.MachineId)?.ToList();
                    if (locationMachineIds.Count > 0)
                    {
                        obj.MachinesNames = _machineRepository.GetAllList(x => locationMachineIds.Contains(x.Id))?.Select(y => y.NameEn);
                    }
                }
            }

            return(new PagedResultDto <GetProjectForViewDto>(
                       totalCount,
                       projectList
                       ));
        }
Exemple #5
0
 public async Task <IActionResult> Projects(GetAllProjectsInput input)
 {
     return(View(await this._projectAppService.GetAll(input)));
 }