Skip to content
This repository was archived by the owner on Dec 14, 2017. It is now read-only.

Commit 7071db0

Browse files
committedAug 5, 2014
custom user account sample
1 parent 87eb9f2 commit 7071db0

File tree

6 files changed

+239
-0
lines changed

6 files changed

+239
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.30501.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomUserAccount", "CustomUserAccount\CustomUserAccount.csproj", "{5AA53894-318A-47AB-A20F-126F4B539EC2}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{5AA53894-318A-47AB-A20F-126F4B539EC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{5AA53894-318A-47AB-A20F-126F4B539EC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{5AA53894-318A-47AB-A20F-126F4B539EC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{5AA53894-318A-47AB-A20F-126F4B539EC2}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
5+
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
6+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
7+
8+
<connectionStrings>
9+
<add name="CustomDatabase" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=CustomDatabaseMembershipReboot;Integrated Security=True" providerName="System.Data.SqlClient" />
10+
</connectionStrings>
11+
12+
<startup>
13+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
14+
</startup>
15+
<entityFramework>
16+
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
17+
<parameters>
18+
<parameter value="v12.0" />
19+
</parameters>
20+
</defaultConnectionFactory>
21+
<providers>
22+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
23+
</providers>
24+
</entityFramework>
25+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{5AA53894-318A-47AB-A20F-126F4B539EC2}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CustomUserAccount</RootNamespace>
11+
<AssemblyName>CustomUserAccount</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="BrockAllen.MembershipReboot, Version=7.4.1.0, Culture=neutral, processorArchitecture=MSIL">
36+
<SpecificVersion>False</SpecificVersion>
37+
<HintPath>..\packages\BrockAllen.MembershipReboot.7.4.1\lib\net45\BrockAllen.MembershipReboot.dll</HintPath>
38+
</Reference>
39+
<Reference Include="BrockAllen.MembershipReboot.Ef, Version=7.1.1.0, Culture=neutral, processorArchitecture=MSIL">
40+
<SpecificVersion>False</SpecificVersion>
41+
<HintPath>..\packages\BrockAllen.MembershipReboot.Ef.7.1.1\lib\net45\BrockAllen.MembershipReboot.Ef.dll</HintPath>
42+
</Reference>
43+
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
44+
<SpecificVersion>False</SpecificVersion>
45+
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
46+
</Reference>
47+
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
48+
<SpecificVersion>False</SpecificVersion>
49+
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
50+
</Reference>
51+
<Reference Include="System" />
52+
<Reference Include="System.ComponentModel.DataAnnotations" />
53+
<Reference Include="System.Core" />
54+
<Reference Include="System.IdentityModel" />
55+
<Reference Include="System.Xml.Linq" />
56+
<Reference Include="System.Data.DataSetExtensions" />
57+
<Reference Include="Microsoft.CSharp" />
58+
<Reference Include="System.Data" />
59+
<Reference Include="System.Xml" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="Program.cs" />
63+
<Compile Include="Properties\AssemblyInfo.cs" />
64+
</ItemGroup>
65+
<ItemGroup>
66+
<None Include="App.config" />
67+
<None Include="packages.config" />
68+
</ItemGroup>
69+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
70+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
71+
Other similar extension points exist, see Microsoft.Common.targets.
72+
<Target Name="BeforeBuild">
73+
</Target>
74+
<Target Name="AfterBuild">
75+
</Target>
76+
-->
77+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using BrockAllen.MembershipReboot;
2+
using BrockAllen.MembershipReboot.Relational;
3+
using BrockAllen.MembershipReboot.Ef;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Data.Entity;
10+
11+
namespace CustomUserAccount
12+
{
13+
public class CustomUserAccount : RelationalUserAccount
14+
{
15+
// make sure the custom properties are all virtual
16+
public virtual int Age { get; set; }
17+
public virtual string FirstName { get; set; }
18+
public virtual string LastName { get; set; }
19+
}
20+
21+
public class CustomDb : MembershipRebootDbContext<CustomUserAccount>
22+
{
23+
public CustomDb()
24+
: base("CustomDatabase")
25+
{
26+
}
27+
}
28+
29+
public class CustomUserAccountRepository : DbContextUserAccountRepository<CustomDb, CustomUserAccount>
30+
{
31+
}
32+
33+
class Program
34+
{
35+
static MembershipRebootConfiguration<CustomUserAccount> config;
36+
static Program()
37+
{
38+
config = new MembershipRebootConfiguration<CustomUserAccount>();
39+
config.PasswordHashingIterationCount = 50000;
40+
config.MultiTenant = false;
41+
// etc...
42+
}
43+
44+
static UserAccountService<CustomUserAccount> GetUserAccountService()
45+
{
46+
var repo = new CustomUserAccountRepository();
47+
UserAccountService<CustomUserAccount> svc = new UserAccountService<CustomUserAccount>(config, repo);
48+
return svc;
49+
}
50+
51+
static void Main(string[] args)
52+
{
53+
var svc = GetUserAccountService();
54+
var account = svc.GetByUsername("brock");
55+
if (account == null)
56+
{
57+
Console.WriteLine("Creating new account");
58+
account = svc.CreateAccount("brock", "pass123", "brockallen@gmail.com");
59+
60+
account.FirstName = "Brock";
61+
account.LastName = "Allen";
62+
account.Age = 21;
63+
svc.Update(account);
64+
}
65+
else
66+
{
67+
Console.WriteLine("Updating existing account");
68+
account.Age++;
69+
svc.Update(account);
70+
}
71+
}
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CustomUserAccount")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CustomUserAccount")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("abecbece-e04f-448d-947a-4a553cd58bad")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="BrockAllen.MembershipReboot" version="7.4.1" targetFramework="net45" />
4+
<package id="BrockAllen.MembershipReboot.Ef" version="7.1.1" targetFramework="net45" />
5+
<package id="EntityFramework" version="6.1.1" targetFramework="net45" />
6+
</packages>

0 commit comments

Comments
 (0)
This repository has been archived.