start working on security group view
This commit is contained in:
@ -5,9 +5,6 @@ namespace UserService.Infrastructure.DataModels
|
||||
{
|
||||
public abstract class Member : Node
|
||||
{
|
||||
[EmailAddress]
|
||||
public string? EMail { get; set; }
|
||||
|
||||
public ICollection<UserMember> Members { get; set; } = new List<UserMember>();
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
|
||||
namespace UserService.Infrastructure.DataModels
|
||||
{
|
||||
@ -7,7 +9,10 @@ namespace UserService.Infrastructure.DataModels
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
|
||||
[EmailAddress]
|
||||
public string? EMail { get; set; }
|
||||
|
||||
public string FullName => $"{FirstName} {LastName}";
|
||||
|
||||
public IEnumerable<UserMember> MemberOf { get; set; } = new List<UserMember>();
|
||||
|
23
UserService.Infrastructure/NodeExtensions.cs
Normal file
23
UserService.Infrastructure/NodeExtensions.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UserService.Infrastructure.DataModels;
|
||||
|
||||
namespace UserService.Infrastructure
|
||||
{
|
||||
public static class NodeExtensions
|
||||
{
|
||||
public static void MapFields(this User user, Dictionary<string, object> values)
|
||||
{
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (values == null) throw new ArgumentNullException(nameof(values));
|
||||
var properties = user.GetType().GetProperties();
|
||||
foreach (var keyValuePair in values)
|
||||
{
|
||||
var propertyInfo = properties.FirstOrDefault(x => x.Name == keyValuePair.Key);
|
||||
if (propertyInfo == null) continue;
|
||||
propertyInfo.SetValue(user, keyValuePair.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -7,13 +7,13 @@ namespace UserService.Infrastructure
|
||||
{
|
||||
public static class Validators
|
||||
{
|
||||
public static bool? ValidateEmail(string mailAddress)
|
||||
public static bool? ValidateEmail(string? mailAddress)
|
||||
{
|
||||
if (string.IsNullOrEmpty(mailAddress)) return null;
|
||||
return new EmailAddressAttribute().IsValid(mailAddress);
|
||||
}
|
||||
|
||||
public static bool? ValidateCommonName(string commonName, IReadOnlyList<User> users)
|
||||
public static bool? ValidateCommonName(string? commonName, IEnumerable<Member> users)
|
||||
{
|
||||
if (string.IsNullOrEmpty(commonName)) return false;
|
||||
return users.All(x => x.CommonName != commonName);
|
||||
|
Reference in New Issue
Block a user