Skip to content

Commit

Permalink
Created IUserInfo and modified classes to support.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobK410 committed Feb 7, 2024
1 parent ad63295 commit 677c1b4
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/Security/ISubjectIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ namespace Talegen.Common.Models.Security
/// <summary>
/// This interface implements the minimum properties for identification
/// </summary>
public interface ISubjectIdentity
public interface ISubjectIdentity<TKey>
{
/// <summary>
/// Gets the subject identity.
/// Gets or sets the unique identity of the subject.
/// </summary>
Guid Id { get; set; }
TKey Id { get; set; }

/// <summary>
/// Gets the subject name.
/// Gets or sets the name of the subject.
/// </summary>
string Name { get; set; }
}
Expand Down
45 changes: 45 additions & 0 deletions src/Security/IUserInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
*
* (c) Copyright Talegen, LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

namespace Talegen.Common.Models.Security
{
/// <summary>
/// This interface defines the minimum implementation of a user information object.
/// </summary>
/// <typeparam name="TKey">Contains the type of the user identifier.</typeparam>
public interface IUserInfo<TKey> : ISubjectIdentity<TKey>
{
/// <summary>
/// Gets or sets the user email address.
/// </summary>
string Email { get; set; }

/// <summary>
/// Gets or sets the user first name.
/// </summary>
string FirstName { get; set; }

/// <summary>
/// Gets or sets the user last name.
/// </summary>
string LastName { get; set; }

/// <summary>
/// Gets the full name of the user.
/// </summary>
string FullName { get; }
}
}
4 changes: 2 additions & 2 deletions src/Security/MicroRoleModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Talegen.Common.Models.Security
/// <summary>
/// This class contains the bare minimum properties to represent a role in the interface.
/// </summary>
public class MicroRoleModel : ISubjectIdentity
public class MicroRoleModel : ISubjectIdentity<Guid>
{
/// <summary>
/// Gets or sets the role identifier.
Expand All @@ -35,6 +35,6 @@ public class MicroRoleModel : ISubjectIdentity
/// </summary>
/// <value>The name.</value>
[Required]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
}
}
14 changes: 9 additions & 5 deletions src/Security/MicroUserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Talegen.Common.Models.Security
/// <summary>
/// This class contains the bare minimum properties to represent a user in the interface.
/// </summary>
public class MicroUserModel : ISubjectIdentity
public class MicroUserModel : IUserInfo<Guid>
{
/// <summary>
/// Gets or sets the unique identity of the user.
Expand All @@ -33,27 +33,31 @@ public class MicroUserModel : ISubjectIdentity
/// Gets or sets the user name of the user.
/// </summary>
[StringLength(100)]
public string Name { get; set; }
[Required]
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the user's e-mail address.
/// </summary>
[StringLength(100)]
public string Email { get; set; }
[Required]
public string Email { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the first name.
/// </summary>
/// <value>The first name.</value>
[StringLength(100)]
public string FirstName { get; set; }
[Required]
public string FirstName { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the last name.
/// </summary>
/// <value>The last name.</value>
[StringLength(100)]
public string LastName { get; set; }
[Required]
public string LastName { get; set; } = string.Empty;

/// <summary>
/// Gets the user full name.
Expand Down
2 changes: 1 addition & 1 deletion src/Security/MinimalRoleModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MinimalRoleModel : MicroRoleModel
/// <summary>
/// Gets or sets the role description.
/// </summary>
public string Description { get; set; }
public string? Description { get; set; }

/// <summary>
/// Gets or sets the type of the role.
Expand Down
4 changes: 2 additions & 2 deletions src/Security/MinimalUserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class MinimalUserModel : MicroUserModel
/// <summary>
/// Gets or sets the user's desired language.
/// </summary>
public string Locale { get; set; }
public string? Locale { get; set; }

/// <summary>
/// Gets or sets the user's time zone.
/// </summary>
public string TimeZone { get; set; }
public string? TimeZone { get; set; }

/// <summary>
/// Gets a value indicating whether the user is locked.
Expand Down
6 changes: 3 additions & 3 deletions src/Security/UserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class UserModel : MinimalUserModel
/// <summary>
/// Gets or sets the user model for the creator user.
/// </summary>
public MinimalUserModel CreatedBy { get; set; }
public MinimalUserModel? CreatedBy { get; set; }

/// <summary>
/// Gets or sets the date time when the account was last updated.
Expand All @@ -42,12 +42,12 @@ public class UserModel : MinimalUserModel
/// <summary>
/// Gets or sets the user model for the updating user.
/// </summary>
public MinimalUserModel UpdatedBy { get; set; }
public MinimalUserModel? UpdatedBy { get; set; }

/// <summary>
/// Gets or sets the user notes.
/// </summary>
public string Notes { get; set; }
public string? Notes { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the user account is active.
Expand Down
4 changes: 2 additions & 2 deletions src/Server/MicroCreatedUpdaterModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class MicroCreatedUpdaterModelBase
/// <summary>
/// Gets or sets the record creator model object.
/// </summary>
public ISubjectIdentity? CreatedBy { get; set; }
public ISubjectIdentity<Guid>? CreatedBy { get; set; }

/// <summary>
/// Gets or sets the record last updated date time.
Expand All @@ -42,6 +42,6 @@ public abstract class MicroCreatedUpdaterModelBase
/// <summary>
/// Gets or sets the record updater model object.
/// </summary>
public ISubjectIdentity? UpdatedBy { get; set; }
public ISubjectIdentity<Guid>? UpdatedBy { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/Server/TimeZoneModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Talegen.Common.Models.Server
using System.ComponentModel.DataAnnotations;

/// <summary>
/// This class represents a timezone model within an application.
/// This class represents a time zone model within an application.
/// </summary>
/// <seealso cref="Talegen.Common.Models.Server.MinimalTimeZoneModel" />
public class TimeZoneModel : MinimalTimeZoneModel
Expand All @@ -28,7 +28,7 @@ public class TimeZoneModel : MinimalTimeZoneModel
/// Gets or sets the long name of the time zone.
/// </summary>
[MaxLength(300)]
public string LongName { get; set; }
public string? LongName { get; set; }

/// <summary>
/// Gets or sets the numeric time offset.
Expand Down
2 changes: 1 addition & 1 deletion src/Talegen.Common.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReleaseNotes>Updated packages and made minor changes to pagination results model to support query info and long total count.</PackageReleaseNotes>
<ApplicationIcon>Assets\logo.ico</ApplicationIcon>
<SignAssembly>false</SignAssembly>
<Version>1.0.11.0</Version>
<Version>1.0.12.0</Version>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
<Title>Talegen.Common.Models</Title>
Expand Down
38 changes: 32 additions & 6 deletions src/Talegen.Common.Models.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 677c1b4

Please sign in to comment.