Fixes up issues with editing the member profile and registering a member with our snippets including specifying a custom member type.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
@@ -18,6 +19,7 @@ namespace Umbraco.Web.Models
|
||||
/// <summary>
|
||||
/// A readonly member profile model
|
||||
/// </summary>
|
||||
[ModelBinder(typeof(ProfileModelBinder))]
|
||||
public class ProfileModel : PostRedirectModel
|
||||
{
|
||||
|
||||
@@ -96,7 +98,18 @@ namespace Umbraco.Web.Models
|
||||
/// <remarks>
|
||||
/// Adding items to this list on the front-end will not add properties to the member in the database.
|
||||
/// </remarks>
|
||||
public List<UmbracoProperty> MemberProperties { get; set; }
|
||||
|
||||
public List<UmbracoProperty> MemberProperties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A custom model binder for MVC because the default ctor performs a lookup!
|
||||
/// </summary>
|
||||
internal class ProfileModelBinder : DefaultModelBinder
|
||||
{
|
||||
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
|
||||
{
|
||||
return ProfileModel.CreateModel();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
namespace Umbraco.Web.Models
|
||||
{
|
||||
[ModelBinder(typeof(RegisterModelBinder))]
|
||||
public class RegisterModel : PostRedirectModel
|
||||
{
|
||||
/// <summary>
|
||||
@@ -58,6 +60,7 @@ namespace Umbraco.Web.Models
|
||||
/// <summary>
|
||||
/// The member type alias to use to register the member
|
||||
/// </summary>
|
||||
[Editable(false)]
|
||||
public string MemberTypeAlias { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -90,5 +93,16 @@ namespace Umbraco.Web.Models
|
||||
/// </summary>
|
||||
public bool LoginOnSuccess { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A custom model binder for MVC because the default ctor performs a lookup!
|
||||
/// </summary>
|
||||
internal class RegisterModelBinder : DefaultModelBinder
|
||||
{
|
||||
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
|
||||
{
|
||||
return RegisterModel.CreateModel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Xml;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
@@ -9,9 +11,30 @@ namespace Umbraco.Web.Models
|
||||
/// </summary>
|
||||
public class UmbracoProperty
|
||||
{
|
||||
[Editable(false)]
|
||||
public string Alias { get; set; }
|
||||
public object Value { get; set; }
|
||||
|
||||
//NOTE: This has to be a string currently, if it is an object it will bind as an array which we don't want.
|
||||
// If we want to have this as an 'object' with a true type on it, we have to create a custom model binder
|
||||
// for an UmbracoProperty and then bind with the correct type based on the property type for this alias. This
|
||||
// would be a bit long winded and perhaps unnecessary. The reason is because it is always posted as a string anyways
|
||||
// and when we set this value on the property object that gets sent to the database we do a TryConvertTo to the
|
||||
// real type anyways.
|
||||
|
||||
[DataType(DataType.Text)]
|
||||
public string Value { get; set; }
|
||||
|
||||
[ReadOnly(true)]
|
||||
public string Name { get; set; }
|
||||
|
||||
//TODO: Perhaps one day we'll ship with our own EditorTempates but for now developers can just render their own inside the view
|
||||
|
||||
///// <summary>
|
||||
///// This can dynamically be set to a custom template name to change
|
||||
///// the editor type for this property
|
||||
///// </summary>
|
||||
//[ReadOnly(true)]
|
||||
//public string EditorTemplate { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user