Beispiel #1
0
        public ActionResult Edit(FieldDefinitionPrimaryKey fieldDefinitionPrimaryKey, EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(fieldDefinitionPrimaryKey, viewModel));
            }
            var fieldDefinitionData = HttpRequestStorage.DatabaseEntities.FieldDefinitionDatas.GetFieldDefinitionDataByFieldDefinition(fieldDefinitionPrimaryKey);

            if (fieldDefinitionData == null)
            {
                fieldDefinitionData = new FieldDefinitionData(fieldDefinitionPrimaryKey.EntityObject);
                HttpRequestStorage.DatabaseEntities.AllFieldDefinitionDatas.Add(fieldDefinitionData);
            }

            var fieldDefinitionDefault = CurrentFirmaSession.IsSitkaAdministrator() ? HttpRequestStorage.DatabaseEntities.FieldDefinitionDefaults.GetFieldDefinitionDefaultByFieldDefinition(fieldDefinitionPrimaryKey) : null;

            if (CurrentFirmaSession.IsSitkaAdministrator() && fieldDefinitionDefault == null)
            {
                // need to insert a default
                fieldDefinitionDefault = new FieldDefinitionDefault(fieldDefinitionData.FieldDefinition, "<p><em>not defined</em></p>");
                HttpRequestStorage.DatabaseEntities.FieldDefinitionDefaults.Add(fieldDefinitionDefault);
            }

            viewModel.UpdateModel(fieldDefinitionData, fieldDefinitionDefault, HttpRequestStorage.DatabaseEntities);
            SetMessageForDisplay("Field Definition successfully saved.");
            return(RedirectToAction(new SitkaRoute <FieldDefinitionController>(x => x.Edit(fieldDefinitionData.FieldDefinition))));
        }
Beispiel #2
0
        public ActionResult Edit(FieldDefinitionPrimaryKey fieldDefinitionPrimaryKey, EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(fieldDefinitionPrimaryKey, viewModel));
            }
            var fieldDefinitionData = HttpRequestStorage.DatabaseEntities.FieldDefinitionDatas.GetFieldDefinitionDataByFieldDefinition(fieldDefinitionPrimaryKey);

            if (fieldDefinitionData == null)
            {
                fieldDefinitionData = new FieldDefinitionData(fieldDefinitionPrimaryKey.EntityObject);
                HttpRequestStorage.DatabaseEntities.FieldDefinitionDatas.Add(fieldDefinitionData);
            }

            viewModel.UpdateModel(fieldDefinitionData);
            SetMessageForDisplay("Field Definition successfully saved.");
            return(RedirectToAction(new SitkaRoute <FieldDefinitionController>(x => x.Edit(fieldDefinitionData.FieldDefinition))));
        }
Beispiel #3
0
        public void UpdateModel(FieldDefinitionData fieldDefinitionData, FieldDefinitionDefault fieldDefinitionDefault, DatabaseEntities databaseEntities)
        {
            // delete file resources for any images that are no longer referenced in the HTML
            var imagesToDelete = FieldDefinitionDataValue == null
                ? fieldDefinitionData.FieldDefinitionDataImages.ToList()
                : fieldDefinitionData.FieldDefinitionDataImages.Where(x => !FieldDefinitionDataValue.ToString().ContainsCaseInsensitive(x.FileResourceInfo.GetFileResourceGUIDAsString())).ToList();

            foreach (var image in imagesToDelete)
            {
                // will cascade delete the FieldDefinitionDataImage
                image.FileResourceInfo.DeleteFull(databaseEntities);
            }

            fieldDefinitionData.FieldDefinitionDataValueHtmlString = FieldDefinitionDataValue;
            fieldDefinitionData.FieldDefinitionLabel = string.IsNullOrWhiteSpace(FieldDefinitionLabel) ? null : FieldDefinitionLabel;
            if (fieldDefinitionDefault != null)
            {
                fieldDefinitionDefault.DefaultDefinitionHtmlString = FieldDefinitionDefault;
            }
        }
Beispiel #4
0
 public EditViewModel(FieldDefinitionData fieldDefinitionData, FieldDefinitionDefault fieldDefinitionDefault)
 {
     FieldDefinitionDataValue = fieldDefinitionData?.FieldDefinitionDataValueHtmlString;
     FieldDefinitionLabel     = fieldDefinitionData?.FieldDefinitionLabel;
     FieldDefinitionDefault   = fieldDefinitionDefault != null && !string.IsNullOrWhiteSpace(fieldDefinitionDefault.DefaultDefinition) ? fieldDefinitionDefault.DefaultDefinitionHtmlString : new HtmlString("<p><em>not defined</em></p>");
 }
Beispiel #5
0
 public void UpdateModel(FieldDefinitionData fieldDefinitionData)
 {
     fieldDefinitionData.FieldDefinitionDataValueHtmlString = FieldDefinitionDataValue;
     fieldDefinitionData.FieldDefinitionLabel = string.IsNullOrWhiteSpace(FieldDefinitionLabel) ? null : FieldDefinitionLabel;
 }
Beispiel #6
0
 public EditViewModel(FieldDefinitionData fieldDefinitionData)
 {
     FieldDefinitionDataValue = fieldDefinitionData?.FieldDefinitionDataValueHtmlString;
     FieldDefinitionLabel     = fieldDefinitionData?.FieldDefinitionLabel;
 }
Beispiel #7
0
        public CustomFieldDefinitionConflicts(ProjectFirmaModels.Models.FieldDefinition fieldDefinitionInConflict, FieldDefinitionData fieldDefinitionData)
        {
            DefaultInConflictFieldDefinitionID          = fieldDefinitionInConflict.FieldDefinitionID;
            DefaultInConflictFieldDefinitionDisplayName = fieldDefinitionInConflict.FieldDefinitionDisplayName;

            CustomFieldDefinitionDataID = fieldDefinitionData.FieldDefinitionDataID;
            CustomFieldDefinitionLabel  = fieldDefinitionData.FieldDefinitionLabel;

            DefaultFieldDefinitionID          = fieldDefinitionData.FieldDefinition.FieldDefinitionID;
            DefaultFieldDefinitionDisplayName = fieldDefinitionData.FieldDefinition.FieldDefinitionDisplayName;
        }