[HttpGet, Route("searchReport"), AllowAnonymous]//ShuttleClaimsAuthorize(ActionCode = ConstantsSecurity.ActionCode.WeeklyReportSearch)
        public HttpResponseMessage SearchReport([FromUri] ExpenseSearchRequest search)
        {
            var response = Request.CreateResponse();

            response.Content = new PushStreamContent((outputStream, httpContent, transportContext)
                                                     => _expenseApplicationService.GenerateDataCsvToReportExcel(outputStream, httpContent, transportContext, search), new MediaTypeHeaderValue("text/csv"));
            response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName        = "expenseReportDTOs.csv",
                DispositionType = "inline"
            };
            return(response);
        }
 public async Task GenerateDataCsvToReportExcelDetail(Stream outputStream, HttpContent httpContent,
                                                      TransportContext transportContext, ExpenseSearchRequest search)
 {
     //var list = await SearchExpenseAsync(search);
     //try
     //{
     //    //if (list.Data.Items.Count > 0)
     //    //    using (var writer = new StreamWriter(outputStream))
     //    //    {
     //    //        var headers = new List<string>
     //    //            {
     //    //                "Period",
     //    //                "Expense Date",
     //    //                "Property Type",
     //    //                "Property",
     //    //                "Tenant",
     //    //                "Payment Type",
     //    //                "Reference No",
     //    //                "Status",
     //    //                "Concept",
     //    //                "Start"
     //    //            };
     //    //        await writer.WriteLineAsync(ExcelHelper.GetHeaderDetail(headers));
     //    //        foreach (var item in list.Data.Items)
     //    //            await writer.WriteLineAsync(ProcessCellDataToReport(item));
     //    //    }
     //}
     //catch (HttpException ex)
     //{
     //}
     //finally
     //{
     //    outputStream.Close();
     //}
     throw new NotImplementedException();
 }
        public async Task <ResponseDTO <PagedList <ExpenseDetailSearchDTO> > > GetDetailByExpenseIdAsync(ExpenseSearchRequest search)
        {
            List <OrderExpression <ExpenseDetailSearchDTO> > orderExpressionList = new List <OrderExpression <ExpenseDetailSearchDTO> >();

            orderExpressionList.Add(new OrderExpression <ExpenseDetailSearchDTO>(OrderType.Asc, p => p.ConceptName));
            Expression <Func <ExpenseDetailSearchDTO, bool> > queryFilter = c => true;

            if (search.ExpenseId.HasValue)
            {
                queryFilter = queryFilter.And(p => p.ExpenseId == search.ExpenseId);
            }


            var expense = await _expenseDetailSearchDataAccess.ListPagedAsync
                              (queryFilter, search.Page, search.PageSize, orderExpressionList.ToArray());

            var pagedResult = new PagedList <ExpenseDetailSearchDTO>()
            {
                Items    = expense.Items,
                PageSize = expense.PageSize,
                Page     = expense.Page,
                Total    = expense.Total
            };

            return(ResponseBuilder.Correct(pagedResult));
        }
        public async Task <ResponseDTO <PagedList <ExpenseSearchDTO> > > SearchExpenseAsync(ExpenseSearchRequest search)
        {
            List <OrderExpression <ExpenseSearchDTO> > orderExpressionList = new List <OrderExpression <ExpenseSearchDTO> >();

            orderExpressionList.Add(new OrderExpression <ExpenseSearchDTO>(OrderType.Asc, p => p.ExpenseDate));
            Expression <Func <ExpenseSearchDTO, bool> > queryFilter = c => true;

            //APPLICATIONDATE
            if (search.ExpenseDateFrom.HasValue && search.ExpenseDateTo.HasValue)
            {
                var toPlusADay = search.ExpenseDateTo.Value.AddDays(1);
                queryFilter = queryFilter.And(p => p.ExpenseDate.Value >= search.ExpenseDateFrom);
                queryFilter = queryFilter.And(p => p.ExpenseDate.Value < toPlusADay);
            }
            else if (search.ExpenseDateFrom.HasValue && !search.ExpenseDateTo.HasValue)
            {
                queryFilter = queryFilter.And(p => p.ExpenseDate.Value >= search.ExpenseDateFrom);
            }
            else if (!search.ExpenseDateFrom.HasValue && search.ExpenseDateTo.HasValue)
            {
                var toPlusADay = search.ExpenseDateTo.Value.AddDays(1);
                queryFilter = queryFilter.And(p => p.ExpenseDate.Value < toPlusADay);
            }

            if (search.HouseTypeId.HasValue)
            {
                queryFilter = queryFilter.And(p => p.HouseTypeId == search.HouseTypeId);
            }

            if (search.PeriodId.HasValue)
            {
                queryFilter = queryFilter.And(p => p.PeriodId == search.PeriodId);
            }

            if (search.HouseId.HasValue)
            {
                queryFilter = queryFilter.And(p => p.HouseId == search.HouseId);
            }

            if (search.PaymentTypeId.HasValue)
            {
                queryFilter = queryFilter.And(p => p.PaymentTypeId == search.PaymentTypeId);
            }

            if (!string.IsNullOrEmpty(search.ReferenceNo))
            {
                queryFilter = queryFilter.And(p => p.ReferenceNo == search.ReferenceNo);
            }

            if (search.ExpenseDetailStatusId.HasValue)
            {
                queryFilter = queryFilter.And(p => p.ExpenseDetailStatusId == search.ExpenseDetailStatusId);
            }

            if (search.ConceptId.HasValue)
            {
                queryFilter = queryFilter.And(p => p.ConceptId == search.ConceptId);
            }

            if (!string.IsNullOrEmpty(search.Remark))
            {
                queryFilter = queryFilter.And(p => p.Remark == search.Remark);
            }

            var expense = await _expenseSearchDataAccess.ListPagedAsync(queryFilter, search.Page, search.PageSize, orderExpressionList.ToArray());

            var pagedResult = new PagedList <ExpenseSearchDTO>()
            {
                Items    = expense.Items,
                PageSize = expense.PageSize,
                Page     = expense.Page,
                Total    = expense.Total
            };

            return(ResponseBuilder.Correct(pagedResult));
        }
        public async Task <ResponseDTO <PagedList <ExpenseSearchDTO> > > Search([FromUri] ExpenseSearchRequest search)
        {
            var resp = await _expenseApplicationService.SearchExpenseAsync(search);

            return(resp);
        }