Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/08/10 09:35:24 (14 years ago)
Author:
jwolfing
Message:

#1196 Changed DataTransfer Structure factoring in abstract class. Added new TestClient2 only to test the new method. All other comment lines, are lines they should be changed to the new structure.

Location:
branches/UserManagement
Files:
5 added
15 edited

Legend:

Unmodified
Added
Removed
  • branches/UserManagement/HeuristicLab.Authentication.sln

    r4584 r4740  
    1616EndProject
    1717Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.Authentication.TestClient", "HeuristicLab.Services.Authentication.TestClient\HeuristicLab.Services.Authentication.TestClient.csproj", "{C31A4169-0BD0-4969-A85B-49AA3B679047}"
     18EndProject
     19Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.Authentication.TestClient2", "HeuristicLab.Services.Authentication.TestClient2\HeuristicLab.Services.Authentication.TestClient2.csproj", "{EB40C828-D545-4DFE-9CE6-108FB03C6912}"
    1820EndProject
    1921Global
     
    7072    {C31A4169-0BD0-4969-A85B-49AA3B679047}.Release|x86.ActiveCfg = Release|x86
    7173    {C31A4169-0BD0-4969-A85B-49AA3B679047}.Release|x86.Build.0 = Release|x86
     74    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Debug|Any CPU.ActiveCfg = Debug|x86
     75    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
     76    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Debug|Mixed Platforms.Build.0 = Debug|x86
     77    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Debug|x86.ActiveCfg = Debug|x86
     78    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Debug|x86.Build.0 = Debug|x86
     79    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Release|Any CPU.ActiveCfg = Release|x86
     80    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Release|Mixed Platforms.ActiveCfg = Release|x86
     81    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Release|Mixed Platforms.Build.0 = Release|x86
     82    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Release|x86.ActiveCfg = Release|x86
     83    {EB40C828-D545-4DFE-9CE6-108FB03C6912}.Release|x86.Build.0 = Release|x86
    7284  EndGlobalSection
    7385  GlobalSection(SolutionProperties) = preSolution
  • branches/UserManagement/HeuristicLab.Services.Authentication.DataAccess/HeuristicLab.Services.Authentication.DataAccess.csproj

    r4647 r4740  
    5252      <DependentUpon>Settings.settings</DependentUpon>
    5353    </Compile>
     54    <Compile Include="UserManagement.cs">
     55      <DependentUpon>UserManagement.dbml</DependentUpon>
     56    </Compile>
    5457    <Compile Include="UserManagement.designer.cs">
    5558      <AutoGen>True</AutoGen>
    5659      <DesignTime>True</DesignTime>
    5760      <DependentUpon>UserManagement.dbml</DependentUpon>
    58     </Compile>
    59     <Compile Include="_HeuristicLab_AuthenticationDataSet.Designer.cs">
    60       <AutoGen>True</AutoGen>
    61       <DesignTime>True</DesignTime>
    62       <DependentUpon>_HeuristicLab_AuthenticationDataSet.xsd</DependentUpon>
    6361    </Compile>
    6462  </ItemGroup>
     
    7371      <LastGenOutput>UserManagement.designer.cs</LastGenOutput>
    7472      <SubType>Designer</SubType>
    75     </None>
    76     <None Include="_HeuristicLab_AuthenticationDataSet.xsc">
    77       <DependentUpon>_HeuristicLab_AuthenticationDataSet.xsd</DependentUpon>
    78     </None>
    79     <None Include="_HeuristicLab_AuthenticationDataSet.xsd">
    80       <Generator>MSDataSetGenerator</Generator>
    81       <LastGenOutput>_HeuristicLab_AuthenticationDataSet.Designer.cs</LastGenOutput>
    82       <SubType>Designer</SubType>
    83     </None>
    84     <None Include="_HeuristicLab_AuthenticationDataSet.xss">
    85       <DependentUpon>_HeuristicLab_AuthenticationDataSet.xsd</DependentUpon>
    8673    </None>
    8774  </ItemGroup>
  • branches/UserManagement/HeuristicLab.Services.Authentication.DataTransfer/Application.cs

    r4589 r4740  
    77namespace HeuristicLab.Services.Authentication.DataTransfer
    88{
    9     [DataContract]
    10     public class Application
    11     {
    12         [DataMember]
    13         public Guid ApplicationId { get; set; }
    14         [DataMember]
    15         public string ApplicationName { get; set; }
    16         [DataMember]
    17         public string LoweredApplicationName { get; set; }
    18         [DataMember]
    19         public string Description { get; set; }
    20     }
     9  [DataContract]
     10  public class Application : NamedAuthItem {
     11    //[DataMember]
     12    //public string LoweredApplicationName { get; set; }
     13    [DataMember]
     14    public string Description { get; set; }
     15  }
     16    //[DataContract]
     17    //public class Application : NamedAuthItem {
     18    //    [DataMember]
     19    //    public Guid ApplicationId { get; set; }
     20    //    [DataMember]
     21    //    public string ApplicationName { get; set; }
     22    //    [DataMember]
     23    //    public string LoweredApplicationName { get; set; }
     24    //    [DataMember]
     25    //    public string Description { get; set; }
     26    //}
    2127}
  • branches/UserManagement/HeuristicLab.Services.Authentication.DataTransfer/HeuristicLab.Services.Authentication.DataTransfer.csproj

    r4584 r4740  
    4343  <ItemGroup>
    4444    <Compile Include="Application.cs" />
     45    <Compile Include="AuthItem.cs" />
     46    <Compile Include="NamedAuthItem.cs" />
    4547    <Compile Include="Role.cs" />
    46     <Compile Include="Membership.cs" />
    4748    <Compile Include="User.cs" />
    4849    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/UserManagement/HeuristicLab.Services.Authentication.DataTransfer/Role.cs

    r4590 r4740  
    77namespace HeuristicLab.Services.Authentication.DataTransfer
    88{
    9     [DataContract]
    10     public class Role
    11     {
    12         [DataMember]
    13         public Guid ApplicationId { get; set; }
    14         [DataMember]
    15         public Guid RoleId { get; set; }
    16         [DataMember]
    17         public string RoleName { get; set; }
    18         [DataMember]
    19         public string LoweredRoleName { get; set; }
    20         [DataMember]
    21         public string Description { get; set; }
    22     }
     9  [DataContract]
     10  public class Role : NamedAuthItem {
     11    [DataMember]
     12    public Guid ApplicationId { get; set; }
     13    //[DataMember]
     14    //public string LoweredRoleName { get; set; }
     15    [DataMember]
     16    public string Desciption { get; set; }
     17  }
     18    //[DataContract]
     19    //public class Role
     20    //{
     21    //    [DataMember]
     22    //    public Guid ApplicationId { get; set; }
     23    //    [DataMember]
     24    //    public Guid RoleId { get; set; }
     25    //    [DataMember]
     26    //    public string RoleName { get; set; }
     27    //    [DataMember]
     28    //    public string LoweredRoleName { get; set; }
     29    //    [DataMember]
     30    //    public string Description { get; set; }
     31    //}
    2332}
  • branches/UserManagement/HeuristicLab.Services.Authentication.DataTransfer/User.cs

    r4726 r4740  
    77namespace HeuristicLab.Services.Authentication.DataTransfer
    88{
    9     [DataContract]
    10     public class User
    11     {
     9  [DataContract]
     10  public class User : NamedAuthItem {
     11    // Member of Membership
     12    [DataMember]
     13    public Guid ApplicationId { get; set; } // Membership
     14    [DataMember]
     15    public string Password { get; set; } // Membership
     16    //[DataMember]
     17    //public string PasswordFormat { get; set; } // Membership
     18    [DataMember]
     19    public string PasswordSalt { get; set; } // Membership
     20    //[DataMember]
     21    //public string MobilePIN { get; set; } // Membership
     22    [DataMember]
     23    public string Email { get; set; } // Membership
     24    //[DataMember]
     25    //public string LoweredEmail { get; set; } // Membership
     26    //[DataMember]
     27    //public string PasswordQuestion { get; set; } // Membership
     28    //[DataMember]
     29    //public string PasswordAnswer { get; set; } // Membership
     30    [DataMember]
     31    public bool IsApproved { get; set; } // Membership
     32    [DataMember]
     33    public bool IsLookedOut { get; set; } // Membership
     34    [DataMember]
     35    public DateTime CreateDate { get; set; } // Membership
     36    [DataMember]
     37    public DateTime LastLoginDate { get; set; } // Membership
     38    [DataMember]
     39    public DateTime LastPasswordChangeDate { get; set; } // Memership
     40    [DataMember]
     41    public DateTime LastLockoutDate { get; set; } // Membership
     42    //[DataMember]
     43    //public int FailedPasswordAttemptCount { get; set; } // Membership
     44    //[DataMember]
     45    //public DateTime FailedPasswordAttemptWindowStart { get; set; } // Membership
     46    //[DataMember]
     47    //public int FailedPasswordAnswerAttemptCount { get; set; } // Membership
     48    //[DataMember]
     49    //public DateTime FailedPasswordAnswerAttemptWindowStart { get; set; } // Membership
     50    [DataMember]
     51    public string Comment { get; set; } // Membership
     52    // Members of User
     53    //[DataMember]
     54    //public string LoweredUserName { get; set; } // User
     55    //[DataMember]
     56    //public string MobileAlias { get; set; } // User
     57    //[DataMember]
     58    //public bool IsAnonymous { get; set; } // User
     59    [DataMember]
     60    public DateTime LastActivityDate { get; set; } // User
    1261
    13         public User()
    14         {
    15             Membership = new Membership();
    16         }
     62  }
    1763
    18         [DataMember]
    19         public Membership Membership { get; set; }
    2064
    21         [DataMember]
    22         public string Email
    23         {
    24             get { return Membership.Email; }
    25             set { Membership.Email = value; }
    26         }
    27         [DataMember]
    28         public string Password
    29         {
    30             get { return Membership.Password; }
    31             set { Membership.Password = value; }
    32         }
    33         [DataMember]
    34         public string PasswordQuestion
    35         {
    36             get { return Membership.PasswordQuestion; }
    37             set { this.Membership.PasswordQuestion = value; }
    38         }
    39         [DataMember]
    40         public Guid ApplicationId { get; set; }
    41         [DataMember]
    42         public Guid UserId { get; set; }
    43         [DataMember]
    44         public string UserName { get; set; }
    45         [DataMember]
    46         public string LoweredUserName { get; set; }
    47         [DataMember]
    48         public string MobileAlias { get; set; }
    49         [DataMember]
    50         public bool IsAnonymous { get; set; }
    51         [DataMember]
    52         public DateTime LastActivityDate { get; set; }
    5365
    54     }
     66    //[DataContract]
     67    //public class User
     68    //{
     69
     70    //    public User()
     71    //    {
     72    //        Membership = new Membership();
     73    //    }
     74
     75    //    [DataMember]
     76    //    public Membership Membership { get; set; }
     77
     78    //    [DataMember]
     79    //    public string Email
     80    //    {
     81    //        get { return Membership.Email; }
     82    //        set { Membership.Email = value; }
     83    //    }
     84    //    [DataMember]
     85    //    public string Password
     86    //    {
     87    //        get { return Membership.Password; }
     88    //        set { Membership.Password = value; }
     89    //    }
     90    //    [DataMember]
     91    //    public string PasswordQuestion
     92    //    {
     93    //        get { return Membership.PasswordQuestion; }
     94    //        set { this.Membership.PasswordQuestion = value; }
     95    //    }
     96    //    [DataMember]
     97    //    public Guid ApplicationId { get; set; }
     98    //    [DataMember]
     99    //    public Guid UserId { get; set; }
     100    //    [DataMember]
     101    //    public string UserName { get; set; }
     102    //    [DataMember]
     103    //    public string LoweredUserName { get; set; }
     104    //    [DataMember]
     105    //    public string MobileAlias { get; set; }
     106    //    [DataMember]
     107    //    public bool IsAnonymous { get; set; }
     108    //    [DataMember]
     109    //    public DateTime LastActivityDate { get; set; }
     110
     111    //}
    55112}
  • branches/UserManagement/HeuristicLab.Services.Authentication.TestClient

    • Property svn:ignore set to
      bin
      obj
  • branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/HeuristicLab.Services.Authentication.TestClient.csproj

    r4726 r4740  
    7575  </ItemGroup>
    7676  <ItemGroup>
    77     <None Include="Properties\DataSources\HeuristicLab.Services.Authentication.DataTransfer.Application.datasource" />
     77    <None Include="Properties\DataSources\HeuristicLab.Services.Authentication.DataTransfer.Membership.datasource" />
    7878    <None Include="Properties\DataSources\HeuristicLab.Services.Authentication.DataTransfer.Role.datasource" />
    7979    <None Include="Properties\DataSources\HeuristicLab.Services.Authentication.DataTransfer.User.datasource" />
  • branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/TestClient.cs

    r4726 r4740  
    2020            {
    2121
     22
    2223                //Console.WriteLine("Insert new application");
    2324                //Application app1 = new Application() { ApplicationName="SPR Application", Description="SPR Application"};
  • branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/UserManagement.Designer.cs

    r4726 r4740  
    4747            this.btnNewUser = new System.Windows.Forms.Button();
    4848            this.dgvUsers = new System.Windows.Forms.DataGridView();
     49            this.userNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
     50            this.isAnonymousDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     51            this.Membership = new System.Windows.Forms.DataGridViewTextBoxColumn();
    4952            this.bsUsers = new System.Windows.Forms.BindingSource(this.components);
    5053            this.tcUser = new System.Windows.Forms.TabControl();
     
    8285            this.userNameDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
    8386            this.bsUserRoles = new System.Windows.Forms.BindingSource(this.components);
    84             this.Membership = new System.Windows.Forms.DataGridViewTextBoxColumn();
    85             this.isAnonymousDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
    86             this.userNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
    8787            roleNameLabel = new System.Windows.Forms.Label();
    8888            descriptionLabel = new System.Windows.Forms.Label();
     
    223223            //
    224224            this.bsApplications.DataSource = typeof(HeuristicLab.Services.Authentication.DataTransfer.Application);
     225            this.bsApplications.CurrentChanged += new System.EventHandler(this.bsApplications_CurrentChanged);
    225226            //
    226227            // label1
     
    297298            this.dgvUsers.TabIndex = 1;
    298299            this.dgvUsers.SelectionChanged += new System.EventHandler(this.dgvUsers_SelectionChanged);
     300            //
     301            // userNameDataGridViewTextBoxColumn
     302            //
     303            this.userNameDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     304            this.userNameDataGridViewTextBoxColumn.DataPropertyName = "UserName";
     305            this.userNameDataGridViewTextBoxColumn.HeaderText = "UserName";
     306            this.userNameDataGridViewTextBoxColumn.Name = "userNameDataGridViewTextBoxColumn";
     307            //
     308            // isAnonymousDataGridViewCheckBoxColumn
     309            //
     310            this.isAnonymousDataGridViewCheckBoxColumn.DataPropertyName = "IsAnonymous";
     311            this.isAnonymousDataGridViewCheckBoxColumn.HeaderText = "IsAnonymous";
     312            this.isAnonymousDataGridViewCheckBoxColumn.Name = "isAnonymousDataGridViewCheckBoxColumn";
     313            //
     314            // Membership
     315            //
     316            this.Membership.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
     317            this.Membership.DataPropertyName = "Membership.Email";
     318            this.Membership.HeaderText = "EMail";
     319            this.Membership.Name = "Membership";
     320            this.Membership.Width = 58;
    299321            //
    300322            // bsUsers
     
    632654            //
    633655            this.bsUserRoles.DataSource = typeof(HeuristicLab.Services.Authentication.DataTransfer.Role);
    634             //
    635             // Membership
    636             //
    637             this.Membership.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
    638             this.Membership.DataPropertyName = "Membership.Email";
    639             this.Membership.HeaderText = "EMail";
    640             this.Membership.Name = "Membership";
    641             this.Membership.Width = 58;
    642             //
    643             // isAnonymousDataGridViewCheckBoxColumn
    644             //
    645             this.isAnonymousDataGridViewCheckBoxColumn.DataPropertyName = "IsAnonymous";
    646             this.isAnonymousDataGridViewCheckBoxColumn.HeaderText = "IsAnonymous";
    647             this.isAnonymousDataGridViewCheckBoxColumn.Name = "isAnonymousDataGridViewCheckBoxColumn";
    648             //
    649             // userNameDataGridViewTextBoxColumn
    650             //
    651             this.userNameDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
    652             this.userNameDataGridViewTextBoxColumn.DataPropertyName = "UserName";
    653             this.userNameDataGridViewTextBoxColumn.HeaderText = "UserName";
    654             this.userNameDataGridViewTextBoxColumn.Name = "userNameDataGridViewTextBoxColumn";
    655656            //
    656657            // UserManagement
  • branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/UserManagement.cs

    r4726 r4740  
    179179        }
    180180
     181        private void bsApplications_CurrentChanged(object sender, EventArgs e)
     182        {
     183
     184        }
     185
    181186   
    182187
  • branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/UserManagement.resx

    r4726 r4740  
    139139    <value>False</value>
    140140  </metadata>
     141  <metadata name="bsApplications.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     142    <value>17, 56</value>
     143  </metadata>
    141144  <metadata name="Membership.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    142145    <value>True</value>
     
    145148    <value>17, 17</value>
    146149  </metadata>
    147   <metadata name="bsApplications.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    148     <value>17, 56</value>
     150  <metadata name="Membership.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     151    <value>True</value>
    149152  </metadata>
    150   <metadata name="bsApplications.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    151     <value>17, 56</value>
     153  <metadata name="bsUsers.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     154    <value>17, 17</value>
    152155  </metadata>
    153156  <metadata name="bsUser.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
  • branches/UserManagement/HeuristicLab.Services.Authentication/AuthenticationService.cs

    r4726 r4740  
    1919            using (UserManagementDataContext db = new UserManagementDataContext())
    2020            {
    21                 try
    22                 {
    23                     Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
    24 
    25                     var User = from item in UserTable
    26                                where item.UserId == id
    27                                select item;
    28                     aspnet_User eUser = User.Single();
    29 
    30                     User user = Convert.ToDataTransfer((aspnet_User)eUser);
    31 
    32                     if (user == null) { return null; }
    33 
    34                     //Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
    35 
    36                     //var Membership = from item in MembershipTable
    37                     //                 where item.UserId == id
    38                     //                 select item;
    39 
    40                     Membership membership = Convert.ToDataTransfer((aspnet_Membership)eUser.aspnet_Membership);
    41 
    42                     if (membership == null) { return null; }
    43                     user.Membership = membership;
    44 
    45                     return user;
    46 
    47 
    48                 }
    49                 catch (Exception ex)
    50                 {
    51                     Debug.WriteLine(ex.InnerException);
    52                     return null;
    53                 }
     21                  var user = db.aspnet_Users.Where(x => x.UserId == id).FirstOrDefault();
     22                  var membership = db.aspnet_Memberships.Where(x => x.UserId == id).FirstOrDefault();
     23                   
     24
     25                  return Convert.ToDataTransfer(user, membership);
     26                  //Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
     27
     28                  //var User = from item in UserTable
     29                  //           where item.UserId == id
     30                  //           select item;
     31                  //aspnet_User eUser = User.Single();
     32
     33                  //User user = Convert.ToDataTransfer((aspnet_User)eUser);
     34
     35                  //if (user == null) { return null; }
     36
     37                  //Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
     38
     39                  //var Membership = from item in MembershipTable
     40                  //                 where item.UserId == id
     41                  //                 select item;
     42
     43                  //Membership membership = Convert.ToDataTransfer((aspnet_Membership)eUser.aspnet_Membership);
     44
     45                  //if (membership == null) { return null; }
     46                  //user.Membership = membership;
     47
     48                  //return user;
     49
    5450            }
    55         }
    56 
    57         public DataTransfer.User GetUser(Guid applicationId, string userName)
    58         {
    59             using (UserManagementDataContext db = new UserManagementDataContext())
    60             {
    61                 try
    62                 {
    63                     Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
    64 
    65                     var User = from item in UserTable
    66                                where item.UserName == userName && item.ApplicationId == applicationId
    67                                select item;
    68 
    69                     User user = Convert.ToDataTransfer((aspnet_User)User.Single());
    70 
    71                     if (user == null) { return null; }
    72 
    73                     Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
    74 
    75                     var Membership = from item in MembershipTable
    76                                      where item.UserId == user.UserId
    77                                      select item;
    78 
    79                     Membership membership = Convert.ToDataTransfer((aspnet_Membership)Membership.Single());
    80 
    81                     if (membership == null) { return null; }
    82                     user.Membership = membership;
    83 
    84                     return user;
    85 
    86 
    87 
    88 
    89                 }
    90                 catch (Exception ex)
    91                 {
    92                     Debug.WriteLine(ex.InnerException);
    93                     return null;
    94                 }
    95                }
    96         }
    97 
    98         public IEnumerable<DataTransfer.User> GetUsers(Guid applicationId)
    99         {
    100             List<DataTransfer.User> UserList = new List<DataTransfer.User>();
    101             using (UserManagementDataContext db = new UserManagementDataContext())
    102             {
    103                 try
    104                 {
    105                     Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
    106                     var Users = from item in UserTable
    107                                 where item.ApplicationId == applicationId
    108                                 select item;
    109                     foreach (var eUser in Users)
    110                     {
    111 
    112                         User user = Convert.ToDataTransfer(eUser);
    113 
    114                         if (user== null) { return null; }
    115 
    116                         //Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
    117 
    118                         //var Membership = from item in MembershipTable
    119                         //                 where item.UserId == user.UserId
    120                         //                 select item;
    121 
    122                         Membership membership = Convert.ToDataTransfer((aspnet_Membership)eUser.aspnet_Membership);
    123 
    124                         if (membership == null) { return null; }
    125                         user.Membership = membership;
    126 
    127                         UserList.Add(user);
    128                     }
    129                 }
    130                 catch (Exception ex)
    131                 {
    132                     Debug.WriteLine(ex.InnerException);
    133                     return new List<User>();
    134                 }
    135             }
    136 
    137             return UserList;
    138         }
    139         public bool InsertUser(User user)
    140         {
    141             if (user != null)
    142             {
    143                 using (UserManagementDataContext db = new UserManagementDataContext())
    144                 {
    145                     try
    146                     {
    147 
    148                         Guid? userId = null;
    149                         Application application = GetApplication(user.ApplicationId);
    150                         if(application == null){return false;}
    151                         if (user.Membership == null) { return false; }
     51      }
     52
     53        #endregion
     54
     55
     56      //public DataTransfer.User GetUser(Guid applicationId, string userName)
     57        //{
     58        //    using (UserManagementDataContext db = new UserManagementDataContext())
     59        //    {
     60        //        try
     61        //        {
     62        //            Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
     63
     64        //            var User = from item in UserTable
     65        //                       where item.UserName == userName && item.ApplicationId == applicationId
     66        //                       select item;
     67
     68        //            User user = Convert.ToDataTransfer((aspnet_User)User.Single());
     69
     70        //            if (user == null) { return null; }
     71
     72        //            Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
     73
     74        //            var Membership = from item in MembershipTable
     75        //                             where item.UserId == user.UserId
     76        //                             select item;
     77
     78        //            Membership membership = Convert.ToDataTransfer((aspnet_Membership)Membership.Single());
     79
     80        //            if (membership == null) { return null; }
     81        //            user.Membership = membership;
     82
     83        //            return user;
     84
     85
     86
     87
     88        //        }
     89        //        catch (Exception ex)
     90        //        {
     91        //            Debug.WriteLine(ex.InnerException);
     92        //            return null;
     93        //        }
     94        //       }
     95        //}
     96
     97        //public IEnumerable<DataTransfer.User> GetUsers(Guid applicationId)
     98        //{
     99        //    List<DataTransfer.User> UserList = new List<DataTransfer.User>();
     100        //    using (UserManagementDataContext db = new UserManagementDataContext())
     101        //    {
     102        //        try
     103        //        {
     104        //            Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
     105        //            var Users = from item in UserTable
     106        //                        where item.ApplicationId == applicationId
     107        //                        select item;
     108        //            foreach (var eUser in Users)
     109        //            {
     110
     111        //                User user = Convert.ToDataTransfer(eUser);
     112
     113        //                if (user== null) { return null; }
     114
     115        //                //Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
     116
     117        //                //var Membership = from item in MembershipTable
     118        //                //                 where item.UserId == user.UserId
     119        //                //                 select item;
     120
     121        //                Membership membership = Convert.ToDataTransfer((aspnet_Membership)eUser.aspnet_Membership);
     122
     123        //                if (membership == null) { return null; }
     124        //                user.Membership = membership;
     125
     126        //                UserList.Add(user);
     127        //            }
     128        //        }
     129        //        catch (Exception ex)
     130        //        {
     131        //            Debug.WriteLine(ex.InnerException);
     132        //            return new List<User>();
     133        //        }
     134        //    }
     135
     136        //    return UserList;
     137        //}
     138        //public bool InsertUser(User user)
     139        //{
     140        //    if (user != null)
     141        //    {
     142        //        using (UserManagementDataContext db = new UserManagementDataContext())
     143        //        {
     144        //            try
     145        //            {
     146
     147        //                Guid? userId = null;
     148        //                Application application = GetApplication(user.ApplicationId);
     149        //                if(application == null){return false;}
     150        //                if (user.Membership == null) { return false; }
    152151   
    153                         int? passwordFormat = 1;
    154                         int? uniqueEmail = null;
    155                         int result = db.aspnet_Membership_CreateUser(application.ApplicationName, user.UserName, user.Membership.Password, user.Membership.PasswordSalt, user.Membership.Email, user.Membership.PasswordQuestion, user.Membership.PasswordAnswer, user.Membership.IsApproved, DateTime.UtcNow, DateTime.Now, uniqueEmail, passwordFormat, ref userId);
     152        //                int? passwordFormat = 1;
     153        //                int? uniqueEmail = null;
     154        //                int result = db.aspnet_Membership_CreateUser(application.ApplicationName, user.UserName, user.Membership.Password, user.Membership.PasswordSalt, user.Membership.Email, user.Membership.PasswordQuestion, user.Membership.PasswordAnswer, user.Membership.IsApproved, DateTime.UtcNow, DateTime.Now, uniqueEmail, passwordFormat, ref userId);
    156155                                                   
    157                         if (result != 0)
    158                         {
    159                             return false;
    160                         }
    161 
    162                         if (userId != null)
    163                         {
    164                             return true;
    165                         }
    166                         else
    167                         {
    168                             return false;
    169                         }
    170                     }
    171                     catch (Exception ex)
    172                     {
    173                         Debug.WriteLine(ex.InnerException);
    174                         return false;
    175                     }
    176                 }
     156        //                if (result != 0)
     157        //                {
     158        //                    return false;
     159        //                }
     160
     161        //                if (userId != null)
     162        //                {
     163        //                    return true;
     164        //                }
     165        //                else
     166        //                {
     167        //                    return false;
     168        //                }
     169        //            }
     170        //            catch (Exception ex)
     171        //            {
     172        //                Debug.WriteLine(ex.InnerException);
     173        //                return false;
     174        //            }
     175        //        }
    177176           
    178             }
    179             return false;
    180         }
    181         public bool DeleteUser(Guid id)
    182         {
    183 
    184             User user = GetUser(id);
    185             if (user != null)
    186             {
    187 
    188                 using (UserManagementDataContext db = new UserManagementDataContext())
    189                 {
    190                     try
    191                     {
    192                         Application application = GetApplication(user.ApplicationId);
    193                         if (application == null)
    194                         {
    195                             return false;
    196                         }
    197 
    198                         int? tablesToDeleteFrom = 99;
    199                         int? numTablesDeletedFrom = null;
    200                         db.aspnet_Users_DeleteUser(application.ApplicationName, user.UserName, tablesToDeleteFrom, ref numTablesDeletedFrom);
     177        //    }
     178        //    return false;
     179        //}
     180        //public bool DeleteUser(Guid id)
     181        //{
     182
     183        //    User user = GetUser(id);
     184        //    if (user != null)
     185        //    {
     186
     187        //        using (UserManagementDataContext db = new UserManagementDataContext())
     188        //        {
     189        //            try
     190        //            {
     191        //                Application application = GetApplication(user.ApplicationId);
     192        //                if (application == null)
     193        //                {
     194        //                    return false;
     195        //                }
     196
     197        //                int? tablesToDeleteFrom = 99;
     198        //                int? numTablesDeletedFrom = null;
     199        //                db.aspnet_Users_DeleteUser(application.ApplicationName, user.UserName, tablesToDeleteFrom, ref numTablesDeletedFrom);
    201200                       
    202                         if (numTablesDeletedFrom != null)
    203                         {
    204                             return true;
    205                         }
    206                         else
    207                         {
    208                             return false;
    209                         }
    210                     }
    211                     catch (Exception ex)
    212                     {
    213                         Debug.WriteLine(ex.InnerException);
    214                         return false;
    215                     }
    216                 }
    217             }
    218             return false;
    219         }
    220 
    221         public bool UpdateUser(User user)
    222         {
     201        //                if (numTablesDeletedFrom != null)
     202        //                {
     203        //                    return true;
     204        //                }
     205        //                else
     206        //                {
     207        //                    return false;
     208        //                }
     209        //            }
     210        //            catch (Exception ex)
     211        //            {
     212        //                Debug.WriteLine(ex.InnerException);
     213        //                return false;
     214        //            }
     215        //        }
     216        //    }
     217        //    return false;
     218        //}
     219
     220        //public bool UpdateUser(User user)
     221        //{
    223222           
    224             if (user != null)
    225             {
    226 
    227                 using (UserManagementDataContext db = new UserManagementDataContext())
    228                 {
    229                     try
    230                     {
    231                         if (user.Membership == null)
    232                         {
    233                             return false;
    234                         }
    235 
    236                         Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
    237 
    238                         var User = from item in UserTable
    239                                    where item.UserId == user.UserId
    240                                    select item;
    241                        aspnet_User eUser = ((aspnet_User)User.Single());
    242 
    243 
    244                        Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
    245 
    246                        var Membership = from item in MembershipTable
    247                                         where item.UserId == user.UserId
    248                                         select item;
    249 
    250                        aspnet_Membership eMembership = ((aspnet_Membership)Membership.Single());
    251 
    252                         Convert.ToEntity(user, eUser);
     223        //    if (user != null)
     224        //    {
     225
     226        //        using (UserManagementDataContext db = new UserManagementDataContext())
     227        //        {
     228        //            try
     229        //            {
     230        //                if (user.Membership == null)
     231        //                {
     232        //                    return false;
     233        //                }
     234
     235        //                Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
     236
     237        //                var User = from item in UserTable
     238        //                           where item.UserId == user.UserId
     239        //                           select item;
     240        //               aspnet_User eUser = ((aspnet_User)User.Single());
     241
     242
     243        //               Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
     244
     245        //               var Membership = from item in MembershipTable
     246        //                                where item.UserId == user.UserId
     247        //                                select item;
     248
     249        //               aspnet_Membership eMembership = ((aspnet_Membership)Membership.Single());
     250
     251        //                Convert.ToEntity(user, eUser);
    253252                       
    254                         Convert.ToEntity(user.Membership, eMembership);
    255                         if (eUser == null)
    256                         {
    257                            return false;
    258                         }
    259                         if (eMembership == null)
    260                         {
    261                             return false;
    262                         }
    263                         db.SubmitChanges();
    264                     }
    265                     catch (Exception ex)
    266                     {
    267                         Debug.WriteLine(ex.InnerException);
    268                         return false;
    269                     }
    270                 }
    271             } return false;
    272         }
    273 
    274         #endregion
    275 
    276 
    277         #region Role
    278 
    279         public Role GetRole(Guid id)
    280         {
    281             using (UserManagementDataContext db = new UserManagementDataContext())
    282             {
    283                 try
    284                 {
    285                     Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
    286 
    287                     var Role = from item in RoleTable
    288                                where item.RoleId == id
    289                                select item;
    290                     return Convert.ToDataTransfer((aspnet_Role)Role.Single());
    291                 }
    292                 catch (Exception ex)
    293                 {
    294                     Debug.WriteLine(ex.InnerException);
    295                     return null;
    296                 }
    297             }
    298         }
    299 
    300         public Role GetRole(Guid applicationId, string roleName)
    301         {
    302             using (UserManagementDataContext db = new UserManagementDataContext())
    303             {
    304                 try
    305                 {
    306                     Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
    307 
    308                     var Role = from item in RoleTable
    309                                where item.RoleName == roleName && item.ApplicationId == applicationId
    310                                select item;
    311                     return Convert.ToDataTransfer((aspnet_Role)Role.Single());
    312                 }
    313                 catch (Exception ex)
    314                 {
    315                     Debug.WriteLine(ex.InnerException);
    316                     return null;
    317                 }
    318             }
    319         }
    320 
    321         public bool RoleExists(Guid roleId)
    322         {
    323             if (roleId != null)
    324             {
    325                 using (UserManagementDataContext db = new UserManagementDataContext())
    326                 {
    327                     try
    328                     {
    329                         Role role = GetRole(roleId);
    330                         if (role == null)
    331                         {
    332                             return false;
    333                         }
    334                         Application application = GetApplication(role.ApplicationId);
    335                         if (application == null)
    336                         {
    337                             return false;
    338                         }
    339 
    340                         int result = db.aspnet_Roles_RoleExists(application.ApplicationName, role.RoleName);
     253        //                Convert.ToEntity(user.Membership, eMembership);
     254        //                if (eUser == null)
     255        //                {
     256        //                   return false;
     257        //                }
     258        //                if (eMembership == null)
     259        //                {
     260        //                    return false;
     261        //                }
     262        //                db.SubmitChanges();
     263        //            }
     264        //            catch (Exception ex)
     265        //            {
     266        //                Debug.WriteLine(ex.InnerException);
     267        //                return false;
     268        //            }
     269        //        }
     270        //    } return false;
     271        //}
     272
     273        //#endregion
     274
     275        //#region Role
     276
     277        //public Role GetRole(Guid id)
     278        //{
     279        //    using (UserManagementDataContext db = new UserManagementDataContext())
     280        //    {
     281        //        try
     282        //        {
     283        //            Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
     284
     285        //            var Role = from item in RoleTable
     286        //                       where item.RoleId == id
     287        //                       select item;
     288        //            return Convert.ToDataTransfer((aspnet_Role)Role.Single());
     289        //        }
     290        //        catch (Exception ex)
     291        //        {
     292        //            Debug.WriteLine(ex.InnerException);
     293        //            return null;
     294        //        }
     295        //    }
     296        //}
     297
     298        //public Role GetRole(Guid applicationId, string roleName)
     299        //{
     300        //    using (UserManagementDataContext db = new UserManagementDataContext())
     301        //    {
     302        //        try
     303        //        {
     304        //            Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
     305
     306        //            var Role = from item in RoleTable
     307        //                       where item.RoleName == roleName && item.ApplicationId == applicationId
     308        //                       select item;
     309        //            return Convert.ToDataTransfer((aspnet_Role)Role.Single());
     310        //        }
     311        //        catch (Exception ex)
     312        //        {
     313        //            Debug.WriteLine(ex.InnerException);
     314        //            return null;
     315        //        }
     316        //    }
     317        //}
     318
     319        //public bool RoleExists(Guid roleId)
     320        //{
     321        //    if (roleId != null)
     322        //    {
     323        //        using (UserManagementDataContext db = new UserManagementDataContext())
     324        //        {
     325        //            try
     326        //            {
     327        //                Role role = GetRole(roleId);
     328        //                if (role == null)
     329        //                {
     330        //                    return false;
     331        //                }
     332        //                Application application = GetApplication(role.ApplicationId);
     333        //                if (application == null)
     334        //                {
     335        //                    return false;
     336        //                }
     337
     338        //                int result = db.aspnet_Roles_RoleExists(application.ApplicationName, role.RoleName);
    341339                       
    342                         return (result == 0);
    343                     }
    344                     catch (Exception ex)
    345                     {
    346                         Debug.Write(ex.InnerException);
    347                         return false;
    348                     }
    349                 }
    350 
    351             } return false;
    352         }
    353 
    354         public IEnumerable<Role> GetRoles(Guid applicationId)
    355         {
    356             List<Role> RoleList = new List<Role>();
    357 
    358             using (UserManagementDataContext db = new UserManagementDataContext())
    359             {
    360                 try
    361                 {
    362                    // db.aspnet_Roles_GetAllRoles(applicationName);
    363                     Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
    364 
    365                     var Roles = from item in RoleTable
    366                                 where item.ApplicationId == applicationId
    367                                 select item;
    368                     foreach (var Role in Roles)
    369                     {
    370                         RoleList.Add(Convert.ToDataTransfer((aspnet_Role)Role));
    371                     }
    372                 }
    373                 catch (Exception ex)
    374                 {
    375                     Debug.WriteLine(ex.InnerException);
    376                     return new List<Role>();
    377                 }
    378             }
    379 
    380             return RoleList;
    381         }
     340        //                return (result == 0);
     341        //            }
     342        //            catch (Exception ex)
     343        //            {
     344        //                Debug.Write(ex.InnerException);
     345        //                return false;
     346        //            }
     347        //        }
     348
     349        //    } return false;
     350        //}
     351
     352        //public IEnumerable<Role> GetRoles(Guid applicationId)
     353        //{
     354        //    List<Role> RoleList = new List<Role>();
     355
     356        //    using (UserManagementDataContext db = new UserManagementDataContext())
     357        //    {
     358        //        try
     359        //        {
     360        //           // db.aspnet_Roles_GetAllRoles(applicationName);
     361        //            Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
     362
     363        //            var Roles = from item in RoleTable
     364        //                        where item.ApplicationId == applicationId
     365        //                        select item;
     366        //            foreach (var Role in Roles)
     367        //            {
     368        //                RoleList.Add(Convert.ToDataTransfer((aspnet_Role)Role));
     369        //            }
     370        //        }
     371        //        catch (Exception ex)
     372        //        {
     373        //            Debug.WriteLine(ex.InnerException);
     374        //            return new List<Role>();
     375        //        }
     376        //    }
     377
     378        //    return RoleList;
     379        //}
    382380       
    383         public bool InsertRole(Role role)
    384         {
    385             if (role != null)
    386             {
    387                 using (UserManagementDataContext db = new UserManagementDataContext())
    388                 {
    389                     try
    390                     {
    391                         Application application = GetApplication(role.ApplicationId);
    392                         if (application == null)
    393                         {
    394                             return false;
    395                         }
    396                         int result = db.aspnet_Roles_CreateRole(application.ApplicationName, role.RoleName);
     381        //public bool InsertRole(Role role)
     382        //{
     383        //    if (role != null)
     384        //    {
     385        //        using (UserManagementDataContext db = new UserManagementDataContext())
     386        //        {
     387        //            try
     388        //            {
     389        //                Application application = GetApplication(role.ApplicationId);
     390        //                if (application == null)
     391        //                {
     392        //                    return false;
     393        //                }
     394        //                int result = db.aspnet_Roles_CreateRole(application.ApplicationName, role.RoleName);
    397395                       
    398                         return (result == 0); // checken, welchen rückgabewert (in db, procedure)
     396        //                return (result == 0); // checken, welchen rückgabewert (in db, procedure)
    399397                     
    400                     }
    401                     catch (Exception ex)
    402                     {
    403                         Debug.WriteLine(ex.InnerException);
    404                         return false;
    405                     }
    406                 }
     398        //            }
     399        //            catch (Exception ex)
     400        //            {
     401        //                Debug.WriteLine(ex.InnerException);
     402        //                return false;
     403        //            }
     404        //        }
    407405             
    408             }
    409             return false;
    410         }
    411         public bool UpdateRole(Role role)
    412         {
    413 
    414             if (role != null)
    415             {
    416 
    417                 using (UserManagementDataContext db = new UserManagementDataContext())
    418                 {
    419                     try
    420                     {
    421 
    422                         Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
    423 
    424                         var Role = from item in RoleTable
    425                                    where item.RoleId == role.RoleId
    426                                    select item;
    427                         aspnet_Role eRole = ((aspnet_Role)Role.Single());
    428 
    429 
    430                         Convert.ToEntity(role, eRole);
    431 
    432                         if (eRole != null)
    433                         {
    434                             db.SubmitChanges();
    435                         }
    436                         else
    437                         {
    438                             return false;
    439                         }
    440                     }
    441                     catch (Exception ex)
    442                     {
    443                         Debug.WriteLine(ex.InnerException);
    444                         return false;
    445                     }
    446                 }
    447             } return false;
    448         }
    449 
    450         public bool DeleteRole(Guid id)
    451         {
    452             if (id != null)
    453             {
    454                 using (UserManagementDataContext db = new UserManagementDataContext())
    455                 {
    456                     try
    457                     {
    458                         Role role = GetRole(id);
    459 
    460                         bool deleteOnlyIfRoleIsEmpty = false;
    461                         if (role == null)
    462                         {
    463                             return false;
    464                         }
    465                         Application application = GetApplication(role.ApplicationId);
    466                         if (application == null)
    467                         {
    468                             return false;
    469                         }
    470                         db.aspnet_Roles_DeleteRole(application.ApplicationName, role.RoleName, deleteOnlyIfRoleIsEmpty);
     406        //    }
     407        //    return false;
     408        //}
     409        //public bool UpdateRole(Role role)
     410        //{
     411
     412        //    if (role != null)
     413        //    {
     414
     415        //        using (UserManagementDataContext db = new UserManagementDataContext())
     416        //        {
     417        //            try
     418        //            {
     419
     420        //                Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
     421
     422        //                var Role = from item in RoleTable
     423        //                           where item.RoleId == role.RoleId
     424        //                           select item;
     425        //                aspnet_Role eRole = ((aspnet_Role)Role.Single());
     426
     427
     428        //                Convert.ToEntity(role, eRole);
     429
     430        //                if (eRole != null)
     431        //                {
     432        //                    db.SubmitChanges();
     433        //                }
     434        //                else
     435        //                {
     436        //                    return false;
     437        //                }
     438        //            }
     439        //            catch (Exception ex)
     440        //            {
     441        //                Debug.WriteLine(ex.InnerException);
     442        //                return false;
     443        //            }
     444        //        }
     445        //    } return false;
     446        //}
     447
     448        //public bool DeleteRole(Guid id)
     449        //{
     450        //    if (id != null)
     451        //    {
     452        //        using (UserManagementDataContext db = new UserManagementDataContext())
     453        //        {
     454        //            try
     455        //            {
     456        //                Role role = GetRole(id);
     457
     458        //                bool deleteOnlyIfRoleIsEmpty = false;
     459        //                if (role == null)
     460        //                {
     461        //                    return false;
     462        //                }
     463        //                Application application = GetApplication(role.ApplicationId);
     464        //                if (application == null)
     465        //                {
     466        //                    return false;
     467        //                }
     468        //                db.aspnet_Roles_DeleteRole(application.ApplicationName, role.RoleName, deleteOnlyIfRoleIsEmpty);
    471469
    472470                     
    473471
    474                         return true;
    475                     }
    476                     catch (Exception ex)
    477                     {
    478                         Debug.WriteLine(ex.InnerException);
    479                         return false;
    480                     }
    481                 }
     472        //                return true;
     473        //            }
     474        //            catch (Exception ex)
     475        //            {
     476        //                Debug.WriteLine(ex.InnerException);
     477        //                return false;
     478        //            }
     479        //        }
    482480             
    483             }
    484             return false;
    485         }
    486 
    487         public bool IsUserInRole(Guid roleId, Guid userId)
    488         {
    489             if (roleId != null && userId != null)
    490             {
    491                 using (UserManagementDataContext db = new UserManagementDataContext())
    492                 {
    493 
    494                     try
    495                     {
    496                         User user = GetUser(userId);
    497                         if (user == null) { return false; }
    498 
    499                         Application application = GetApplication(user.ApplicationId);
    500                         if (application == null) { return false; }
    501 
    502                         Role role = GetRole(roleId);
    503                         if (role == null) { return false; }
    504 
    505                         int result = db.aspnet_UsersInRoles_IsUserInRole(application.ApplicationName, user.UserName, role.RoleName);
     481        //    }
     482        //    return false;
     483        //}
     484
     485        //public bool IsUserInRole(Guid roleId, Guid userId)
     486        //{
     487        //    if (roleId != null && userId != null)
     488        //    {
     489        //        using (UserManagementDataContext db = new UserManagementDataContext())
     490        //        {
     491
     492        //            try
     493        //            {
     494        //                User user = GetUser(userId);
     495        //                if (user == null) { return false; }
     496
     497        //                Application application = GetApplication(user.ApplicationId);
     498        //                if (application == null) { return false; }
     499
     500        //                Role role = GetRole(roleId);
     501        //                if (role == null) { return false; }
     502
     503        //                int result = db.aspnet_UsersInRoles_IsUserInRole(application.ApplicationName, user.UserName, role.RoleName);
    506504                       
    507                         return (result == 0);
    508                     }
    509                     catch (Exception ex)
    510                     {
    511                         Debug.WriteLine(ex.InnerException);
    512                         return false;
    513 
    514                     }
    515 
    516                 }
    517 
    518             } return false;
    519         }
    520 
    521         public bool AddUserToRole(Guid roleId, Guid userId)
    522         {
    523             using (UserManagementDataContext db = new UserManagementDataContext())
    524             {
    525                 try
    526                 {
    527                     Role role = GetRole(roleId);
    528                     if (role == null)
    529                     {
    530                         return false;
    531                     }
    532                     Application application = GetApplication(role.ApplicationId);
    533                     if (application == null)
    534                     {
    535                         return false;
    536                     }
    537                     User user = GetUser(userId);
    538                     if (user == null)
    539                     {
    540                         return false;
    541                     }
    542 
    543                     db.aspnet_UsersInRoles_AddUsersToRoles(application.ApplicationName, user.UserName, role.RoleName,DateTime.Now);
    544                     return true;
    545                 }
    546                 catch (Exception ex)
    547                 {
    548                     Debug.WriteLine(ex.InnerException);
    549                     return false;
    550                 }
    551             }
     505        //                return (result == 0);
     506        //            }
     507        //            catch (Exception ex)
     508        //            {
     509        //                Debug.WriteLine(ex.InnerException);
     510        //                return false;
     511
     512        //            }
     513
     514        //        }
     515
     516        //    } return false;
     517        //}
     518
     519        //public bool AddUserToRole(Guid roleId, Guid userId)
     520        //{
     521        //    using (UserManagementDataContext db = new UserManagementDataContext())
     522        //    {
     523        //        try
     524        //        {
     525        //            Role role = GetRole(roleId);
     526        //            if (role == null)
     527        //            {
     528        //                return false;
     529        //            }
     530        //            Application application = GetApplication(role.ApplicationId);
     531        //            if (application == null)
     532        //            {
     533        //                return false;
     534        //            }
     535        //            User user = GetUser(userId);
     536        //            if (user == null)
     537        //            {
     538        //                return false;
     539        //            }
     540
     541        //            db.aspnet_UsersInRoles_AddUsersToRoles(application.ApplicationName, user.UserName, role.RoleName,DateTime.Now);
     542        //            return true;
     543        //        }
     544        //        catch (Exception ex)
     545        //        {
     546        //            Debug.WriteLine(ex.InnerException);
     547        //            return false;
     548        //        }
     549        //    }
    552550       
    553         }
    554         public bool RemoveUserFromRole(Guid roleId, Guid userId)
    555         {
    556             using (UserManagementDataContext db = new UserManagementDataContext())
    557             {
    558                 try
    559                 {
    560                     Role role = GetRole(roleId);
    561                     if (role == null)
    562                     {
    563                         return false;
    564                     }
    565                     Application application = GetApplication(role.ApplicationId);
    566                     if (application == null)
    567                     {
    568                         return false;
    569                     }
    570                     User user = GetUser(userId);
    571                     if (user == null)
    572                     {
    573                         return false;
    574                     }
    575 
    576                    db.aspnet_UsersInRoles_RemoveUsersFromRoles(application.ApplicationName, user.UserName, role.RoleName);
    577                     return true;
     551        //}
     552        //public bool RemoveUserFromRole(Guid roleId, Guid userId)
     553        //{
     554        //    using (UserManagementDataContext db = new UserManagementDataContext())
     555        //    {
     556        //        try
     557        //        {
     558        //            Role role = GetRole(roleId);
     559        //            if (role == null)
     560        //            {
     561        //                return false;
     562        //            }
     563        //            Application application = GetApplication(role.ApplicationId);
     564        //            if (application == null)
     565        //            {
     566        //                return false;
     567        //            }
     568        //            User user = GetUser(userId);
     569        //            if (user == null)
     570        //            {
     571        //                return false;
     572        //            }
     573
     574        //           db.aspnet_UsersInRoles_RemoveUsersFromRoles(application.ApplicationName, user.UserName, role.RoleName);
     575        //            return true;
    578576                   
    579                 }
    580                 catch (Exception ex)
    581                 {
    582                     Debug.WriteLine(ex.InnerException);
    583                     return false;
    584                 }
    585             }
     577        //        }
     578        //        catch (Exception ex)
     579        //        {
     580        //            Debug.WriteLine(ex.InnerException);
     581        //            return false;
     582        //        }
     583        //    }
    586584           
    587         }
    588         public IEnumerable<Role> GetRolesForUser(Guid userId)
    589         {
    590             List<Role> roles = new List<Role>();
    591             using (UserManagementDataContext db = new UserManagementDataContext())
    592             {
    593                 try
    594                 {
    595                     User user = GetUser(userId);
    596                     if (user == null)
    597                     {
    598                         return roles;
    599                     }
    600                     Application application = GetApplication(user.ApplicationId);
    601                     if (application == null)
    602                     {
    603                         return roles;
    604                     }
     585        //}
     586        //public IEnumerable<Role> GetRolesForUser(Guid userId)
     587        //{
     588        //    List<Role> roles = new List<Role>();
     589        //    using (UserManagementDataContext db = new UserManagementDataContext())
     590        //    {
     591        //        try
     592        //        {
     593        //            User user = GetUser(userId);
     594        //            if (user == null)
     595        //            {
     596        //                return roles;
     597        //            }
     598        //            Application application = GetApplication(user.ApplicationId);
     599        //            if (application == null)
     600        //            {
     601        //                return roles;
     602        //            }
    605603                   
    606604
    607                     ISingleResult<aspnet_UsersInRoles_GetRolesForUserResult> results = db.aspnet_UsersInRoles_GetRolesForUser(application.ApplicationName,user.UserName);
    608                     foreach (aspnet_UsersInRoles_GetRolesForUserResult userInRole in results)
    609                     {
    610                         roles.Add(GetRole(application.ApplicationId,userInRole.RoleName));
    611                     }
    612                 }
    613                 catch (Exception ex)
    614                 {
    615                     Debug.WriteLine(ex.InnerException);
    616                     return new List<Role>();
    617                 }
    618             }
     605        //            ISingleResult<aspnet_UsersInRoles_GetRolesForUserResult> results = db.aspnet_UsersInRoles_GetRolesForUser(application.ApplicationName,user.UserName);
     606        //            foreach (aspnet_UsersInRoles_GetRolesForUserResult userInRole in results)
     607        //            {
     608        //                roles.Add(GetRole(application.ApplicationId,userInRole.RoleName));
     609        //            }
     610        //        }
     611        //        catch (Exception ex)
     612        //        {
     613        //            Debug.WriteLine(ex.InnerException);
     614        //            return new List<Role>();
     615        //        }
     616        //    }
    619617           
    620             return roles;
    621         }
    622 
    623         public IEnumerable<User> GetUsersInRole(Guid roleId)
    624         {
    625             List<User> users = new List<User>();
    626 
    627             using(UserManagementDataContext db = new UserManagementDataContext()){
    628                 try
    629                 {
    630                     Role role = GetRole(roleId);
    631 
    632                     if (role != null)
    633                     {
    634                         Application application = GetApplication(role.ApplicationId);
    635 
    636                         if (application != null)
    637                         {
    638 
    639 
    640                             ISingleResult<aspnet_UsersInRoles_GetUsersInRolesResult> result = db.aspnet_UsersInRoles_GetUsersInRoles(application.ApplicationName, role.RoleName);
    641                             foreach (aspnet_UsersInRoles_GetUsersInRolesResult usersInRole in result)
    642                             {
    643                                 users.Add(GetUser(application.ApplicationId,usersInRole.UserName));
    644                             }
    645                         }
    646                     }
    647                 }
    648                 catch (Exception ex)
    649                 {
    650                     Debug.WriteLine(ex.InnerException);
    651                     return new List<User>();
    652                 }
    653             }
    654 
    655             return users;
    656         }
    657 
    658         #endregion
    659 
    660         #region Application
    661 
    662         public Application InsertApplication(Application application)
    663         {
    664             if (application != null)
    665             {
    666                 using (UserManagementDataContext db = new UserManagementDataContext())
    667                 {
    668                     try
    669                     {
    670                         Guid? applicationId = null;
    671                         int result = db.aspnet_Applications_CreateApplication(application.ApplicationName, ref applicationId);
    672                         Console.WriteLine("result=" + result);
    673                         if (applicationId != null)
    674                         {
    675                             application.ApplicationId = (Guid)applicationId;
    676                             return application;
    677                         }
    678                         else
    679                         {
    680                             return null;
    681                         }
    682                     }
    683                     catch (Exception ex)
    684                     {
    685                         Debug.WriteLine(ex.InnerException);
    686                         return null;
    687                     }
    688                 }
     618        //    return roles;
     619        //}
     620
     621        //public IEnumerable<User> GetUsersInRole(Guid roleId)
     622        //{
     623        //    List<User> users = new List<User>();
     624
     625        //    using(UserManagementDataContext db = new UserManagementDataContext()){
     626        //        try
     627        //        {
     628        //            Role role = GetRole(roleId);
     629
     630        //            if (role != null)
     631        //            {
     632        //                Application application = GetApplication(role.ApplicationId);
     633
     634        //                if (application != null)
     635        //                {
     636
     637
     638        //                    ISingleResult<aspnet_UsersInRoles_GetUsersInRolesResult> result = db.aspnet_UsersInRoles_GetUsersInRoles(application.ApplicationName, role.RoleName);
     639        //                    foreach (aspnet_UsersInRoles_GetUsersInRolesResult usersInRole in result)
     640        //                    {
     641        //                        users.Add(GetUser(application.ApplicationId,usersInRole.UserName));
     642        //                    }
     643        //                }
     644        //            }
     645        //        }
     646        //        catch (Exception ex)
     647        //        {
     648        //            Debug.WriteLine(ex.InnerException);
     649        //            return new List<User>();
     650        //        }
     651        //    }
     652
     653        //    return users;
     654        //}
     655
     656        //#endregion
     657
     658        //#region Application
     659
     660        //public Application InsertApplication(Application application)
     661        //{
     662        //    if (application != null)
     663        //    {
     664        //        using (UserManagementDataContext db = new UserManagementDataContext())
     665        //        {
     666        //            try
     667        //            {
     668        //                Guid? applicationId = null;
     669        //                int result = db.aspnet_Applications_CreateApplication(application.ApplicationName, ref applicationId);
     670        //                Console.WriteLine("result=" + result);
     671        //                if (applicationId != null)
     672        //                {
     673        //                    application.ApplicationId = (Guid)applicationId;
     674        //                    return application;
     675        //                }
     676        //                else
     677        //                {
     678        //                    return null;
     679        //                }
     680        //            }
     681        //            catch (Exception ex)
     682        //            {
     683        //                Debug.WriteLine(ex.InnerException);
     684        //                return null;
     685        //            }
     686        //        }
    689687             
    690             }
    691             return null;
    692         }
    693 
    694         public bool DeleteApplication(Application application)
    695         {
    696             return false;
    697         }
    698 
    699         public Application GetApplication(Guid id)
    700         {
    701             using (UserManagementDataContext db = new UserManagementDataContext())
    702             {
    703                 try
    704                 {
    705                     Table<aspnet_Application> ApplicationTable = db.GetTable<aspnet_Application>();
    706 
    707                     var Application = from item in ApplicationTable
    708                                       where item.ApplicationId == id
    709                                       select item;
    710                     return Convert.ToDataTransfer((aspnet_Application)Application.Single());
    711                 }
    712                 catch (Exception ex)
    713                 {
    714                     Debug.WriteLine(ex.InnerException);
    715                     return null;
    716                 }
    717             }
    718         }
    719 
    720         public IEnumerable<DataTransfer.Application> GetApplications()
    721         {
    722             List<DataTransfer.Application> ApplicationList = new List<DataTransfer.Application>();
    723             using (UserManagementDataContext db = new UserManagementDataContext())
    724             {
    725                 try
    726                 {
    727                     Table<aspnet_Application> ApplicationTable = db.GetTable<aspnet_Application>();
    728                     var Applications = from item in ApplicationTable
    729                                 select item;
    730                     foreach (var eApplication in Applications)
    731                     {
    732 
    733                         Application application = Convert.ToDataTransfer(eApplication);
    734 
    735                         if (application == null) { return null; }
    736 
    737 
    738                         ApplicationList.Add(application);
    739                     }
    740                 }
    741                 catch (Exception ex)
    742                 {
    743                     Debug.WriteLine(ex.InnerException);
    744                     return new List<Application>();
    745                 }
    746             }
    747 
    748             return ApplicationList;
    749         }
    750 
    751 
    752 
    753         #endregion
    754 
    755         #region Membership
    756 
    757         public Membership InsertMembership(Membership membership)
    758         {
    759 
    760             if (membership != null)
    761             {
    762                 using (UserManagementDataContext db = new UserManagementDataContext())
    763                 {
    764                     try
    765                     {
    766                         Application application = GetApplication(membership.ApplicationId);
    767                         if (application == null) { return null; }
    768 
    769                     }
    770                     catch (Exception ex)
    771                     {
    772                         Debug.WriteLine(ex.InnerException);
    773                         return null;
    774                     }
    775                 }
    776             }
    777             return null;
    778         }
    779 
    780         #endregion
     688        //    }
     689        //    return null;
     690        //}
     691
     692        //public bool DeleteApplication(Application application)
     693        //{
     694        //    return false;
     695        //}
     696
     697        //public Application GetApplication(Guid id)
     698        //{
     699        //    using (UserManagementDataContext db = new UserManagementDataContext())
     700        //    {
     701        //        try
     702        //        {
     703        //            Table<aspnet_Application> ApplicationTable = db.GetTable<aspnet_Application>();
     704
     705        //            var Application = from item in ApplicationTable
     706        //                              where item.ApplicationId == id
     707        //                              select item;
     708        //            return Convert.ToDataTransfer((aspnet_Application)Application.Single());
     709        //        }
     710        //        catch (Exception ex)
     711        //        {
     712        //            Debug.WriteLine(ex.InnerException);
     713        //            return null;
     714        //        }
     715        //    }
     716        //}
     717
     718        //public IEnumerable<DataTransfer.Application> GetApplications()
     719        //{
     720        //    List<DataTransfer.Application> ApplicationList = new List<DataTransfer.Application>();
     721        //    using (UserManagementDataContext db = new UserManagementDataContext())
     722        //    {
     723        //        try
     724        //        {
     725        //            Table<aspnet_Application> ApplicationTable = db.GetTable<aspnet_Application>();
     726        //            var Applications = from item in ApplicationTable
     727        //                        select item;
     728        //            foreach (var eApplication in Applications)
     729        //            {
     730
     731        //                Application application = Convert.ToDataTransfer(eApplication);
     732
     733        //                if (application == null) { return null; }
     734
     735
     736        //                ApplicationList.Add(application);
     737        //            }
     738        //        }
     739        //        catch (Exception ex)
     740        //        {
     741        //            Debug.WriteLine(ex.InnerException);
     742        //            return new List<Application>();
     743        //        }
     744        //    }
     745
     746        //    return ApplicationList;
     747        //}
     748
     749
     750
     751        //#endregion
     752
     753        //#region Membership
     754
     755        //public Membership InsertMembership(Membership membership)
     756        //{
     757
     758        //    if (membership != null)
     759        //    {
     760        //        using (UserManagementDataContext db = new UserManagementDataContext())
     761        //        {
     762        //            try
     763        //            {
     764        //                Application application = GetApplication(membership.ApplicationId);
     765        //                if (application == null) { return null; }
     766
     767        //            }
     768        //            catch (Exception ex)
     769        //            {
     770        //                Debug.WriteLine(ex.InnerException);
     771        //                return null;
     772        //            }
     773        //        }
     774        //    }
     775        //    return null;
     776        //}
     777
     778        //#endregion
    781779    }
    782780}
  • branches/UserManagement/HeuristicLab.Services.Authentication/Convert.cs

    r4647 r4740  
    2020            {
    2121                ApplicationId = source.ApplicationId,
    22                 UserId = source.UserId,
    23                 UserName = source.UserName,
    24                 LoweredUserName = source.LoweredUserName,
    25                 IsAnonymous = source.IsAnonymous,
     22                UserId = source.Id,
     23                UserName = source.Name,
     24                //LoweredUserName = source.LoweredUserName,
     25                //IsAnonymous = source.IsAnonymous,
    2626                LastActivityDate = source.LastActivityDate
    2727            };
    2828        }
     29
     30        ///// <summary>
     31        ///// converts data transfer object to data access objet
     32        ///// </summary>
     33        ///// <param name="source">data transfer object</param>
     34        ///// <returns>data access object</returns>
     35        //public static aspnet_Membership ToEntity(User source) {
     36        //  if (source == null) return null;
     37        //  return new aspnet_Membership() {
     38        //    ApplicationId = source.ApplicationId,
     39        //    UserId = source.Id,
     40        //    Password = source.Password,
     41        //    PasswordFormat = 1,
     42        //    PasswordSalt = source.PasswordSalt,
     43        //    Email = source.Email,
     44        //    IsApproved = source.IsApproved,
     45        //    IsLockedOut = source.IsLookedOut,
     46        //    CreateDate = source.CreateDate,
     47        //    LastLoginDate = source.LastLoginDate,
     48        //    LastPasswordChangedDate = source.LastPasswordChangeDate,
     49        //    LastLockoutDate = source.LastLockoutDate,
     50        //    FailedPasswordAttemptCount = 0,
     51        //    FailedPasswordAttemptWindowStart = new System.DateTime(1900, 01, 01),
     52        //    FailedPasswordAnswerAttemptCount = 0,
     53        //    FailedPasswordAnswerAttemptWindowStart = new System.DateTime(1900, 01, 01),
     54        //    Comment = source.Comment
     55        //  };
     56        //}
    2957
    3058        /// <summary>
     
    3361        /// <param name="source">data access object</param>
    3462        /// <returns>data transfer object</returns>
    35         public static User ToDataTransfer(aspnet_User source)
     63        public static User ToDataTransfer(aspnet_User userSource, aspnet_Membership membershipSource)
    3664        {
    37             if (source == null) return null;
     65            if (userSource == null || membershipSource == null) return null;
    3866            return new User()
    3967            {
    40                 ApplicationId = source.ApplicationId,
    41                 UserId = source.UserId,
    42                 UserName = source.UserName,
    43                 LoweredUserName = source.LoweredUserName,
    44                 IsAnonymous = source.IsAnonymous,
    45                 LastActivityDate = source.LastActivityDate
     68                ApplicationId = userSource.ApplicationId,
     69                Id = userSource.UserId,
     70                Name = userSource.UserName,
     71                //LoweredUserName = userSource.LoweredUserName,
     72                //IsAnonymous = userSource.IsAnonymous,
     73                LastActivityDate = userSource.LastActivityDate,
     74                Password = membershipSource.Password,
     75                PasswordSalt = membershipSource.PasswordSalt,
     76                Email = membershipSource.Email,
     77                IsApproved = membershipSource.IsApproved,
     78                IsLookedOut = membershipSource.IsApproved,
     79                CreateDate = membershipSource.CreateDate,
     80                LastLoginDate = membershipSource.LastLoginDate,
     81                LastPasswordChangeDate = membershipSource.LastPasswordChangedDate,
     82                LastLockoutDate = membershipSource.LastLockoutDate,
     83                Comment = membershipSource.Comment
    4684            };
    4785        }
     
    5290        /// <param name="source">data transfer object</param>
    5391        /// <param name="target">data access object</param>
    54         public static void ToEntity(User source, aspnet_User target)
     92        public static void ToEntity(User source, aspnet_User userTarget, aspnet_Membership membershipTarget)
    5593        {
    56             if ((source != null) && (target != null))
     94            if ((source != null) && (userTarget != null) && (membershipTarget != null))
    5795            {
    58                 target.ApplicationId = source.ApplicationId;
    59                 target.UserId = source.UserId;
    60                 target.UserName = source.UserName;
    61                 target.LoweredUserName = source.LoweredUserName;
    62                 target.IsAnonymous = source.IsAnonymous;
    63                 target.LastActivityDate = source.LastActivityDate;
     96              userTarget.ApplicationId = source.ApplicationId;
     97              membershipTarget.ApplicationId = source.ApplicationId;
     98              userTarget.UserId = source.Id;
     99              membershipTarget.UserId = source.Id;
     100              userTarget.UserName = source.Name;
     101              userTarget.LoweredUserName = source.Name;
     102              userTarget.IsAnonymous = false;
     103              userTarget.LastActivityDate = source.LastActivityDate;
     104              membershipTarget.Password = source.Password;
     105              membershipTarget.PasswordFormat = 1;
     106              membershipTarget.PasswordSalt = source.PasswordSalt;
     107              membershipTarget.Email = source.Email;
     108              membershipTarget.IsApproved = source.IsApproved;
     109              membershipTarget.IsLockedOut = source.IsLookedOut;
     110              membershipTarget.CreateDate = source.CreateDate;
     111              membershipTarget.LastLoginDate = source.LastLoginDate;
     112              membershipTarget.LastPasswordChangedDate = source.LastPasswordChangeDate;
     113              membershipTarget.LastLockoutDate = source.LastLockoutDate;
     114              membershipTarget.FailedPasswordAttemptCount = 0;
     115              membershipTarget.FailedPasswordAttemptWindowStart = new System.DateTime(1900, 01, 01);
     116              membershipTarget.FailedPasswordAnswerAttemptCount = 0;
     117              membershipTarget.FailedPasswordAnswerAttemptWindowStart = new System.DateTime(1900, 01, 01);
     118              membershipTarget.Comment = source.Comment;
     119
    64120            }
    65121
     
    71127        #region Application
    72128
    73         /// <summary>
    74         /// converts data transfer object to data access objet
    75         /// </summary>
    76         /// <param name="source">data transfer object</param>
    77         /// <returns>data access object</returns>
    78         public static aspnet_Application ToEntity(Application source)
    79         {
    80             if (source == null) return null;
    81             return new aspnet_Application()
    82             {
    83                 ApplicationId = source.ApplicationId,
    84                 ApplicationName = source.ApplicationName,
    85                 LoweredApplicationName = source.LoweredApplicationName,
    86                 Description = source.Description
    87             };
    88         }
    89 
    90         /// <summary>
    91         /// converts data access object to data transfer object
    92         /// </summary>
    93         /// <param name="source">data access object</param>
    94         /// <returns>data transfer object</returns>
    95         public static Application ToDataTransfer(aspnet_Application source)
    96         {
    97             if (source == null) return null;
    98             return new Application()
    99             {
    100                 ApplicationId = source.ApplicationId,
    101                 ApplicationName = source.ApplicationName,
    102                 LoweredApplicationName = source.LoweredApplicationName,
    103                 Description = source.Description
    104             };
    105         }
    106 
    107         /// <summary>
    108         /// converts data transfer object to data access object
    109         /// </summary>
    110         /// <param name="source">data transfer object</param>
    111         /// <param name="target">data access object</param>
    112         public static void ToEntity(Application source, aspnet_Application target)
    113         {
    114             if ((source != null) && (target != null))
    115             {
    116                 target.ApplicationId = source.ApplicationId;
    117                 target.ApplicationName = source.ApplicationName;
    118                 target.LoweredApplicationName = source.LoweredApplicationName;
    119                 target.Description = source.Description;
    120             }
    121 
    122         }
     129        ///// <summary>
     130        ///// converts data transfer object to data access objet
     131        ///// </summary>
     132        ///// <param name="source">data transfer object</param>
     133        ///// <returns>data access object</returns>
     134        //public static aspnet_Application ToEntity(Application source)
     135        //{
     136        //    if (source == null) return null;
     137        //    return new aspnet_Application()
     138        //    {
     139        //        ApplicationId = source.ApplicationId,
     140        //        ApplicationName = source.ApplicationName,
     141        //        LoweredApplicationName = source.LoweredApplicationName,
     142        //        Description = source.Description
     143        //    };
     144        //}
     145
     146        ///// <summary>
     147        ///// converts data access object to data transfer object
     148        ///// </summary>
     149        ///// <param name="source">data access object</param>
     150        ///// <returns>data transfer object</returns>
     151        //public static Application ToDataTransfer(aspnet_Application source)
     152        //{
     153        //    if (source == null) return null;
     154        //    return new Application()
     155        //    {
     156        //        ApplicationId = source.ApplicationId,
     157        //        ApplicationName = source.ApplicationName,
     158        //        LoweredApplicationName = source.LoweredApplicationName,
     159        //        Description = source.Description
     160        //    };
     161        //}
     162
     163        ///// <summary>
     164        ///// converts data transfer object to data access object
     165        ///// </summary>
     166        ///// <param name="source">data transfer object</param>
     167        ///// <param name="target">data access object</param>
     168        //public static void ToEntity(Application source, aspnet_Application target)
     169        //{
     170        //    if ((source != null) && (target != null))
     171        //    {
     172        //        target.ApplicationId = source.ApplicationId;
     173        //        target.ApplicationName = source.ApplicationName;
     174        //        target.LoweredApplicationName = source.LoweredApplicationName;
     175        //        target.Description = source.Description;
     176        //    }
     177
     178        //}
    123179
    124180        #endregion
     
    126182        #region Membership
    127183
    128         /// <summary>
    129         /// converts data transfer object to data access objet
    130         /// </summary>
    131         /// <param name="source">data transfer object</param>
    132         /// <returns>data access object</returns>
    133         public static aspnet_Membership ToEntity(Membership source)
    134         {
    135             if (source == null) return null;
    136             return new aspnet_Membership()
    137             {
    138                 ApplicationId = source.ApplicationId,
    139                 UserId = source.UserId,
    140                 Password = source.Password,
    141                 PasswordAnswer = source.PasswordAnswer,
    142                 PasswordSalt = source.PasswordSalt,
    143                 PasswordQuestion = source.PasswordQuestion,
     184        ///// <summary>
     185        ///// converts data transfer object to data access objet
     186        ///// </summary>
     187        ///// <param name="source">data transfer object</param>
     188        ///// <returns>data access object</returns>
     189        //public static aspnet_Membership ToEntity(Membership source)
     190        //{
     191        //    if (source == null) return null;
     192        //    return new aspnet_Membership()
     193        //    {
     194        //        ApplicationId = source.ApplicationId,
     195        //        UserId = source.UserId,
     196        //        Password = source.Password,
     197        //        PasswordAnswer = source.PasswordAnswer,
     198        //        PasswordSalt = source.PasswordSalt,
     199        //        PasswordQuestion = source.PasswordQuestion,
    144200               
    145                 Email = source.Email,
    146                 LoweredEmail = source.LoweredEmail,
    147                 IsApproved = source.IsApproved,
    148                 IsLockedOut = source.IsLockedOut,
    149                 CreateDate = source.CreateDate,
    150                 LastLoginDate = source.LastLoginDate,
    151                 LastPasswordChangedDate = source.LastPasswordChangedDate,
    152                 LastLockoutDate = source.LastLockoutDate,
    153                 Comment = source.Comment
     201        //        Email = source.Email,
     202        //        LoweredEmail = source.LoweredEmail,
     203        //        IsApproved = source.IsApproved,
     204        //        IsLockedOut = source.IsLockedOut,
     205        //        CreateDate = source.CreateDate,
     206        //        LastLoginDate = source.LastLoginDate,
     207        //        LastPasswordChangedDate = source.LastPasswordChangedDate,
     208        //        LastLockoutDate = source.LastLockoutDate,
     209        //        Comment = source.Comment
    154210
    155211               
    156             };
    157         }
    158 
    159         /// <summary>
    160         /// converts data access object to data transfer object
    161         /// </summary>
    162         /// <param name="source">data access object</param>
    163         /// <returns>data transfer object</returns>
    164         public static Membership ToDataTransfer(aspnet_Membership source)
    165         {
    166             if (source == null) return null;
    167             return new Membership()
    168             {
    169                 ApplicationId = source.ApplicationId,
    170                 UserId = source.UserId,
    171                 Password = source.Password,
    172                 PasswordAnswer = source.PasswordAnswer,
    173                 PasswordSalt = source.PasswordSalt,
    174                 PasswordQuestion = source.PasswordQuestion,
     212        //    };
     213        //}
     214
     215        ///// <summary>
     216        ///// converts data access object to data transfer object
     217        ///// </summary>
     218        ///// <param name="source">data access object</param>
     219        ///// <returns>data transfer object</returns>
     220        //public static Membership ToDataTransfer(aspnet_Membership source)
     221        //{
     222        //    if (source == null) return null;
     223        //    return new Membership()
     224        //    {
     225        //        ApplicationId = source.ApplicationId,
     226        //        UserId = source.UserId,
     227        //        Password = source.Password,
     228        //        PasswordAnswer = source.PasswordAnswer,
     229        //        PasswordSalt = source.PasswordSalt,
     230        //        PasswordQuestion = source.PasswordQuestion,
    175231               
    176                 Email = source.Email,
    177                 LoweredEmail = source.LoweredEmail,
    178                 IsApproved = source.IsApproved,
    179                 IsLockedOut = source.IsLockedOut,
    180                 CreateDate = source.CreateDate,
    181                 LastLoginDate = source.LastLoginDate,
    182                 LastPasswordChangedDate = source.LastPasswordChangedDate,
    183                 LastLockoutDate = source.LastLockoutDate,
    184                 Comment = source.Comment
    185             };
    186         }
    187 
    188         /// <summary>
    189         /// converts data transfer object to data access object
    190         /// </summary>
    191         /// <param name="source">data transfer object</param>
    192         /// <param name="target">data access object</param>
    193         public static void ToEntity(Membership source, aspnet_Membership target)
    194         {
    195             if ((source != null) && (target != null))
    196             {
    197                 target.ApplicationId = source.ApplicationId;
    198                 target.UserId = source.UserId;
    199                 target.Password = source.Password;
    200                 target.PasswordAnswer = source.PasswordAnswer;
    201                 target.PasswordSalt = source.PasswordSalt;
    202                 target.PasswordQuestion = source.PasswordQuestion;
     232        //        Email = source.Email,
     233        //        LoweredEmail = source.LoweredEmail,
     234        //        IsApproved = source.IsApproved,
     235        //        IsLockedOut = source.IsLockedOut,
     236        //        CreateDate = source.CreateDate,
     237        //        LastLoginDate = source.LastLoginDate,
     238        //        LastPasswordChangedDate = source.LastPasswordChangedDate,
     239        //        LastLockoutDate = source.LastLockoutDate,
     240        //        Comment = source.Comment
     241        //    };
     242        //}
     243
     244        ///// <summary>
     245        ///// converts data transfer object to data access object
     246        ///// </summary>
     247        ///// <param name="source">data transfer object</param>
     248        ///// <param name="target">data access object</param>
     249        //public static void ToEntity(Membership source, aspnet_Membership target)
     250        //{
     251        //    if ((source != null) && (target != null))
     252        //    {
     253        //        target.ApplicationId = source.ApplicationId;
     254        //        target.UserId = source.UserId;
     255        //        target.Password = source.Password;
     256        //        target.PasswordAnswer = source.PasswordAnswer;
     257        //        target.PasswordSalt = source.PasswordSalt;
     258        //        target.PasswordQuestion = source.PasswordQuestion;
    203259               
    204                 target.Email = source.Email;
    205                 target.LoweredEmail = source.LoweredEmail;
    206                 target.IsApproved = source.IsApproved;
    207                 target.IsLockedOut = source.IsLockedOut;
    208                 target.CreateDate = source.CreateDate;
    209                 target.LastLoginDate = source.LastLoginDate;
    210                 target.LastPasswordChangedDate = source.LastPasswordChangedDate;
    211                 target.LastLockoutDate = source.LastLockoutDate;
    212                 target.Comment = source.Comment;
    213             }
    214 
    215         }
     260        //        target.Email = source.Email;
     261        //        target.LoweredEmail = source.LoweredEmail;
     262        //        target.IsApproved = source.IsApproved;
     263        //        target.IsLockedOut = source.IsLockedOut;
     264        //        target.CreateDate = source.CreateDate;
     265        //        target.LastLoginDate = source.LastLoginDate;
     266        //        target.LastPasswordChangedDate = source.LastPasswordChangedDate;
     267        //        target.LastLockoutDate = source.LastLockoutDate;
     268        //        target.Comment = source.Comment;
     269        //    }
     270
     271        //}
    216272
    217273        #endregion
     
    219275        #region Role
    220276
    221         /// <summary>
    222         /// converts data transfer object to data access objet
    223         /// </summary>
    224         /// <param name="source">data transfer object</param>
    225         /// <returns>data access object</returns>
    226         public static aspnet_Role ToEntity(Role source)
    227         {
    228             if (source == null) return null;
    229             return new aspnet_Role()
    230             {
    231                 ApplicationId = source.ApplicationId,
    232                 RoleId = source.RoleId,
    233                 RoleName = source.RoleName,
    234                 LoweredRoleName = source.LoweredRoleName,
    235                 Description = source.Description
    236             };
    237         }
    238 
    239         /// <summary>
    240         /// converts data access object to data transfer object
    241         /// </summary>
    242         /// <param name="source">data access object</param>
    243         /// <returns>data transfer object</returns>
    244         public static Role ToDataTransfer(aspnet_Role source)
    245         {
    246             if (source == null) return null;
    247             return new Role()
    248             {
    249                 ApplicationId = source.ApplicationId,
    250                 RoleId = source.RoleId,
    251                 RoleName = source.RoleName,
    252                 LoweredRoleName = source.LoweredRoleName,
    253                 Description = source.Description
    254             };
    255         }
    256 
    257         /// <summary>
    258         /// converts data transfer object to data access object
    259         /// </summary>
    260         /// <param name="source">data transfer object</param>
    261         /// <param name="target">data access object</param>
    262         public static void ToEntity(Role source, aspnet_Role target)
    263         {
    264             if ((source != null) && (target != null))
    265             {
    266                 target.ApplicationId = source.ApplicationId;
    267                 target.RoleId = source.RoleId;
    268                 target.RoleName = source.RoleName;
    269                 target.LoweredRoleName = source.LoweredRoleName;
    270                 target.Description = source.Description;
    271             }
    272 
    273         }
     277        ///// <summary>
     278        ///// converts data transfer object to data access objet
     279        ///// </summary>
     280        ///// <param name="source">data transfer object</param>
     281        ///// <returns>data access object</returns>
     282        //public static aspnet_Role ToEntity(Role source)
     283        //{
     284        //    if (source == null) return null;
     285        //    return new aspnet_Role()
     286        //    {
     287        //        ApplicationId = source.ApplicationId,
     288        //        RoleId = source.RoleId,
     289        //        RoleName = source.RoleName,
     290        //        LoweredRoleName = source.LoweredRoleName,
     291        //        Description = source.Description
     292        //    };
     293        //}
     294
     295        ///// <summary>
     296        ///// converts data access object to data transfer object
     297        ///// </summary>
     298        ///// <param name="source">data access object</param>
     299        ///// <returns>data transfer object</returns>
     300        //public static Role ToDataTransfer(aspnet_Role source)
     301        //{
     302        //    if (source == null) return null;
     303        //    return new Role()
     304        //    {
     305        //        ApplicationId = source.ApplicationId,
     306        //        RoleId = source.RoleId,
     307        //        RoleName = source.RoleName,
     308        //        LoweredRoleName = source.LoweredRoleName,
     309        //        Description = source.Description
     310        //    };
     311        //}
     312
     313        ///// <summary>
     314        ///// converts data transfer object to data access object
     315        ///// </summary>
     316        ///// <param name="source">data transfer object</param>
     317        ///// <param name="target">data access object</param>
     318        //public static void ToEntity(Role source, aspnet_Role target)
     319        //{
     320        //    if ((source != null) && (target != null))
     321        //    {
     322        //        target.ApplicationId = source.ApplicationId;
     323        //        target.RoleId = source.RoleId;
     324        //        target.RoleName = source.RoleName;
     325        //        target.LoweredRoleName = source.LoweredRoleName;
     326        //        target.Description = source.Description;
     327        //    }
     328
     329        //}
    274330
    275331        #endregion
  • branches/UserManagement/HeuristicLab.Services.Authentication/Interfaces/IAuthenticationService.cs

    r4726 r4740  
    1515        User GetUser(Guid id);
    1616
    17         [OperationContract]
    18         User GetUser(Guid applicationId, string userName);
     17        //[OperationContract]
     18        //User GetUser(Guid applicationId, string userName);
    1919
    20         [OperationContract]
    21         IEnumerable<User> GetUsers(Guid applicationId);
     20        //[OperationContract]
     21        //IEnumerable<User> GetUsers(Guid applicationId);
    2222
    23         [OperationContract]
    24         bool InsertUser(User user);
     23        //[OperationContract]
     24        //bool InsertUser(User user);
    2525
    26         [OperationContract]
    27         bool DeleteUser(Guid id);
     26        //[OperationContract]
     27        //bool DeleteUser(Guid id);
    2828
    29         [OperationContract]
    30         bool UpdateUser(User user);
     29        //[OperationContract]
     30        //bool UpdateUser(User user);
    3131
    32         [OperationContract]
    33         bool AddUserToRole(Guid roleId, Guid userId);
     32        //[OperationContract]
     33        //bool AddUserToRole(Guid roleId, Guid userId);
    3434
    35         [OperationContract]
    36         bool RemoveUserFromRole(Guid roleId, Guid userId);
     35        //[OperationContract]
     36        //bool RemoveUserFromRole(Guid roleId, Guid userId);
    3737
    38         [OperationContract]
    39         IEnumerable<Role> GetRolesForUser(Guid userId);
     38        //[OperationContract]
     39        //IEnumerable<Role> GetRolesForUser(Guid userId);
    4040
    4141        #endregion
     
    4343        #region Role
    4444
    45         [OperationContract]
    46         Role GetRole(Guid id);
     45        //[OperationContract]
     46        //Role GetRole(Guid id);
    4747       
    48         [OperationContract]
    49         Role GetRole(Guid applicationId, string roleName);
     48        //[OperationContract]
     49        //Role GetRole(Guid applicationId, string roleName);
    5050
    51         [OperationContract]
    52         IEnumerable<Role> GetRoles(Guid applicationId);
     51        //[OperationContract]
     52        //IEnumerable<Role> GetRoles(Guid applicationId);
    5353
    54         [OperationContract]
    55         bool RoleExists(Guid roleId);
     54        //[OperationContract]
     55        //bool RoleExists(Guid roleId);
    5656
    57         [OperationContract]
    58         bool IsUserInRole(Guid roleId, Guid userId);
     57        //[OperationContract]
     58        //bool IsUserInRole(Guid roleId, Guid userId);
    5959       
    60         [OperationContract]
    61         bool InsertRole(Role role);
     60        //[OperationContract]
     61        //bool InsertRole(Role role);
    6262
    63         [OperationContract]
    64         bool UpdateRole(Role role);
     63        //[OperationContract]
     64        //bool UpdateRole(Role role);
    6565
    66         [OperationContract]
    67         bool DeleteRole(Guid id);
     66        //[OperationContract]
     67        //bool DeleteRole(Guid id);
    6868
    69         [OperationContract]
    70         IEnumerable<User> GetUsersInRole(Guid roleId);
     69        //[OperationContract]
     70        //IEnumerable<User> GetUsersInRole(Guid roleId);
    7171       
    7272        #endregion
     
    7474        #region Application
    7575
    76         [OperationContract]
    77         Application GetApplication(Guid id);
     76        //[OperationContract]
     77        //Application GetApplication(Guid id);
    7878
    79         [OperationContract]
    80         Application InsertApplication(Application application);
     79        //[OperationContract]
     80        //Application InsertApplication(Application application);
    8181
    82         [OperationContract]
    83         bool DeleteApplication(Application application);
     82        //[OperationContract]
     83        //bool DeleteApplication(Application application);
    8484
    85         [OperationContract]
    86         IEnumerable<DataTransfer.Application> GetApplications();
     85        // [OperationContract]
     86        //IEnumerable<DataTransfer.Application> GetApplications();
    8787
    8888        #endregion
     
    9090        #region Membership
    9191
    92         [OperationContract]
    93         Membership InsertMembership(Membership membership);
     92        //[OperationContract]
     93        //Membership InsertMembership(Membership membership);
    9494
    9595        #endregion
Note: See TracChangeset for help on using the changeset viewer.