/AspNetWebApiCrud

Asp Net Web Api Crud application

Primary LanguageC#

Introduction

This is a project mean to be used for learning basic CRUD operations and Pagination using

  • AspNet Web Api 2 (Not Asp Net Core, for the Asp Net Core I have another app, look links below)
  • Entity Framework

Full-stack Applications

E-commerce (shopping cart)

Server side implementations

The next to come are:

  • Spring Boot + Spring Data Hibernate + Kotlin
  • Spring Boot + Jax-RS Jersey + Hibernate + Kotlin
  • Spring Boot + mybatis
  • Spring Boot + mybatis + Kotlin
  • Asp.Net Web Api v2
  • Elixir
  • Golang + Beego
  • Golang + Iris
  • Golang + Echo
  • Golang + Mux
  • Golang + Revel
  • Golang + Kit
  • Flask + Flask-Restful
  • AspNetCore + NHibernate
  • AspNetCore + Dapper

Client side implementations

This client side E-commerce application is also implemented using other client side technologies:

Blog/CMS

Server side implementations

Client side

The next come are

  • Angular NgRx-Store
  • Angular + Material
  • React + Material
  • React + Redux + Material
  • Vue + Material
  • Vue + Vuex + Material
  • Ember

Simple CRUD(Create, Read, Update, Delete)

Server side implementations

Client side implementations

The next come are

  • Angular NgRx-Store
  • Angular + Material
  • React + Material
  • React + Redux + Material
  • Vue + Material
  • Vue + Vuex + Material
  • Ember
  • Vanilla javascript

CRUD + Pagination

Server side implementations

The next come are

  • NodeJs Express + Knex
  • Flask + Flask-Restful
  • Laravel + Fractal
  • Laravel + ApiResources
  • Go with Mux
  • AspNet Web Api 2
  • Jersey
  • Elixir

Client side implementations

The next come are

  • Angular NgRx-Store
  • Angular + Material
  • React + Material
  • React + Redux + Material
  • Vue + Material
  • Vue + Vuex + Material
  • Ember
  • Vanilla javascript

Understanding the project

I have controllers, services that deal with the database, Dtos that filter which thing is returned or not as response. The controllers all return HttpResponseMessage, which is somewhat the old way, which means this code is more portable, If for some reason you wanna return the new IHttpActionResult, it is easy, just wrap the HttpResponseMessage into ResponseMessage, the example for the GetTodos Action in TodosController would be:

public async Task<IHttpActionResult> GetTodos([FromUri] int page = 1, [FromUri] int pageSize = 5)
{
    var result = await _todosService.FetchMany(page, pageSize, TodoShow.All);
    return ResponseMessage(StatusCodeAndDtoWrapper.BuildSuccess(TodoListResponse.Build(result.Item2,
        Request.RequestUri.LocalPath, page,
        pageSize, result.Item1)));

}

More on this topic:

I drop/create and seed database each time the app is run, this is not what we want for a more serious app, what we would want is to use migrations. A really cool and simple guide can be found at official Microsoft docs(1min article read): https://docs.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-3

The next come are:

  • NodeJs Express + Knex
  • Flask + Flask-Restful
  • Laravel + Fractal
  • Laravel + ApiResources
  • Go with Mux
  • Jersey
  • Elixir

Social media links

Resources