Remove unused fat

This commit is contained in:
2024-10-20 14:10:36 -04:00
parent 28d74503df
commit 905d3747d2
48 changed files with 20 additions and 792 deletions

View File

@@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Hutopy.Application</RootNamespace>
<AssemblyName>Hutopy.Application</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ardalis.GuardClauses" />
<PackageReference Include="AutoMapper" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" />
<PackageReference Include="Google.Apis.Oauth2.v2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="MinimalApis.Extensions" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,12 +0,0 @@
namespace Hutopy.Domain.Common;
public abstract class BaseAuditableEntity : BaseEntity
{
public DateTimeOffset CreatedAt { get; set; }
public Guid? CreatedBy { get; set; }
public DateTimeOffset LastModifiedAt { get; set; }
public Guid? LastModifiedBy { get; set; }
}

View File

@@ -1,30 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Hutopy.Domain.Common;
public abstract class BaseEntity
{
// This can easily be modified to be BaseEntity<T> and public T Id to support different key types.
// Using non-generic integer types for simplicity
public Guid Id { get; set; }
private readonly List<BaseEvent> _domainEvents = [];
[NotMapped]
public IEnumerable<BaseEvent> DomainEvents => _domainEvents.AsReadOnly();
public void AddDomainEvent(BaseEvent domainEvent)
{
_domainEvents.Add(domainEvent);
}
public void RemoveDomainEvent(BaseEvent domainEvent)
{
_domainEvents.Remove(domainEvent);
}
public void ClearDomainEvents()
{
_domainEvents.Clear();
}
}

View File

@@ -1,7 +0,0 @@
using MediatR;
namespace Hutopy.Domain.Common;
public abstract class BaseEvent : INotification
{
}

View File

@@ -1,45 +0,0 @@
namespace Hutopy.Domain.Common;
// Learn more: https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/implement-value-objects
public abstract class ValueObject
{
private static bool EqualOperator(ValueObject left, ValueObject right)
{
if (left is null ^ right is null)
{
return false;
}
return left?.Equals(right!) != false;
}
protected static bool NotEqualOperator(ValueObject left, ValueObject right)
{
return !(EqualOperator(left, right));
}
protected abstract IEnumerable<object> GetEqualityComponents();
public override bool Equals(object? obj)
{
if (obj == null || obj.GetType() != GetType())
{
return false;
}
var other = (ValueObject)obj;
return GetEqualityComponents().SequenceEqual(other.GetEqualityComponents());
}
public override int GetHashCode()
{
var hash = new HashCode();
foreach (var component in GetEqualityComponents())
{
hash.Add(component);
}
return hash.ToHashCode();
}
}

View File

@@ -1,7 +0,0 @@
namespace Hutopy.Domain.Constants;
public abstract class Policies
{
public const string CanPurge = nameof(CanPurge);
public const string CanDelete = nameof(CanDelete);
}

View File

@@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Hutopy.Domain</RootNamespace>
<AssemblyName>Hutopy.Domain</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Apis.Oauth2.v2" />
<PackageReference Include="MediatR" />
</ItemGroup>
</Project>

View File

@@ -1,9 +0,0 @@
namespace Hutopy.Domain.Enums;
public enum PriorityLevel
{
None = 0,
Low = 1,
Medium = 2,
High = 3
}

View File

@@ -1,4 +0,0 @@
namespace Hutopy.Domain.Exceptions;
public class UnsupportedColourException(
string code) : Exception($"Colour \"{code}\" is unsupported.");

View File

@@ -1,2 +0,0 @@
global using Hutopy.Domain.Common;
global using Hutopy.Domain.Exceptions;

View File

@@ -1,69 +0,0 @@
namespace Hutopy.Domain.ValueObjects;
public class Colour(string code) : ValueObject
{
public static Colour From(string code)
{
var colour = new Colour(code);
if (!SupportedColours.Contains(colour))
{
throw new UnsupportedColourException(code);
}
return colour;
}
public static Colour White => new("#FFFFFF");
public static Colour Red => new("#FF5733");
public static Colour Orange => new("#FFC300");
public static Colour Yellow => new("#FFFF66");
public static Colour Green => new("#CCFF99");
public static Colour Blue => new("#6666FF");
public static Colour Purple => new("#9966CC");
public static Colour Grey => new("#999999");
public string Code { get; private set; } = string.IsNullOrWhiteSpace(code)?"#000000":code;
public static implicit operator string(Colour colour)
{
return colour.ToString();
}
public static explicit operator Colour(string code)
{
return From(code);
}
public override string ToString()
{
return Code;
}
private static IEnumerable<Colour> SupportedColours
{
get
{
yield return White;
yield return Red;
yield return Orange;
yield return Yellow;
yield return Green;
yield return Blue;
yield return Purple;
yield return Grey;
}
}
protected override IEnumerable<object> GetEqualityComponents()
{
yield return Code;
}
}

View File

