Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d3dfa4f
Initial commit
SingleUnitBox Nov 10, 2024
64017e1
add Brewery Layers .Api .Infrastructure, .Application, .Domain
SingleUnitBox Nov 10, 2024
6f7a475
add project references
SingleUnitBox Nov 10, 2024
32d358b
add Beer, Brewer, Brewery, Wholesaler
SingleUnitBox Nov 10, 2024
18ea2c4
add ICommand, ICommandHandler, ICommandDispatcher
SingleUnitBox Nov 11, 2024
4e6cc5b
add Migrations, CQRS
SingleUnitBox Nov 12, 2024
e67694a
add BeerQueries and Commands
SingleUnitBox Nov 13, 2024
2853c16
add BeerController, UpdateBeerHandler
SingleUnitBox Nov 13, 2024
86b3378
add ExceptionMiddleware
SingleUnitBox Nov 13, 2024
e60a836
edit Wholesaler
SingleUnitBox Nov 14, 2024
3ccec29
add Sale, Wholesaler, Repositories, Exceptions, Commands
SingleUnitBox Nov 14, 2024
72ec7d6
add BeerStock, Repository, CommandHandler
SingleUnitBox Nov 15, 2024
9ad0221
add DTOs, Queries, Commands
SingleUnitBox Nov 16, 2024
d5f7de8
add Brewery.Tests.EndToEnd.AddBeerTests
SingleUnitBox Nov 17, 2024
c56a806
Create README.md
SingleUnitBox Nov 17, 2024
778188c
Update README.md
SingleUnitBox Nov 17, 2024
a46dbcd
Update README.md
SingleUnitBox Nov 17, 2024
7f9b874
add Auth using jwt
SingleUnitBox Nov 19, 2024
11fa2f7
add RabbitMq to handle Auth
SingleUnitBox Nov 20, 2024
97a5ec9
BackgroundConsumer
SingleUnitBox Nov 21, 2024
b9407ef
edit AccountController
SingleUnitBox Nov 22, 2024
6cb32ec
add IConnectionFactory
SingleUnitBox Nov 23, 2024
ee19221
add ConnectionManager
SingleUnitBox Nov 23, 2024
1f474a1
add BreweryUnitOfWork
SingleUnitBox Nov 24, 2024
ed22ece
resolve conflicts between Brewery and CodeReviews
SingleUnitBox Nov 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# User-specific files
*.rsuser

*.suo
*.user
*.userosscache
Expand All @@ -13,8 +14,6 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Mono auto generated files
mono_crash.*

# Build results
[Dd]ebug/
Expand All @@ -23,14 +22,12 @@ mono_crash.*
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/

bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/


# Visual Studio 2015/2017 cache/options directory
.vs/
Expand All @@ -44,10 +41,7 @@ Generated\ Files/
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml


# Build Results of an ATL Project
[Dd]ebugPS/
Expand All @@ -68,13 +62,13 @@ artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt


# StyleCop
StyleCopReport.xml

# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
Expand Down Expand Up @@ -197,8 +191,6 @@ PublishScripts/

# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
Expand All @@ -223,14 +215,13 @@ BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload


# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/


# Others
ClientBin/
Expand All @@ -239,11 +230,13 @@ ClientBin/
*.dbmdl
*.dbproj.schemaview
*.jfm

*.pfx
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk

# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -274,9 +267,7 @@ ServiceFabricBackup/
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl


# Microsoft Fakes
FakesAssemblies/
Expand Down Expand Up @@ -323,8 +314,13 @@ paket-files/
# FAKE - F# Make
.fake/

# CodeRush personal settings
.cr/personal

# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/

# Python Tools for Visual Studio (PTVS)
__pycache__/
Expand All @@ -349,7 +345,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output

ASALocalRun/

# MSBuild Binary and Structured Log
Expand Down Expand Up @@ -475,3 +471,4 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

