예제 #1
0
        public ActionResult New(EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(viewModel));
            }

            var fileResourceInfo        = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(viewModel.FileResourceData, CurrentFirmaSession);
            var reportTemplateModelType = ReportTemplateModelType.All.FirstOrDefault(x => x.ReportTemplateModelTypeID == viewModel.ReportTemplateModelTypeID);
            var reportTemplateModel     = ReportTemplateModel.All.FirstOrDefault(x => x.ReportTemplateModelID == viewModel.ReportTemplateModelID);
            var reportTemplate          = ReportTemplate.CreateNewBlank(fileResourceInfo, reportTemplateModelType, reportTemplateModel);

            ReportTemplateGenerator.ValidateReportTemplate(reportTemplate, out var reportIsValid, out var errorMessage, out var sourceCode);

            if (reportIsValid)
            {
                viewModel.UpdateModel(reportTemplate, fileResourceInfo, CurrentFirmaSession, HttpRequestStorage.DatabaseEntities);
                SitkaDbContext.SaveChanges();
                SetMessageForDisplay($"Report Template \"{reportTemplate.DisplayName}\" successfully created.");
            }
            else
            {
                SetErrorForDisplay($"There was an error with this template: {errorMessage}");
                if (!sourceCode.IsEmpty())
                {
                    SetErrorWithScrollablePreForDisplay($"{sourceCode}");
                }
            }

            return(new ModalDialogFormJsonResult());
        }
예제 #2
0
        public void UpdateModel(TenantAttribute tenantAttribute, FirmaSession currentFirmaSession, DatabaseEntities databaseEntities)
        {
            var attributeTenantStyleSheetFileResource = tenantAttribute.TenantStyleSheetFileResourceInfo;

            tenantAttribute.TenantStyleSheetFileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(TenantStyleSheetFileResourceData, currentFirmaSession);
            attributeTenantStyleSheetFileResource?.FileResourceData.Delete(databaseEntities);
            attributeTenantStyleSheetFileResource?.Delete(databaseEntities);
        }
예제 #3
0
        public ContentResult CkEditorUploadFileResourceForOrganizationDescription(OrganizationPrimaryKey organizationPrimaryKey, CkEditorImageUploadViewModel viewModel)
        {
            var fileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(viewModel.upload, CurrentFirmaSession);
            var organization     = organizationPrimaryKey.EntityObject;
            var ppImage          = new OrganizationImage(organization, fileResourceInfo);

            HttpRequestStorage.DatabaseEntities.AllOrganizationImages.Add(ppImage);
            return(Content(viewModel.GetCkEditorJavascriptContentToReturn(fileResourceInfo)));
        }
예제 #4
0
        public ContentResult CkEditorUploadFileResourceForGeospatialAreaDescription(GeospatialAreaPrimaryKey geospatialAreaPrimaryKey, CkEditorImageUploadViewModel viewModel)
        {
            var fileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(viewModel.upload, CurrentFirmaSession);
            var geospatialArea   = geospatialAreaPrimaryKey.EntityObject;
            var ppImage          = new GeospatialAreaImage(geospatialArea, fileResourceInfo);

            HttpRequestStorage.DatabaseEntities.AllGeospatialAreaImages.Add(ppImage);
            return(Content(viewModel.GetCkEditorJavascriptContentToReturn(fileResourceInfo)));
        }
예제 #5
0
        public ContentResult CkEditorUploadFileResourceForCustomPage(CustomPagePrimaryKey customPagePrimaryKey, CkEditorImageUploadViewModel viewModel)
        {
            var fileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(viewModel.upload, CurrentFirmaSession);
            var customPage       = customPagePrimaryKey.EntityObject;
            var ppImage          = new CustomPageImage(customPage, fileResourceInfo);

            HttpRequestStorage.DatabaseEntities.AllCustomPageImages.Add(ppImage);
            return(Content(viewModel.GetCkEditorJavascriptContentToReturn(fileResourceInfo)));
        }
