public async Task <GetProjectForEditOutput> GetProjectForEdit(EntityDto input)
        {
            var project = await _projectRepository.FirstOrDefaultAsync(input.Id);

            var output = new GetProjectForEditOutput {
                Project = ObjectMapper.Map <CreateOrEditProjectDto>(project)
            };

            if (output.Project.AccountId != null)
            {
                var _lookupAccount = await _lookup_accountRepository.FirstOrDefaultAsync((int)output.Project.AccountId);

                output.AccountName = _lookupAccount.Name.ToString();
            }

            if (output.Project.TeamId != null)
            {
                var _lookupTeam = await _lookup_teamRepository.FirstOrDefaultAsync((int)output.Project.TeamId);

                output.TeamName = _lookupTeam.Name.ToString();
            }

            if (output.Project.SysStatusId != null)
            {
                var _lookupSysStatus = await _lookup_sysStatusRepository.FirstOrDefaultAsync((int)output.Project.SysStatusId);

                output.SysStatusName = _lookupSysStatus.Name.ToString();
            }

            return(output);
        }
Beispiel #2
0
        public async Task <GetProjectForEditOutput> GetProjectForEdit(EntityDto input)
        {
            var project = await _projectRepository.FirstOrDefaultAsync(input.Id);

            var output = new GetProjectForEditOutput {
                Project = ObjectMapper.Map <CreateOrEditProjectDto>(project)
            };

            if (output.Project.ManagerId != null)
            {
                var _lookupUser = await _lookup_userRepository.FirstOrDefaultAsync((long)output.Project.ManagerId);

                output.UserName = _lookupUser.Name.ToString();
            }

            if (output.Project.LocationId != null)
            {
                var _lookupLocation = await _lookup_locationRepository.FirstOrDefaultAsync((int)output.Project.LocationId);

                output.LocationTitleEn = _lookupLocation.TitleEn.ToString();
            }

            if (output.Project.OrganizationUnitId != null)
            {
                var _lookupOrganizationUnit = await _lookup_organizationUnitRepository.FirstOrDefaultAsync((long)output.Project.OrganizationUnitId);

                output.OrganizationUnitDisplayName = _lookupOrganizationUnit.DisplayName.ToString();
            }

            return(output);
        }
Beispiel #3
0
        public async Task <GetProjectForEditOutput> GetProjectForEdit(EntityDto input)
        {
            var project = await _projectRepository.FirstOrDefaultAsync(input.Id);

            project.Locations = _projectLocationRepository.GetAll().Where(x => x.ProjectId == project.Id).ToList();

            var output = new GetProjectForEditOutput {
                Project = ObjectMapper.Map <CreateOrEditProjectDto>(project)
            };

            if (output.Project.ManagerId != null)
            {
                var _lookupUser = await _lookup_userRepository.FirstOrDefaultAsync((long)output.Project.ManagerId);

                output.UserName = _lookupUser.Name.ToString();
            }


            if (output.Project.ManagerAssistantId != null)
            {
                var _lookupUser = await _lookup_userRepository.FirstOrDefaultAsync((long)output.Project.ManagerAssistantId);

                output.AssistantUserName = _lookupUser.Name.ToString();
            }

            if (output.Project.LocationId != null)
            {
                var _lookupLocation = await _lookup_locationRepository.FirstOrDefaultAsync((int)output.Project.LocationId);

                output.LocationTitleEn = _lookupLocation.TitleEn.ToString();
            }

            if (output.Project.OrganizationUnitId != null)
            {
                var _lookupOrganizationUnit = await _lookup_organizationUnitRepository.FirstOrDefaultAsync((long)output.Project.OrganizationUnitId);

                output.OrganizationUnitDisplayName = _lookupOrganizationUnit.DisplayName.ToString();
            }
            foreach (var projectLocation in output.Project.Locations)
            {
                var location = _lookup_locationRepository.FirstOrDefault(x => x.Id == projectLocation.LocationId);
                if (location != null)
                {
                    projectLocation.LocationName = location.TitleEn;
                }
            }

            return(output);
        }
        public async Task <GetProjectForEditOutput> GetForEdit(NullableIdDto <Guid> input)
        {
            var            output = new GetProjectForEditOutput();
            ProjectEditDto editDto;

            if (input.Id.HasValue)
            {
                var entity = await _projectRepository.GetAsync(input.Id.Value);

                //editDto = entity.MapTo<ProjectEditDto>();

                editDto = ObjectMapper.Map <ProjectEditDto>(entity);

                //projectEditDto = ObjectMapper.Map<List<projectEditDto>>(entity);
            }
            else
            {
                editDto = new ProjectEditDto();
            }

            output.Project = editDto;
            return(output);
        }
 public CreateOrUpdateProjectModalViewModel(GetProjectForEditOutput output)
 {
     output.MapTo <GetProjectForEditOutput, CreateOrUpdateProjectModalViewModel>(this);
 }