65 changes: 65 additions & 0 deletions Brewery.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{13BABC4E-2013-45BE-B5F2-37374813BFF3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FD1F28D7-23D0-4225-814C-549E308E4C9D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brewery.Api", "src\Brewery.Api\Brewery.Api.csproj", "{CE3C015E-3E32-4BB5-9F0B-1BD36FAF8DBC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brewery.Domain", "src\Brewery.Domain\Brewery.Domain.csproj", "{89613C40-A24A-4972-909F-8E840056349A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brewery.Application", "src\Brewery.Application\Brewery.Application.csproj", "{6DA2F545-AD92-4EF3-8638-D42F1F8C5833}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brewery.Infrastructure", "src\Brewery.Infrastructure\Brewery.Infrastructure.csproj", "{F0FFE48E-371C-423C-9DB7-22BF810F6AA4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brewery.Abstractions", "src\Brewery.Abstractions\Brewery.Abstractions.csproj", "{AD694077-201B-49C3-9537-FE96BA598E82}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brewery.Tests.Shared", "tests\Brewery.Tests.Shared\Brewery.Tests.Shared.csproj", "{8EDE4ED9-E7AB-4DAB-983D-B2870AED0C60}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brewery.Tests.EndToEnd", "tests\Brewery.Tests.EndToEnd\Brewery.Tests.EndToEnd.csproj", "{667A8402-FC19-406C-9BCA-4D194D1AD257}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CE3C015E-3E32-4BB5-9F0B-1BD36FAF8DBC} = {13BABC4E-2013-45BE-B5F2-37374813BFF3}
{89613C40-A24A-4972-909F-8E840056349A} = {13BABC4E-2013-45BE-B5F2-37374813BFF3}
{6DA2F545-AD92-4EF3-8638-D42F1F8C5833} = {13BABC4E-2013-45BE-B5F2-37374813BFF3}
{F0FFE48E-371C-423C-9DB7-22BF810F6AA4} = {13BABC4E-2013-45BE-B5F2-37374813BFF3}
{AD694077-201B-49C3-9537-FE96BA598E82} = {13BABC4E-2013-45BE-B5F2-37374813BFF3}
{8EDE4ED9-E7AB-4DAB-983D-B2870AED0C60} = {FD1F28D7-23D0-4225-814C-549E308E4C9D}
{667A8402-FC19-406C-9BCA-4D194D1AD257} = {FD1F28D7-23D0-4225-814C-549E308E4C9D}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CE3C015E-3E32-4BB5-9F0B-1BD36FAF8DBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE3C015E-3E32-4BB5-9F0B-1BD36FAF8DBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE3C015E-3E32-4BB5-9F0B-1BD36FAF8DBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE3C015E-3E32-4BB5-9F0B-1BD36FAF8DBC}.Release|Any CPU.Build.0 = Release|Any CPU
{89613C40-A24A-4972-909F-8E840056349A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89613C40-A24A-4972-909F-8E840056349A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89613C40-A24A-4972-909F-8E840056349A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89613C40-A24A-4972-909F-8E840056349A}.Release|Any CPU.Build.0 = Release|Any CPU
{6DA2F545-AD92-4EF3-8638-D42F1F8C5833}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DA2F545-AD92-4EF3-8638-D42F1F8C5833}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DA2F545-AD92-4EF3-8638-D42F1F8C5833}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DA2F545-AD92-4EF3-8638-D42F1F8C5833}.Release|Any CPU.Build.0 = Release|Any CPU
{F0FFE48E-371C-423C-9DB7-22BF810F6AA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0FFE48E-371C-423C-9DB7-22BF810F6AA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0FFE48E-371C-423C-9DB7-22BF810F6AA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0FFE48E-371C-423C-9DB7-22BF810F6AA4}.Release|Any CPU.Build.0 = Release|Any CPU
{AD694077-201B-49C3-9537-FE96BA598E82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD694077-201B-49C3-9537-FE96BA598E82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD694077-201B-49C3-9537-FE96BA598E82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD694077-201B-49C3-9537-FE96BA598E82}.Release|Any CPU.Build.0 = Release|Any CPU
{8EDE4ED9-E7AB-4DAB-983D-B2870AED0C60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8EDE4ED9-E7AB-4DAB-983D-B2870AED0C60}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8EDE4ED9-E7AB-4DAB-983D-B2870AED0C60}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8EDE4ED9-E7AB-4DAB-983D-B2870AED0C60}.Release|Any CPU.Build.0 = Release|Any CPU
{667A8402-FC19-406C-9BCA-4D194D1AD257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{667A8402-FC19-406C-9BCA-4D194D1AD257}.Debug|Any CPU.Build.0 = Debug|Any CPU
{667A8402-FC19-406C-9BCA-4D194D1AD257}.Release|Any CPU.ActiveCfg = Release|Any CPU
{667A8402-FC19-406C-9BCA-4D194D1AD257}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Overview
Brewery is a RESTful API that enables breweries, wholesalers, and clients to manage and interact with a beer distribution system. The system supports functionalities for managing beer inventory, facilitating sales between brewers and wholesalers, and providing clients with quotes for bulk beer orders. The application is built using .NET Core and Entity Framework, with a focus on efficient data management and clear REST API principles.
7 changes: 7 additions & 0 deletions src/Brewery.Abstractions/Auth/IAuthManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Brewery.Abstractions.Auth;

public interface IAuthManager
{
JsonWebToken GenerateToken(string userId, string role, string audience = null,
IDictionary<string, IEnumerable<string>> claims = null);
}
12 changes: 12 additions & 0 deletions src/Brewery.Abstractions/Auth/JsonWebToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Brewery.Abstractions.Auth;

public class JsonWebToken
{
public string AccessToken { get; set; }
public string RefreshToken { get; set; }
public long Expires { get; set; }
public string Id { get; set; }
public string Role { get; set; }
public string Email { get; set; }
public IDictionary<string, IEnumerable<string>> Claims { get; set; }
}
13 changes: 13 additions & 0 deletions src/Brewery.Abstractions/Brewery.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App "/>
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions src/Brewery.Abstractions/Commands/ICommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Brewery.Abstractions.Messaging;

namespace Brewery.Abstractions.Commands;

public interface ICommand : IMessage
{

}

public interface ICommand<TResult> : ICommand;
6 changes: 6 additions & 0 deletions src/Brewery.Abstractions/Commands/ICommandDispatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Brewery.Abstractions.Commands;

public interface ICommandDispatcher
{
Task DispatchAsync<TCommand>(TCommand command) where TCommand : class, ICommand;
}
11 changes: 11 additions & 0 deletions src/Brewery.Abstractions/Commands/ICommandHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Brewery.Abstractions.Commands;

public interface ICommandHandler<TCommand> where TCommand : class, ICommand
{
Task HandleAsync(TCommand command);
}

public interface ICommandHandler<TCommand, TResult>
{
Task<TResult> HandleAsync(TCommand command);
}
8 changes: 8 additions & 0 deletions src/Brewery.Abstractions/Contexts/IContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Brewery.Abstractions.Contexts;

public interface IContext
{
string RequestId { get; }
string TraceId { get; }
IIdentityContext IdentityContext { get; }
}
6 changes: 6 additions & 0 deletions src/Brewery.Abstractions/Contexts/IContextFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Brewery.Abstractions.Contexts;

public interface IContextFactory
{
IContext Create();
}
11 changes: 11 additions & 0 deletions src/Brewery.Abstractions/Contexts/IIdentityContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Security.Claims;

namespace Brewery.Abstractions.Contexts;

public interface IIdentityContext
{
bool IsAuthenticated { get; }
Guid Id { get; }
string Role { get; }
Dictionary<string, IEnumerable<string>> Claims { get; }
}
11 changes: 11 additions & 0 deletions src/Brewery.Abstractions/Exceptions/BreweryException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Brewery.Abstractions.Exceptions;

public class BreweryException : Exception
{
public string Message { get; set; }

public BreweryException(string message)
{
Message = message;
}
}
6 changes: 6 additions & 0 deletions src/Brewery.Abstractions/Exceptions/ExceptionResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System.Net;

namespace Brewery.Abstractions.Exceptions;

public record ExceptionResponse(Error Error, HttpStatusCode HttpStatusCode);
public record Error(string Code, string Message);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Brewery.Abstractions.Exceptions;

public interface IExceptionToResponseMapper
{
ExceptionResponse Map(Exception exception);
}
6 changes: 6 additions & 0 deletions src/Brewery.Abstractions/Messaging/IMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Brewery.Abstractions.Messaging;

public interface IMessage
{

}
12 changes: 12 additions & 0 deletions src/Brewery.Abstractions/Messaging/IMessagePublisher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Brewery.Abstractions.Auth;

namespace Brewery.Abstractions.Messaging;

public interface IMessagePublisher
{
Task PublishAsync<TMessage>(TMessage message, string exchange)
where TMessage : class, IMessage;

Task<TResult> PublishAsync<TMessage, TResult>(TMessage message, string exchange)
where TMessage : class, IMessage where TResult : JsonWebToken;
}
6 changes: 6 additions & 0 deletions src/Brewery.Abstractions/Messaging/RabbitMqOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Brewery.Abstractions.Messaging;

public class RabbitMqOptions
{
public string HostName { get; set; }
}
6 changes: 6 additions & 0 deletions src/Brewery.Abstractions/Postgres/PostgresOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Brewery.Abstractions.Postgres;

public class PostgresOptions
{
public string ConnectionString { get; set; }
}
8 changes: 8 additions & 0 deletions src/Brewery.Abstractions/Queries/IQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Brewery.Abstractions.Queries;

public interface IQuery
{

}

public interface IQuery<TResult> : IQuery;
6 changes: 6 additions & 0 deletions src/Brewery.Abstractions/Queries/IQueryDispatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Brewery.Abstractions.Queries;

public interface IQueryDispatcher
{
Task<TResult> QueryAsync<TResult>(IQuery<TResult> query);
}
Loading