示例#1
0
        public bool MergeProjectSection(ProjectSectionVM sectionVM)
        {
            var section = Map <ProjectSectionVM, ProjectSection>(sectionVM);
            var result  = _projectSections.Merge(section);

            sectionVM.Id = section.Id;
            return(result);
        }
示例#2
0
        public IActionResult MergeWork(WorkAddOrUpdateVM model)
        {
            var result  = true;
            var message = string.Empty;

            try
            {
                var project = new ProjectVM
                {
                    Id          = model.Id.GetValueOrDefault(),
                    ProjectName = model.Name,
                    Description = model.Description,
                    Latitude    = (decimal?)model.Latitude,
                    Longtitude  = (decimal?)model.Longtitude
                };

                var projectCreated = UnitOfWork.Projects.MergeProject(project);
                if (projectCreated)
                {
                    if (model.Sections?.Count() > 0)
                    {
                        foreach (var section in model.Sections)
                        {
                            var _section = new ProjectSectionVM
                            {
                                Id          = section.Id.GetValueOrDefault(),
                                Description = section.Description,
                                SectionName = section.Name,
                                ProjectId   = project.Id
                            };
                            UnitOfWork.Projects.MergeProjectSection(_section);
                            if (section.Images?.Count() > 0)
                            {
                                foreach (var image in section.Images)
                                {
                                    if (image.Updated)
                                    {
                                        UnitOfWork.Projects.MergeProjectSectionImage(new ProjectSectionImageVM
                                        {
                                            Id        = image.Id.GetValueOrDefault(),
                                            Image     = image.FileName,
                                            SectionId = _section.Id
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                result  = false;
                message = ex.ToString();
            }

            return(Json(new { result, message }));
        }