-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSimpleOrderSearchController.cs
More file actions
47 lines (44 loc) · 1.37 KB
/
SimpleOrderSearchController.cs
File metadata and controls
47 lines (44 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SimpleOrderSearchAPI.Data;
using SimpleOrderSearchAPI.Model;
namespace SimpleOrderSearchAPI.Controllers
{
[Route("api/[controller]")]
public class SimpleOrderSearchController : Controller
{
private readonly ISimpleOrderSearchService _service;
public SimpleOrderSearchController(ISimpleOrderSearchService service)
{
_service = service;
}
[HttpGet]
public IActionResult GetOrders([FromQuery]Params orderParam)
{
try
{
var orders = _service.GetSearchOrders(orderParam);
var pagination = new Pagination
{
CurrentPage = orders.CurrentPage,
ItemPerPage = orders.ItemPerPage,
TotalItems = orders.TotalItem,
TotalPages = orders.TotalPages,
Offset = orders.Offset
};
var result = new GetOrdersResponseMessage
{
Orders = orders,
Pagination = pagination
};
return Ok(result);
}
catch (Exception ex)
{
Console.WriteLine(ex);
return BadRequest();
}
}
}
}