Git Product home page Git Product logo

clean-architecture-webapi-ef-core's Introduction

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.

clean-architecture-webapi-ef-core's People

Contributors

ivanpaulovich avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.