Created Woodpecker CI/CD deployment

- Created Dockerfile for packing up API and Web projects as Docker image
This commit is contained in:
2023-03-27 21:48:25 -05:00
parent baf38aa3cd
commit a5d5ed048f
145 changed files with 30973 additions and 18248 deletions

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
namespace YABA.Common.Extensions
{
public static class DictionaryExtensions
{
public static void AddRange<K, V>(this Dictionary<K, V> source, Dictionary<K, V> collection)
{
if (collection == null)
{
throw new ArgumentNullException("Collection is null");
}
foreach (var item in collection)
{
if (!source.ContainsKey(item.Key))
{
source.Add(item.Key, item.Value);
}
}
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using YABA.Common.Attributes;
using YABA.Common.Lookups;
namespace YABA.Common.Extensions
{
public static class EnumExtensions
{
private static readonly IEnumerable<CrudResultLookup> SuccessfulCrudStatuses = new List<CrudResultLookup>() {
CrudResultLookup.CreateSucceeded,
CrudResultLookup.UpdateSucceeded,
CrudResultLookup.DeleteSucceeded,
CrudResultLookup.RetrieveSuccessful
};
public static TAttribute GetAttribute<TAttribute>(this Enum value) where TAttribute : Attribute
{
var enumType = value.GetType();
var name = Enum.GetName(enumType, value);
return enumType.GetField(name).GetCustomAttributes(false).OfType<TAttribute>().SingleOrDefault();
}
public static string GetDisplayName(this Enum enumValue)
{
return enumValue.GetAttribute<DisplayAttribute>().Name;
}
public static string GetClaimName(this ClaimsLookup claimLookup)
{
return claimLookup.GetAttribute<ClaimNameAttribute>().Name;
}
public static bool IsCrudResultSuccessful(this CrudResultLookup importStatusLookup) => SuccessfulCrudStatuses.Contains(importStatusLookup);
public static bool IsCrudResultFailure(this CrudResultLookup importStatusLookup) => !SuccessfulCrudStatuses.Contains(importStatusLookup);
}
}

View File

@ -0,0 +1,18 @@
using System.Security.Claims;
using System.Security.Principal;
using YABA.Common.Lookups;
namespace YABA.Common.Extensions
{
public static class UserIdentityExtensions
{
public static string GetUserId(this IIdentity identity) => GetCustomClaim(identity, ClaimsLookup.UserId);
public static string GetAuthProviderId(this IIdentity identity) => GetCustomClaim(identity, ClaimsLookup.AuthProviderId);
public static string GetCustomClaim(this IIdentity identity, ClaimsLookup claim)
{
var claimsIdentity = identity as ClaimsIdentity;
return claimsIdentity.FindFirst(claim.GetClaimName())?.Value.ToString();
}
}
}