예제 #6
0
        public ContentResult CkEditorUploadFileResourceForFieldDefinition(FieldDefinitionPrimaryKey fieldDefinitionPrimaryKey, CkEditorImageUploadViewModel viewModel)
        {
            var fileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(viewModel.upload, CurrentFirmaSession);
            var fieldDefinition  = fieldDefinitionPrimaryKey.EntityObject;
            var image            = new FieldDefinitionDataImage(fieldDefinition.GetFieldDefinitionData().FieldDefinitionDataID, fileResourceInfo.FileResourceInfoID);

            HttpRequestStorage.DatabaseEntities.AllFieldDefinitionDataImages.Add(image);
            return(Content(viewModel.GetCkEditorJavascriptContentToReturn(fileResourceInfo)));
        }
예제 #7
0
 public override void UpdateModel(ProjectFirmaModels.Models.ProjectImage projectImage, FirmaSession currentFirmaSession)
 {
     base.UpdateModel(projectImage, currentFirmaSession);
     projectImage.FileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(FileResourceData, currentFirmaSession);
     if (projectImage.Project.ProjectImages.All(x => x.ProjectImageID == projectImage.ProjectImageID))
     {
         projectImage.IsKeyPhoto = true;
     }
 }
예제 #8
0
        public void UpdateModel(ProjectFirmaModels.Models.Classification classification, FirmaSession currentFirmaSession, DatabaseEntities databaseEntities)
        {
            classification.DisplayName = DisplayName;
            classification.ClassificationDescription = ClassificationDescription;
            classification.GoalStatement             = GoalStatement;

            if (DeleteCurrentKeyImage)
            {
                var oldKeyImageFileResourceInfo = classification.KeyImageFileResourceInfo;
                classification.KeyImageFileResourceInfo   = null;
                classification.KeyImageFileResourceInfoID = null;
                oldKeyImageFileResourceInfo.FileResourceData.Delete(databaseEntities);
                oldKeyImageFileResourceInfo.Delete(databaseEntities);
            }

            if (KeyImageFileResourceData != null)
            {
                classification.KeyImageFileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(KeyImageFileResourceData, currentFirmaSession);
            }

            classification.ThemeColor = ThemeColor;
        }
예제 #9
0
        public void UpdateModel(ProjectFirmaModels.Models.Organization organization, FirmaSession currentFirmaSession, DatabaseEntities databaseEntities)
        {
            organization.OrganizationName      = OrganizationName;
            organization.OrganizationShortName = OrganizationShortName;
            organization.OrganizationTypeID    = OrganizationTypeID.Value;
            organization.IsActive = IsActive;
            organization.PrimaryContactPersonID = PrimaryContactPersonID;
            organization.OrganizationUrl        = OrganizationUrl;
            if (LogoFileResourceData != null)
            {
                var oldLogoFileResourceInfo = organization.LogoFileResourceInfo;
                organization.LogoFileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(LogoFileResourceData, currentFirmaSession);
                oldLogoFileResourceInfo?.FileResourceData.Delete(databaseEntities);
                oldLogoFileResourceInfo?.Delete(databaseEntities);
            }

            var isSitkaAdmin = new SitkaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession);

            if (isSitkaAdmin)
            {
                organization.KeystoneOrganizationGuid = KeystoneOrganizationGuid;
            }
        }
예제 #10
0
 public override void UpdateModel(DocumentLibraryDocument documentLibraryDocument, FirmaSession currentFirmaSession, ICollection <DocumentLibraryDocumentRole> allDocumentLibraryDocumentRoles)
 {
     documentLibraryDocument.FileResourceInfo  = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(FileResourceData, currentFirmaSession);
     documentLibraryDocument.DocumentLibraryID = DocumentLibraryID;
     base.UpdateModel(documentLibraryDocument, currentFirmaSession, allDocumentLibraryDocumentRoles);
 }
예제 #11
0
 public override void UpdateModel(ProjectFirmaModels.Models.FirmaHomePageImage firmaHomePageImage, FirmaSession currentFirmaSession)
 {
     base.UpdateModel(firmaHomePageImage, currentFirmaSession);
     firmaHomePageImage.FileResourceInfo = FileResourceModelExtensions.CreateNewFromHttpPostedFileAndSave(FileResourceData, currentFirmaSession);
 }