コード例 #1
0
ファイル: ProjectsAppService.cs プロジェクト: iatta/GEC
        protected virtual async Task Update(CreateOrEditProjectDto input)
        {
            var project = await _projectRepository.FirstOrDefaultAsync((int)input.Id);

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

            var oldProjectLocations = new HashSet <ProjectLocation>(project.Locations.ToList());
            var newProjectLocations = new HashSet <ProjectLocationDto>(input.Locations.ToList());

            foreach (var detail in oldProjectLocations)
            {
                if (!newProjectLocations.Any(x => x.Id == detail.Id))
                {
                    project.Locations.Remove(detail);
                }
                else
                {
                    var inputDetail = newProjectLocations.Where(x => x.Id == detail.Id).FirstOrDefault();
                }
            }

            foreach (var item in newProjectLocations)
            {
                if (item.Id == 0)
                {
                    project.Locations.Add(ObjectMapper.Map <ProjectLocation>(item));
                }
            }
            await _projectRepository.UpdateAsync(project);
        }
コード例 #2
0
ファイル: ProjectsAppService.cs プロジェクト: war-man/GEC
        protected virtual async Task Create(CreateOrEditProjectDto input)
        {
            var project = ObjectMapper.Map <Project>(input);



            await _projectRepository.InsertAsync(project);
        }
コード例 #3
0
 public async Task CreateOrEdit(CreateOrEditProjectDto input)
 {
     if (input.Id == null)
     {
         await Create(input);
     }
     else
     {
         await Update(input);
     }
 }
コード例 #4
0
        protected virtual async Task Create(CreateOrEditProjectDto input)
        {
            var project = ObjectMapper.Map <Project>(input);


            if (AbpSession.TenantId != null)
            {
                project.TenantId = (int?)AbpSession.TenantId;
            }


            await _projectRepository.InsertAsync(project);
        }
コード例 #5
0
ファイル: ProjectsAppService.cs プロジェクト: iatta/GEC
        protected virtual async Task Create(CreateOrEditProjectDto input)
        {
            var project = ObjectMapper.Map <Project>(input);

            project.Locations = new List <ProjectLocation>();

            if (input.Locations.Count > 0)
            {
                foreach (var item in input.Locations)
                {
                    project.Locations.Add(ObjectMapper.Map <ProjectLocation>(item));
                }
            }


            await _projectRepository.InsertAsync(project);
        }
コード例 #6
0
        protected virtual async Task Update(CreateOrEditProjectDto input)
        {
            var project = await _projectRepository.FirstOrDefaultAsync((int)input.Id);

            ObjectMapper.Map(input, project);
        }