Skip to content

A ready-to-use template for ASP.NET Core with repositories, services, models mapping, DI and StyleCop warnings fixed.

License

Notifications You must be signed in to change notification settings

NikolayIT/ASP.NET-Core-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASP.NET Core Template

A ready-to-use template for ASP.NET Core with repositories, services, models mapping, DI and StyleCop warnings fixed.

Build status

Build Status

Authors

Package Installation

You can install this template using NuGet:

dotnet new -i AspNetCoreTemplate
dotnet new aspnet-core -n YourProjectName

Pack this Template

dotnet pack .\nuget.csproj

Project Overview

Dependencies Graph image

Common

AspNetCoreTemplate.Common contains common things for the project solution. For example:

Data

This solution folder contains three subfolders:

  • AspNetCoreTemplate.Data.Common
  • AspNetCoreTemplate.Data.Models
  • AspNetCoreTemplate.Data

AspNetCoreTemplate.Data.Common

AspNetCoreTemplate.Data.Common.Models provides abstract generics classes and interfaces, which holds information about our entities. For example when the object is Created, Modified, Deleted or IsDeleted. It contains a property for the primary key as well.

AspNetCoreTemplate.Data.Common.Repositories provides two interfaces IDeletableEntityRepository and IRepository, which are part of the repository pattern.

AspNetCoreTemplate.Data.Models

AspNetCoreTemplate.Data.Models contains ApplicationUser and ApplicationRole classes, which inherits IdentityRole and IdentityUsers.

AspNetCoreTemplate.Data

AspNetCoreTemplate.Data contains DbContext, Migrations and Configuraitons for the EF Core.There is Seeding and Repository functionality as well.

Services

This solution folder contains four subfolders:

  • AspNetCoreTemplate.Services.Data
  • AspNetCoreTemplate.Services.Mapping
  • AspNetCoreTemplate.Services.Messaging
  • AspNetCoreTemplate.Services

AspNetCoreTemplate.Services.Data

AspNetCoreTemplate.Services.Data wil contains service layer logic.

AspNetCoreTemplate.Services.Mapping

AspNetCoreTemplate.Services.Mapping provides simplified functionlity for auto mapping. For example:

using Blog.Data.Models;
using Blog.Services.Mapping;

public class TagViewModel : IMapFrom<Tag>
{
    public int Id { get; set; }

    public string Name { get; set; }
}

Or if you have something specific:

using System;

using AutoMapper;
using Blog.Data.Models;
using Blog.Services.Mapping;

public class IndexPostViewModel : IMapFrom<Post>, IHaveCustomMappings
{
    public int Id { get; set; }

    public string Title { get; set; }

    public string Author { get; set; }

    public string ImageUrl { get; set; }

    public DateTime CreatedOn { get; set; }

    public void CreateMappings(IProfileExpression configuration)
    {
        configuration.CreateMap<Post, IndexPostViewModel>()
            .ForMember(
                source => source.Author,
                destination => destination.MapFrom(member => member.ApplicationUser.UserName));
    }
}

AspNetCoreTemplate.Services.Messaging

AspNetCoreTemplate.Services.Messaging a ready to use integration with SendGrid.

AspNetCoreTemplate.Services

AspNetCoreTemplate.Services

Tests

This solution folder contains three subfolders:

  • AspNetCoreTemplate.Services.Data.Tests
  • AspNetCoreTemplate.Web.Tests
  • Sandbox

AspNetCoreTemplate.Services.Data.Tests

AspNetCoreTemplate.Services.Data.Tests holds unit tests for our service layer with ready setted up xUnit.

AspNetCoreTemplate.Web.Tests

AspNetCoreTemplate.Web.Tests setted up Selenuim tests.

Sandbox

Sandbox can be used to test your logic.

Web

This solution folder contains three subfolders:

  • AspNetCoreTemplate.Web.Infrastructure
  • AspNetCoreTemplate.Web.ViewModels
  • AspNetCoreTemplate.Web

AspNetCoreTemplate.Web.Infrastructure

AspNetCoreTemplate.Web.Infrastructure contains functionality like Middlewares and Filters.

AspNetCoreTemplate.Web.ViewModels

AspNetCoreTemplate.Web.ViewModels contains objects, which will be mapped from/to our entities and used in the front-end/back-end.

AspNetCoreTemplate.Web

AspNetCoreTemplate.Web self explanatory.

Support

If you are having problems, please let us know by raising a new issue.

Example Projects

License

This project is licensed with the MIT license.