GithubHelp home page GithubHelp logo

bezaeel / devicemanager.api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from boriszn/devicemanager.api

0.0 2.0 0.0 839 KB

Web API Solution demonstrates mutliteant architecture, using Entity Framework, UnitOfWork, Repository patterns, Docker

Home Page: https://dzone.com/articles/multi-tenant-api-based-on-swagger-entity-framework-1

C# 98.61% Dockerfile 1.39%

devicemanager.api's Introduction

alt text

Web API Solution demonstrates mutliteantcy architecture, using Entity Framework, UnitOfWork,Repository patterns

Build status Gitter chat Build status

arh-diagram

Project

Todo list, accomplished tasks, can be found Here.

Installation

  1. Clone repository
  2. Apply Entity Framework migration. Run: Update-DataBase.
  • (For Multitenancy testing) Change DefaultConnection to ;Database=DeviceDb-ten2; in appsettings.json. Run EF migration Update-DataBase. It will create another database.
  • Tenants Database configuration stored in DataBaseManager (tenantConfigurationDictionary).
  1. Fill up valid database connection string configuration option in appsettings.json.
  2. Run UnitTests.
  3. (Optional) Run API integration tests
  4. Build / Run.

Database Connection

DatabaseType field is used to specify the database type the application should connect. Currently, the framework contains connection information for:

The value of DatabaseType should come from DatabaseType enum (src\DeviceManager.Api\Configuration\Settings) and should match the class name inside (src\DeviceManager.Api\Configuration\DatabaseTypes) and implement IDatabaseType interface.

To add a new database type, just add a class implementing IDatabaseType and add the same name inside DatabaseType and change connection string in the DefaultConnection property and DatabaseType to new database type.

Localization Support

Application supports localization support though resource files. Currently, shared resource file is used to support support for English and German languages. According to (Microsoft docs), to use a UI culture pass it as a query parameter (ui-culture=de-DE). All the resource values for each UI culture should be added to a resource file under Resources folder. The file name should include culture code. Text values from resource files based on the UI culture is obtained from using the instance of IStringLocalizer<SharedResource> sharedLocalizer which is injected via constructor. Then use this object to get resource values using sharedLocalizer["ResourceKey"].Value.

Check Ping action in BaseController.

Note: If only one of culture or ui-culture is sent in the query parameter then dotnetcore uses same value for the other one.

Data Seeding

To seed database with initial data update SeedData method in DataSeederclass.

There can be multiple data seeding classes. To create a new data seeding class:

  1. Create a new data seeding class in the same folder inheriting from IDataSeeder interface.
  2. Register new class in the IocContainerConfiguration class by replacing DataSeeder with new class name.

Docker support

App image available in Docker Hub Registry: https://hub.docker.com/r/boriszn/devicemanagerapi/

You can pull image: docker pull boriszn/devicemanagerapi

The solution was migrated to the docker container and support docker compose orchestration. You can run docker using following options:

  • Visual Studio 2017 Debug mode. Run VS (F5) will run docker container.
  • Docker CLI. Run in PS docker run -p 8080:80 --rm -d boriszn/devicemanagerapi:latest will run docker container in background (or docker run -p 8080:80 boriszn/devicemanagerapi:latest)

You can access the the Web API locally via URL: http://localhost:8080

To run/build project without docker, switch from Docker to DeviceManagerApi (specified in launchSettings.json)

Known issues

  • In case of running from Docker Connection string should be changed to use IP addresses or real server domain names for Server parameter. Also User Id and Password should be added. For example: Server=192.168.1.36,1433;Database=DeviceDb;User Id=MyUser;Password=MySuperStringPassword;Trusted_Connection=True;MultipleActiveResultSets=true

Please be aware connection string like: Server=(localdb)\\mssqllocaldb;Database=DeviceDb;Trusted_Connection=True;MultipleActiveResultSets=true will NOT work if app running from Docker container

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

History

All changes can be easily found in RELEASENOTES

License

This project is licensed under the MIT License

devicemanager.api's People

Contributors

boriszn avatar rudreshgp avatar

Watchers

 avatar  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.