Skip to content
Web API Framework demonstrates scalable, mutliteant, architecture and allows building own solution in the minutes. Uses: Entity Framework, UnitOfWork, Repository patterns. Wrapped in Docker, Kubernates
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets update readme Oct 1, 2018
src/DeviceManager.Api Refactor constants Mar 1, 2019
test/DeviceManager.Api.UnitTests Refactor constants Mar 1, 2019
.dockerignore add docker compose for multicontainer support; add docker status shie… Oct 11, 2018
.gitignore add docker compose for multicontainer support; add docker status shie… Oct 11, 2018
DeviceManagerApi.sln add docker compose for multicontainer support; add docker status shie… Oct 11, 2018
README.md fix readme 2 Mar 1, 2019
ReleaseNotes.md update ReleaseNotes Mar 1, 2019
docker-compose.dcproj add docker compose for multicontainer support; add docker status shie… Oct 11, 2018
docker-compose.override.yml add docker compose for multicontainer support; add docker status shie… Oct 11, 2018
docker-compose.yml

README.md

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

You can’t perform that action at this time.