Beispiel #1
0
        public ActionResult GetAll(int page, int countOnPage)
        {
            try
            {
                if (page < 1 || countOnPage < 1)
                {
                    throw new IndexOutOfRangeException("Index was outside the bounds of the array. Page < 1 Or countOnPage < 1");
                }
                int maxOfElement = 0;
                var commodities  = _commodityService.GetAll(page, countOnPage, out maxOfElement);

                return(Ok(Response.WriteAsync(JsonConvert.SerializeObject(new List <Object>()
                {
                    commodities,
                    "CountAllElement =" + maxOfElement,
                    "page =" + page,
                    "countOnPage =" + countOnPage
                },
                                                                          new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                }))));
            }
            catch (Exception ex)
            {
                return(BadRequest(Response.WriteAsync(JsonConvert.SerializeObject(ex,
                                                                                  new JsonSerializerSettings
                {
                    Formatting = Formatting.Indented
                }))));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Get()
        {
            var list = await _commodityService.GetAll();

            if (list == null)
            {
                return(NotFound());
            }

            return(Ok(list));
        }
Beispiel #3
0
        public async Task <IActionResult> GetAll()
        {
            var response = await _commodityService.GetAll();

            return(Ok(response));
        }
Beispiel #4
0
 public ActionResult <IEnumerable <CommodityModel> > Get()
 {
     return(Ok(_commodityService.GetAll()));
 }