internal void AddResolutions(int templateId, ResolutionCollection resolutions)
        {
            if (resolutions.Count == 0)
            {
                return;
            }

            DataAccess.ResolutionRepository.AddResolutions(templateId, resolutions.CreateDataObjectCollection());
        }
        internal void UpdateResolutions(ResolutionCollection resolutions)
        {
            if (resolutions.Count == 0)
            {
                return;
            }

            DataAccess.ResolutionRepository.UpdateResolutions(resolutions.CreateDataObjectCollection());
        }
        internal static ResolutionCollection CreateFromDataObjectCollection(Data.ResolutionCollection resolutions)
        {
            var list = new ResolutionCollection();

            foreach (var resolution in resolutions)
            {
                list.Add(Resolution.CreateFromDataObject(resolution));
            }

            return(list);
        }
        internal void Save(int templateId)
        {
            var newResolutions      = new ResolutionCollection();
            var existingResolutions = new ResolutionCollection();

            newResolutions.AddRange(this.FindAll(resolution => resolution.Id == 0));
            existingResolutions.AddRange(this.FindAll(resolution => resolution.Id > 0));

            var existingResolutionIds = from r in existingResolutions
                                        select r.Id;


            TemplateManager.ResolutionService.RemoveResolutionsNotInCollection(templateId, existingResolutionIds);

            //Update must be run first since it clears existing resolution values
            TemplateManager.ResolutionService.UpdateResolutions(existingResolutions);
            TemplateManager.ResolutionService.AddResolutions(templateId, newResolutions);
            TemplateManager.TemplateControlService.ResetTemplateControlCreationGUIDs(templateId);
        }
Ejemplo n.º 5
0
        public bool Save(int userId, bool simpleSave = true)
        {
            if (this.Id > 0)
            {
                TemplateManager.TemplateService.UpdateTemplate(this);
            }
            else
            {
                this.CreatedByUserId = userId;
                TemplateManager.TemplateService.AddTemplate(this);
            }

            if (!simpleSave)
            {
                this.TemplateControls.Save(this.Id);
                this.Resolutions.Save(this.Id);
                this.templateControls = null;                   //flag as dirty
                this.resolutions      = null;                   //flag as dirty
            }

            return(true);
        }
 internal ResolutionCollection GetResolutions(int templateId)
 {
     return(ResolutionCollection.CreateFromDataObjectCollection(DataAccess.ResolutionRepository.GetResolutions(templateId)));
 }