public HttpResponseMessage GetSalesTransaction(SalesHistoryApiRequestModel request) { var response = new ApiResultViewModel <List <SalesRecordViewModel> > { result = new List <SalesRecordViewModel>() }; try { var dtoResult = GetPagedSales(request); dtoResult.ForEach(item => response.result.Add(Mapper.Map <SalesRecordViewModel>(item))); if (dtoResult.Count() > 0) { response.additionalResult = new { pageCount = dtoResult.FirstOrDefault().TotalCount, SumTotal = dtoResult.Sum(t => t.Total) } } ; } catch (Exception ex) { _logger.Log(ex); #if DEBUG response.errorMessage = ex.Message; response.errorStatus = true; #else response.errorMessage = "Error occured, please contact admin."; response.errorStatus = true; #endif } return(Request.CreateResponse(response)); }
private List <SalesRecordDto> GetPagedSales(SalesHistoryApiRequestModel request) { var startDate = ParseDate(request.startDate); var endDate = ParseDate(request.endDate); request.startDate = startDate.ToString("ddd, dd MMM, yyyy", CultureInfo.InvariantCulture); request.endDate = endDate.ToString("ddd, dd MMM, yyyy", CultureInfo.InvariantCulture); var dtoResult = _reportSvc.GetSalesHistory(request.pageIndex, request.itemsOnPage, request.user , startDate, endDate, request.status, request.transactionId , request.Stock); return(dtoResult); }