Exemplo n.º 1
0
        public Task <GetAllQuotationResponse> getAllQuotation(SearchQuotationRequest request)
        {
            GetAllQuotationResponse response = new GetAllQuotationResponse();

            try
            {
                List <QuotationModel> datas      = new List <QuotationModel>();
                PagedModel            pagedModel = _service.Search(request.Code, request.Page, request.PageSize);

                if (pagedModel.Data != null)
                {
                    foreach (QuotationModel q in pagedModel.Data)
                    {
                        //lay danh sach san pham co trong bao gia
                        q.ProductPrices = _service.GetListProductOfQuotation(q.ID);
                        if (q.ProductPrices != null)
                        {
                            //lay danh sach bao gia cho tung don vi tinh theo san pham
                            foreach (ProductPriceModel p in q.ProductPrices)
                            {
                                p.Prices = _quotationItemService.GetListItemOfQuotation(q.ID, p.ProductID);
                            }
                        }
                        datas.Add(q);
                    }
                }
                response.Data     = datas;
                response.Page     = pagedModel.Page;
                response.PageSize = pagedModel.PageSize;
                response.Total    = pagedModel.PageTotal;
            }
            catch (Exception e)
            {
                //response.Data = e as object;
            }
            return(Task.FromResult(response));
        }