• Stars
    star
    131
  • Rank 266,605 (Top 6 %)
  • Language
    C#
  • Created over 5 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

❀️ The simplest Clean Architecture demo on how to implement a Web Api using .NET Core and Entity Framework

Try in PWD Clean Architecture Implementation of a Personal Wallet Web Api

The simplest demo on how to implement a Web Api using .NET Core and Entity Framework that protects the business rules from framework dependencies by following the Clean Architecture Principles.

🐳 Running From The Docker Image

docker run -e ASPNETCORE_ENVIRONMENT="Development" -p 5500:80 ivanpaulovich/clean-architecture-webapi-ef-core

πŸš€ Running From Source

To run on top of a InMemory persistance layer simple run:

dotnet run --environment="dev" --project source/MyWallet.WebApi/MyWallet.WebApi.csproj

To run on top of a SQL Server persistance layer you need to setup the SQL Server database in steps ahead then run:

dotnet run --environment="production" --project source/MyWallet.WebApi/MyWallet.WebApi.csproj

Then navigate to the Swagger URL http://localhost:5500/ or run in command-line:

curl -X POST "http://localhost:5500/api/Customers" -H "accept: application/json" -H "Content-Type: application/json-patch+json" -d "{ \"personnummer\": \"198608178877\", \"name\": \"string\", \"initialAmount\": 440}"

πŸ’Ύ SQL Server Database

If you wanna use Entity Framework, setup the SQL Server then update the database via dotnet EF Tool.

Update the Database

dotnet ef database update --project source/MyWallet.Infrastructure --startup-project source/MyWallet.WebApi

Add Migration

Run the EF Tool to add a migration to the MyWallet.Infrastructure project.

dotnet ef migrations add "InitialCreate" -o "EntityFrameworkDataAccess/Migrations" --project source/MyWallet.Infrastructure --startup-project source/MyWallet.WebApi

Setup the SQL Server in Docker

To run SQL Server container images with Docker use:

#!/bin/bash
sudo docker pull mcr.microsoft.com/mssql/server:2017-latest
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourStrong!Passw0rd>' -Q 'ALTER LOGIN SA WITH PASSWORD="<YourNewStrong!Passw0rd>"'

It will enable a SQL Server running on Server=localhost;User Id=sa;Password=<YourNewStrong!Passw0rd>; for more details checkout the docs at How to run a SQL Server in a Docker Container.

🏁 Requirements

Developed and Tested using:

  • MacOS Sierra
  • VSCode ❀️
  • .NET SDK 2.2.
  • Docker 🐳
  • SQL Server via Docker container.

☎️ For Support and Issues

I am happy to be reach out through the Issues Tab.

More Repositories

1

clean-architecture-manga

πŸŒ€ Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks
C#
3,849
star
2

hexagonal-architecture-acerola

An Hexagonal Architecture service template with DDD, CQRS, TDD and SOLID using .NET Core 2.0. All small features are testable and could be mocked. Adapters could be mocked or exchanged.
C#
446
star
3

dotnet-new-caju

Learn Clean Architecture with .NET Core 3.0 πŸ”₯
C#
250
star
4

FluentMediator

πŸ”€ FluentMediator is an unobtrusive library that allows developers to build custom pipelines for Commands, Queries and Events.
C#
191
star
5

event-sourcing-jambo

An Hexagonal Architecture with DDD + Aggregates + Event Sourcing using .NET Core, Kafka e MongoDB (Blog Engine)
C#
188
star
6

ddd-tdd-rich-domain-model-dojo-kata

DDD patterns implemented following TDD
C#
140
star
7

todo

βœ… Commad-Line Task management with storage on your GitHub πŸ”₯
C#
121
star
8

event-sourcing-castanha

An Event Sourcing service template with DDD, TDD and SOLID. It has High Cohesion and Loose Coupling, it's a good start for your next Microservice application.
C#
80
star
9

clean-architecture-video-tutorials

Live Streaming and Video Tutorials on Clean Architecture, DDD, TDD using .NET Core every week on Paulovich.NET Youtube channel.
C#
51
star
10

webapi-backgroundworker-rabbitmq

Sample implementation of a WebApi that publishes messages to RabbitMQ and consume them using a BackgroundWorker.
C#
24
star
11

TechTalks

Download the high-resolution slides from my past talks to easy your learning into Clean Architecture.
23
star
12

clean-architecture-kata-dojo

⭐ Kata to learn Clean Architecture and Hexagonal Architecture styles, you start with two use cases already implemented and the final solution has six use cases. ⭐
C#
21
star
13

amora-angular-app

An Angular App with Material Design and client of the Microservices Acerola and Manga
TypeScript
16
star
14

CleanArchitectureVSCodeSnippets

Clean Architecture C# Snippets for Visual Studio Code
TypeScript
10
star
15

mfa

DDD + Aggregates + Event Sourcing com .NET Core, Kafka e MongoDB (School Management)
C#
9
star
16

IdentityServer4Sample

C#
7
star
17

betsson-meetup-ddd-tdd

Building Rich Domain Models with DDD and TDD - Presentation
C#
7
star
18

MrRobot

A programmatically Cleaning Robot that informs the number of places cleaned after each execution.
C#
5
star
19

ivanpaulovich

Tech Lead, Software Engineer, 20+ GitHub projects about Clean Architecture, SOLID, DDD and TDD. Speaker/Streamer. Microsoft rMVP.
4
star
20

software-craftsmanship-study-plan

3
star
21

goat-ecs

Goat-ECS is an Entity-Component System with a friendly API to build objects with dynamic components.
C++
3
star
22

dotfiles

Shell
3
star
23

dotnet-new-on-the-web

Run dotnet new command on demand in an Web App
C#
2
star
24

tdd-practices

Practicing TDD
C#
1
star
25

openhackC4H

Classify Jobs description accordingly to a Natural Language then translate the results into Emoji!
C#
1
star
26

lapland

C#
1
star