Rebel.Cms.Web.Editors.DataTypeEditorController.EditForm C# (CSharp) Method

EditForm() private method

private EditForm ( HiveId id ) : System.Web.Mvc.ActionResult
id HiveId
return System.Web.Mvc.ActionResult
        public ActionResult EditForm(HiveId? id)
        {
            if (id.IsNullValueOrEmpty()) return HttpNotFound();
            
            using (var uow = BackOfficeRequestContext.Application.Hive.OpenWriter<IContentStore>())
            {
                var dataTypeEntity = uow.Repositories.Schemas.Get<AttributeType>(id.Value);
                if (dataTypeEntity == null)
                    throw new ArgumentException(string.Format("No AttributeType found for id: {0} on action EditForm", id));

                var dataTypeViewModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map<AttributeType, DataTypeEditorModel>(dataTypeEntity);

                return ProcessSubmit(dataTypeViewModel, dataTypeEntity);
            }           
        }

Usage Example

        public void DataTypeEditorControllerTests_DataType_Saved()
        {
            //Arrange

            //create data type in persistence layer
            var propEditor = new MandatoryPropertyEditor();
            var dataTypeEntity = HiveModelCreationHelper.CreateAttributeType("test", "Test", "");
            dataTypeEntity.RenderTypeProvider = propEditor.Id.ToString();
            RebelApplicationContext.AddPersistenceData(dataTypeEntity);

            var controller = new DataTypeEditorController(GetBackOfficeRequestContext());
            controller.InjectDependencies(new Dictionary<string, string>(), new Dictionary<string, string>
                                              {
                                                  {"Name", "Hello World"},
                                                   {"PropertyEditorId", "5A379AF0-0256-4BE9-9D01-F149603DB257"},
                                                   { "submit.Save", "Save"} //set save flag
                                              }, GetBackOfficeRequestContext(), false);

            //Act

            var result = controller.EditForm(dataTypeEntity.Id);

            //Assert

            Assert.IsTrue(result is RedirectToRouteResult);

            using (var uow = RebelApplicationContext.Hive.OpenReader<IContentStore>())
            {
                var latestEntity = uow.Repositories.Schemas.Get<AttributeType>(dataTypeEntity.Id);
                Assert.IsTrue(dataTypeEntity.UtcModified < latestEntity.UtcModified);                
            }
        }
All Usage Examples Of Rebel.Cms.Web.Editors.DataTypeEditorController::EditForm