Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 915 Bytes

README.md

File metadata and controls

40 lines (34 loc) · 915 Bytes

RestToolkit

ASP.NET Core REST Toolkit - for quickly creating clean REST APIs in ASP.NET Core

Example AdditionalUserInfo code

public class ExampleAccountController 
	: AccountController<IExampleAdditionalUserInfo, ExampleUser, ExampleAdditionalUserInfo>
{
	//ctor...
}

public interface IExampleAdditionalUserInfo : IToolkitAdditionalUserInfo<ExampleUser>
{
    string UserName { get; set; }
}

[DataContract]
public class ExampleUser : ToolkitUser, IExampleAdditionalUserInfo
{
    public void Map(ref ExampleUser user)
    {
        throw new System.NotImplementedException();
    }
}

public class ExampleAdditionalUserInfo : IExampleAdditionalUserInfo
{
    [Required]
    [MinLength(3), MaxLength(10)]
    [RegularExpression("[A-Za-z0-9]+")]
    [PersonalData]
    public string UserName { get; set; }

    public void Map(ref ExampleUser user)
    {
        user.UserName = UserName;
    }
}