MasoudBimar / RestApi

.NET Core RESTful API with Dapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.NET Core RESTful API with Dapper

Frontend

Sample Requst POST api/values/getData (RequestMetadata)

{
  "pageMeta": {
    "currentPage": 1,
    "perPage": 50
  },
  "filters": {
    "type": {
      "value": "0",
      "matchMode": "startsWith"
    }
  },
  "sortMeta": [
    {
      "field": "name",
      "order": 1
    }
  ],
  "globalFilterValue": "time",
  "table": "report"
}

Response

{
  "items": [
    {
      "id": 5,
      "name": "Report 1",
      "code": "TIME",
      "type": 0,
      "sort_order": 15,
      "row_cnt": 1,
      "rn": 1
    }
  ],
  "_meta": {
    "totalCount": 1,
    "currentPage": 1,
    "perPage": 50,
    "maxRowCount": 500000
  }
}

Sample POST api/values/write (RequestCrud)

{
  "table": "preferences",
  "row": {
    "preference_name": "test",
    "preference_value": "val"
  },
  "type": 1
}

Data

    public class RequestMetadata
    {
        public Dictionary<string, FilterMetadata> filters;
        public PageMetadata pageMeta;
        public SortMetadata[] sortMeta;
        public string globalFilterValue;
        public string table;
    }

    public class FilterMetadata
    {
        public dynamic value;
        public string matchMode;
        public dynamic valueTo;
        public string type;
    }

    public class PageMetadata
    {
        public int currentPage;
        public int perPage;
        public int maxRowCount;
    }

    public class SortMetadata
    {
        public string field;
        public int order;
    }

CRUD

    public class RequestCrud
    {
        public string table;
        public Dictionary<string, object> row;
        public Statement type;
    }

    public enum Statement
    {
        INSERT = 1,
        UPDATE = 2,
        DELETE = 3,
        MERGE = 4
    }

About

.NET Core RESTful API with Dapper


Languages

Language:C# 92.2%Language:TypeScript 7.8%