@@ -4,7 +4,7 @@ using Azure.Storage.Blobs.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace Hutopy.Infrastructure.AzureBlob;
namespace Hutopy.Infrastructure.BlobStorage;
public class AzureBlobStorage
{

View File

@@ -1,4 +1,4 @@
namespace Hutopy.Application.AzureBlobStorage.Constants;
namespace Hutopy.Infrastructure.BlobStorage;
public static class CommonFileNames
{

View File

@@ -1,4 +1,4 @@
namespace Hutopy.Application.AzureBlobStorage.Constants;
namespace Hutopy.Infrastructure.BlobStorage;
public static class ContainerNames
{

View File

@@ -1,4 +1,4 @@
namespace Hutopy.Infrastructure.AzureBlob;
namespace Hutopy.Infrastructure.BlobStorage;
public static class ContentTypes
{

View File

@@ -1,4 +1,4 @@
namespace Hutopy.Application.AzureBlobStorage.Constants;
namespace Hutopy.Infrastructure.BlobStorage;
public static class SubDirectoryNames
{

View File

@@ -1,5 +1,4 @@
using Hutopy.Domain.Constants;
using Hutopy.Infrastructure.Identity;
using Hutopy.Infrastructure.Identity;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
@@ -55,13 +54,13 @@ public class ApplicationDbContextInitializer(
private async Task TrySeedAsync()
{
var administratorRole = new ApplicationRole(Roles.Administrator);
var administratorRole = new ApplicationRole(KnownRoles.Administrator);
if (roleManager.Roles.All(r => r.Name != administratorRole.Name))
{
await roleManager.CreateAsync(administratorRole);
}
var roleCreator = new ApplicationRole(Roles.Creator);
var roleCreator = new ApplicationRole(KnownRoles.Creator);
if (roleManager.Roles.All(r => r.Name != roleCreator.Name))
{
await roleManager.CreateAsync(roleCreator);

View File

@@ -1,5 +1,4 @@
using Hutopy.Domain.Constants;
using Hutopy.Infrastructure.AzureBlob;
using Hutopy.Infrastructure.BlobStorage;
using Hutopy.Infrastructure.Data;
using Hutopy.Infrastructure.Identity;
using Microsoft.AspNetCore.Identity;
@@ -49,9 +48,6 @@ public static class DependencyInjection
// Scoped services
services.AddScoped<IdentityService>();
services.AddAuthorization(options =>
options.AddPolicy(Policies.CanPurge, policy => policy.RequireRole(Roles.Administrator)));
return services;
}
}

View File

@@ -1,6 +1,6 @@
namespace Hutopy.Domain.Constants;
namespace Hutopy.Infrastructure.Identity;
public abstract class Roles
public static class KnownRoles
{
public const string Administrator = nameof(Administrator);
public const string Creator = nameof(Creator);

View File

@@ -18,9 +18,6 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"/>
<PackageReference Include="Stripe.net"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj"/>
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\"/>
</ItemGroup>

View File

@@ -1,5 +1,4 @@
using Hutopy.Application.AzureBlobStorage.Constants;
using Hutopy.Infrastructure.AzureBlob;
using Hutopy.Infrastructure.BlobStorage;
using Hutopy.Web.Features.Contents.Data;
namespace Hutopy.Web.Features.Contents.Handlers;

View File

@@ -1,5 +1,4 @@
using Hutopy.Application.AzureBlobStorage.Constants;
using Hutopy.Infrastructure.AzureBlob;
using Hutopy.Infrastructure.BlobStorage;
using Hutopy.Web.Features.Contents.Data;
namespace Hutopy.Web.Features.Contents.Handlers;

View File

@@ -1,6 +1,5 @@
using System.Collections.Concurrent;
using Hutopy.Application.AzureBlobStorage.Constants;
using Hutopy.Infrastructure.AzureBlob;
using Hutopy.Infrastructure.BlobStorage;
using Hutopy.Web.Common;
using Hutopy.Web.Features.Contents.Data;
using Hutopy.Web.Features.Contents.Handlers.Models;

View File

@@ -1,5 +1,4 @@
using Hutopy.Application.AzureBlobStorage.Constants;
using Hutopy.Infrastructure.AzureBlob;
using Hutopy.Infrastructure.BlobStorage;
using Hutopy.Infrastructure.Identity;
using Hutopy.Web.Common;

View File

@@ -1,5 +1,4 @@
using Hutopy.Application.AzureBlobStorage.Constants;
using Hutopy.Infrastructure.AzureBlob;
using Hutopy.Infrastructure.BlobStorage;
using Hutopy.Infrastructure.Identity;
namespace Hutopy.Web.Features.Users.Handlers;

View File

@@ -30,8 +30,7 @@ public class GoogleUserInfo
[PublicAPI]
public record LoginWithGoogleRequest(
string Token)
: IRequest<LoginWithGoogleResponse>;
string Token);
public record LoginWithGoogleResponse(
string AccessToken,

View File

@@ -1,6 +1,4 @@
global using Ardalis.GuardClauses;
global using FastEndpoints;
global using FluentValidation;
global using JetBrains.Annotations;
global using MediatR;
global using Microsoft.EntityFrameworkCore;

View File

@@ -1,5 +1,4 @@
using Azure.Identity;
using Hutopy.Application;
using Hutopy.Infrastructure;
using Hutopy.Infrastructure.Data;
using Hutopy.Infrastructure.Identity;

View File

@@ -1,5 +1,4 @@
using Hutopy.Domain.Constants;
using Hutopy.Infrastructure.Identity;
using Hutopy.Infrastructure.Identity;
using Hutopy.Web.Common;
using Hutopy.Web.Features.Contents.Data;
using Hutopy.Web.Features.Messages.Data;
@@ -34,7 +33,7 @@ internal class TestDataSeeder(
{
if (contentContext.Contents.Any()) return;
_users.Add(await CreateUserAsync("admin", null, Roles.Administrator));
_users.Add(await CreateUserAsync("admin", null, KnownRoles.Administrator));
var userA = await CreateUserAsync("userA", null);
_users.Add(userA);
_users.Add(await CreateUserAsync("userB", null));
@@ -44,7 +43,7 @@ internal class TestDataSeeder(
var creatorUser = await CreateUserAsync(
creator.Name,
creator.Images.Logo,
Roles.Creator);
KnownRoles.Creator);
creator.Id = creatorUser.Id;
creator.CreatedBy = creator.Id;

View File

@@ -7,7 +7,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>