Exemple #1
0
        public MultiEnquiryModel GetMultiEnquiries(string identifier)
        {
            HttpResponseMessage response  = _httpClient.GetAsync("Enquiries/Multi/" + identifier).Result;
            MultiEnquiryModel   enquiries = null;

            if (response.IsSuccessStatusCode)
            {
                var json = response.Content.ReadAsStringAsync().ConfigureAwait(true)
                           .GetAwaiter()
                           .GetResult();

                enquiries = JsonConvert.DeserializeObject <MultiEnquiryModel>(json);
            }

            return(enquiries);
        }
        public MultiEnquiryModel GetMultiEnquiries(string identifier)
        {
            MultiEnquiryModel ine         = new MultiEnquiryModel();
            List <Enquiry>    lstEnquiry  = new List <Enquiry>();
            List <Contact>    lstContacts = new List <Contact>();
            Enquiry           enquiry     = new Enquiry();

            enquiry = _unitOfWork.GetRepository <Enquiry>().GetList().Items.Where(predicate: x => x.Identifier == identifier).FirstOrDefault();
            if (enquiry == null)
            {
                return(null);
            }

            lstEnquiry.Add(enquiry);
            lstContacts.Add(_unitOfWork.GetRepository <Contact>().GetList().Items.Where(predicate: x => x.Id == enquiry.ContactId).FirstOrDefault());

            ine.enquiries = lstEnquiry;
            ine.contacts  = lstContacts;

            List <DomainEnquiryProduct> lstEnquiryProducts = new List <DomainEnquiryProduct>();

            foreach (EnquiryCatalogItem ep in _unitOfWork.GetRepository <EnquiryCatalogItem>().GetList().Items.Where(predicate: x => x.EnquiryId == enquiry.Id))
            {
                DomainEnquiryProduct dp = new DomainEnquiryProduct {
                    Id = ep.Id, EnquiryId = ep.EnquiryId, ProductId = ep.CatalogItemId, OnRoadPrice = ep.OnRoadPrice, TotalAmount = ep.TotalAmount
                };
                dp.ItemName = _unitOfWork.GetRepository <CatalogItem>().GetList().Items.Where(predicate: x => x.Id == dp.ProductId).FirstOrDefault().ItemName;
                lstEnquiryProducts.Add(dp);
            }
            ine.EnquiryItems              = lstEnquiryProducts;
            ine.enquiryAccessories        = _unitOfWork.GetRepository <EnquiryAccessories>().GetList().Items.Where(predicate: x => x.EnquiryId == enquiry.Id);
            ine.enquiryExchangeQuotations = _unitOfWork.GetRepository <EnquiryExchangeQuotation>().GetList().Items.Where(predicate: x => x.EnquiryId == enquiry.Id);
            ine.enquiryFinanceQuotations  = _unitOfWork.GetRepository <EnquiryFinanceQuotation>().GetList().Items.Where(predicate: x => x.EnquiryProductId == enquiry.Id);

            return(ine);
        }
Exemple #3
0
        public static void PrintEnquiry(ICrystalReport ReportObj, string Identifier)
        {
            if (ReportObj == null)
            {
                return;
            }

            var Scope = Startup.Instance.provider.CreateScope();

            MultiEnquiryModel invm         = Scope.ServiceProvider.GetRequiredService <IEnquiriesService>().GetMultiEnquiries(Identifier);
            ReportDocument    rd           = new ReportDocument();
            string            assemblyFile = (
                new System.Uri(Assembly.GetExecutingAssembly().CodeBase)
                ).AbsolutePath;
            string path = Path.GetDirectoryName(assemblyFile);
            string g    = path + @"\..\..\reports\reports\Enquiry.rpt";

            MessageBox.Show(g);
            rd.Load("reports\\Enquiry.rpt");

            DataSet   ds = new DataSet();
            DataTable dt = ConvertToDataTable <Contact>(invm.contacts);

            dt.TableName = "Contact";
            ds.Tables.Add(dt);
            DataTable dtEnquiries = ConvertToDataTable <Enquiry>(invm.enquiries);

            dtEnquiries.TableName = "Enquiry";
            ds.Tables.Add(dtEnquiries);
            if (invm.EnquiryItems != null)
            {
                DataTable dtProducts = ConvertToDataTable <DomainEnquiryProduct>(invm.EnquiryItems);
                dtProducts.TableName = "EnquiryProducts";
                ds.Tables.Add(dtProducts);
            }
            if (invm.enquiryFinanceQuotations != null)
            {
                DataTable dtFinance = ConvertToDataTable <EnquiryFinanceQuotation>(invm.enquiryFinanceQuotations);
                dtFinance.TableName = "EnquiryFinanceQuotations";
                ds.Tables.Add(dtFinance);
            }
            DataTable dtExchange = ConvertToDataTable <EnquiryExchangeQuotation>(invm.enquiryExchangeQuotations);

            dtExchange.TableName = "EnquiryExchangeQuotations";
            ds.Tables.Add(dtExchange);
            DataTable dtAccessories = ConvertToDataTable <EnquiryAccessories>(invm.enquiryAccessories);

            dtAccessories.TableName = "EnquiryAccessories";
            ds.Tables.Add(dtAccessories);
            //= new DataTable();
            //dt.TableName = "Contact";
            //dt.Columns.Add("Name");
            //dt.Columns.Add("MobileNumber");

            //foreach (Enquiries cr in Enquiries)
            //{
            //    DataRow dr = dt.NewRow();
            //    dr["Name"] = cr.Contact.Name;
            //    dr["MobileNumber"] = cr.Contact.MobileNumber;
            //    dt.Rows.Add(dr);
            //}
            rd.SetDataSource(ds);
            foreach (ReportDocument sub in rd.Subreports)
            {
                sub.SetDataSource(ds);
            }

            ReportObj.ShowReport(rd);
        }