Beispiel #1
0
        internal void UpdateTemplateControls(TemplateControlCollection templateControls)
        {
            if (templateControls.Count == 0)
            {
                return;
            }

            DataAccess.TemplateControlRepository.UpdateTemplateControls(templateControls.CreateDataObjectCollection());
        }
Beispiel #2
0
        internal void AddTemplateControls(int templateId, TemplateControlCollection templateControls)
        {
            if (templateControls.Count == 0)
            {
                return;
            }

            DataAccess.TemplateControlRepository.AddTemplateControls(templateId, templateControls.CreateDataObjectCollection());
        }
Beispiel #3
0
        internal static TemplateControlCollection CreateFromDataObjectCollection(Data.TemplateControlCollection templateCollection)
        {
            var list = new TemplateControlCollection();

            foreach (var templateControl in templateCollection)
            {
                list.Add(TemplateControl.CreateFromDataObject(templateControl));
            }

            return(list);
        }
Beispiel #4
0
        internal void Save(int templateId)
        {
            var newControls      = new TemplateControlCollection();
            var existingControls = new TemplateControlCollection();

            newControls.AddRange(this.FindAll(templateControl => templateControl.Id <= 0));
            existingControls.AddRange(this.FindAll(templateControl => templateControl.Id > 0));

            var existingControlIds = from tc in existingControls
                                     select tc.Id;

            TemplateManager.TemplateControlService.RemoveTemplateControlsNotInCollection(templateId, existingControlIds);
            TemplateManager.TemplateControlService.AddTemplateControls(templateId, newControls);
            TemplateManager.TemplateControlService.UpdateTemplateControls(existingControls);
        }
Beispiel #5
0
        internal TemplateControlCollection GetControls(int templateId, int documentId = 0, int documentTypeId = 0)
        {
            TemplateControlCollection result = null;

            if (documentId > 0)
            {
                result = TemplateControlCollection.CreateFromDataObjectCollection(DataAccess.TemplateControlRepository.GetControls(templateId, documentId, documentTypeId));
            }
            else
            {
                result = TemplateControlCollection.CreateFromDataObjectCollection(DataAccess.TemplateControlRepository.GetControls(templateId));
            }

            return(result);
        }
Beispiel #6
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);
        }