Exemple #1
0
 public ApiResponse Post1(AutoWrapperDemo model)
 {
     if (!ModelState.IsValid)
     {
         throw new ApiException(ModelState.AllErrors());
     }
     return(new ApiResponse("New record has been created in the database", 1, StatusCodes.Status201Created));
 }
Exemple #2
0
        public MyCustomApiResponse Post2(AutoWrapperDemo model)
        {
            if (!ModelState.IsValid)
            {
                throw new ApiException(ModelState.AllErrors());
            }

            var data = new { name = "name", age = 12 };

            return(new MyCustomApiResponse(DateTime.UtcNow, data, new Pagination {
                CurrentPage = 1, PageSize = 10, TotalItemsCount = 200, TotalPages = 20
            }));
        }