Code Monkey home page Code Monkey logo

boostart.net's Introduction

Boostart.NET

ASP.NET Core RESTful API Project Template for CRUD applications


Key Features

  • Essential Database Operations (CRUD) in BaseDataService & BaseController.
  • Dependency Injections
  • Swagger configured
  • Automatic Request Logging (NLog)

HOW TO: Run this demo


HOW TO: Add New Controller(s)

With Boostart.NET, you could have a new fully functional controller providing CRUD endpoints within 5 minutes.

Now, let's suppose we are going to setup a new set of endpoints for the new table: Departments.

Here are all the things you have to do:

  • Step #1. Define the database entity under Database.Entity/Entities. It looks like:
    public class Department: BaseEntity
    {
        [MaxLength(255)]
        public string DepartmentName{ get; set; }
    
        [MaxLength(255)]
        public string Address { get; set; }
    }

    NOTE:

    • the new entity MUST inherit from BaseEntity
  • Step #2. Run any dotnet ef command you'd like to update the database;
  • Step #3. Create the new data service class and interface
    /// IDepartmentsDataService.cs
    public interface IUsersDataService : IBaseDataService<User>
    {
    }
    
    /// DepartmentsDataService.cs
    public class DepartmentsDataService : BaseDataService<Department>, IDepartmentsDataService
    {
        public DepartmentsDataService(
            IHttpContextAccessor httpContextAccessor,
            IBaseRepository<User> repos
            ) : base(httpContextAccessor, repos)
        {
        }
    }
  • Step #4. Create the controller
    [Route("api/[controller]")]
    [ApiController]
    public class DepartmentsController : BaseController<Department>
    {
        public DepartmentsController(
            ILogger<ILogActionFilter> logger, 
            IDepartmentsDataService dataService)
            : base(logger, dataService)
        {
        }
    
    }
  • Done!

As you can see, what you did is just create

  • new entity from BaseEntity
  • new data service from BaseDataService
  • new controller from BaseController

That's it!

You don't have to do too many copy & pastes, so you could just focus on the relationships between the entities and business logic.

Enjoy! :)

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.