Skip to content

Latest commit

 

History

History
104 lines (81 loc) · 2.87 KB

1. Multi-Project Template.md

File metadata and controls

104 lines (81 loc) · 2.87 KB

Standardly - Multi-Project Template

The multi project template consists of a few project templates that will allow you to quickly setup a new solution with API, Build, Provision, Unit Tests and Acceptance Tests projects.

The project names will follow the name convention:

  • %solution name%.Api
  • %solution name%.Api.Build
  • %solution name%.Api.Provision
  • %solution name%.Api.Tests.Unit
  • %solution name%.Api.Tests.Acceptance

API Project

This project will have the basic structure with a few things the following services configured in Startup.cs, a barebones SQL Storage Broker with an implementation of ASP.Net Core Identity.

Startup.cs

    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddLogging();
            services.AddControllers();
            services.AddDbContext<StorageBroker>();
            AddBrokers(services);
            AddServices(services);

            services.AddSwaggerGen(...);
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(...);
            }

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints => endpoints.MapControllers());
        }

        private static void AddServices(IServiceCollection services)
        {
        }

        private static void AddBrokers(IServiceCollection services)
        {
        }
    }

Storage Broker

    public partial class StorageBroker : EFxceptionsIdentityContext<ApplicationUser, ApplicationRole, Guid>, IStorageBroker
    {
        private readonly IConfiguration configuration;

        public StorageBroker(IConfiguration configuration)
        {
            this.configuration = configuration;
            Database.Migrate();
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            string connectionString = configuration
                .GetConnectionString(name: "DefaultConnection");

            optionsBuilder.UseSqlServer(connectionString);
        }

        public override void Dispose() { }
    }

Models

Some models that can be used to extend ASP.Net Core Identity:

  • ApplicationRole.cs
  • ApplicationRoleClaim.cs
  • ApplicationUser.cs
  • ApplicationUserClaim.cs
  • ApplicationUserLogin.cs
  • ApplicationUserRole.cs
  • ApplicationUserToken.cs