public IActionResult GetPurchaseHistoryList(GetPurchaseHistoryRequest _request)
        {
            string APIName = "GetPurchaseHistoryList";

            log.LogInformation($"{APIName}\r\nPageNum:{_request.PageNumber}\r\nPageSize{_request.PageSize}");
            try
            {
                var response = repo.Estore.GetPurchaseHistory(_request);

                if (response != null && response.Count > 0)
                {
                    Response.Headers.Add("X-Pagination", PageListHelper.GetPagingMetadata(response));
                    log.LogInformation($"{APIName}\r\n Get List Count :{response.Count}");
                    return(Ok(response));
                }
                else
                {
                    log.LogError($"{APIName}\r\nNo Record Found");
                    return(NotFound(new Error("Not-Found", "No Record Found")));
                }
            }
            catch (Exception e)
            {
                log.LogError($"{APIName}\r\n{e}");
                return(StatusCode(500, new Error("internal-error", e.Message)));
            }
        }
Example #2
0
        public PagedList <GetPurchaseHistoryResponse> GetPurchaseHistory(GetPurchaseHistoryRequest _request)
        {
            GetPurchaseHistoryResponse response = new GetPurchaseHistoryResponse();
            var eVoucherList = (from p in db_Evoucher.TblPurchaseHistories
                                join ge in db_Evoucher.TblGeneratedEvouchers
                                on p.PromoCode equals ge.PromoCode
                                where ge.Status >= (int)PromoCodeStatus.Used &&
                                p.Status == (int)RecordStatus.Active &&
                                _request.PurchaseFromDate == null ? true : p.PurchaseDate >= _request.PurchaseFromDate &&
                                _request.PurchaseToDate == null ? true : p.PurchaseDate <= _request.PurchaseToDate
                                select new GetPurchaseHistoryResponse
            {
                PromoCode = p.PromoCode,
                QR_Image_Path = ge.Status != (int)PromoCodeStatus.Used ? ge.QrImagePath : "",
                IsUsed = ge.Status == (int)PromoCodeStatus.Used,
                PurchaseHistoryId = p.PurchaseHistoryId,
            }
                                ).AsQueryable();

            return(PagedList <GetPurchaseHistoryResponse> .ToPagedList(eVoucherList,
                                                                       _request.PageNumber,
                                                                       _request.PageSize));
        }