2018-06-29 19:52:40 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-12-03 15:28:55 +11:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2019-12-04 12:50:05 +11:00
|
|
|
|
using System.Linq;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
using Umbraco.Core.Models;
|
2018-07-19 19:32:07 +10:00
|
|
|
|
using Umbraco.Core.Models.Editors;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
using Umbraco.Core.Models.Validation;
|
2018-07-19 19:32:07 +10:00
|
|
|
|
using Umbraco.Web.WebApi.Filters;
|
2019-12-04 12:50:05 +11:00
|
|
|
|
using Umbraco.Core;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Models.ContentEditing
|
|
|
|
|
|
{
|
2018-07-19 19:32:07 +10:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public class MemberSave : ContentBaseSave<IMember>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "username", IsRequired = true)]
|
|
|
|
|
|
[RequiredForPersistence(AllowEmptyStrings = false, ErrorMessage = "Required")]
|
|
|
|
|
|
public string Username { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "email", IsRequired = true)]
|
|
|
|
|
|
[RequiredForPersistence(AllowEmptyStrings = false, ErrorMessage = "Required")]
|
2019-12-03 15:28:55 +11:00
|
|
|
|
[EmailAddress]
|
2018-06-29 19:52:40 +02:00
|
|
|
|
public string Email { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "password")]
|
|
|
|
|
|
public ChangingPasswordModel Password { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "memberGroups")]
|
|
|
|
|
|
public IEnumerable<string> Groups { get; set; }
|
|
|
|
|
|
|
2019-12-04 12:50:05 +11:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the value from the Comments property
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Comments => GetPropertyValue<string>(Constants.Conventions.Member.Comments);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the value from the IsLockedOut property
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsLockedOut => GetPropertyValue<bool>(Constants.Conventions.Member.IsLockedOut);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the value from the IsApproved property
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsApproved => GetPropertyValue<bool>(Constants.Conventions.Member.IsApproved);
|
|
|
|
|
|
|
|
|
|
|
|
private T GetPropertyValue<T>(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
var prop = Properties.FirstOrDefault(x => x.Alias == alias);
|
|
|
|
|
|
if (prop == null) return default;
|
|
|
|
|
|
var converted = prop.Value.TryConvertTo<T>();
|
|
|
|
|
|
return converted.ResultOr(default);
|
|
|
|
|
|
}
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|