// GET: CustomerQuotes/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            var customerquotes = db.CustomerQuotes.SingleOrDefault(c => c.CustomerQuoteId == id);

            var customers         = db.Customers.ToList();
            var customerdivisions = db.CustomerDivisions.ToList();
            var mlsdivisions      = db.MlsDivisions.ToList();
            var cqstatus          = db.CQStatuses.ToList();

            var viewModel = new SaveCustomerQuotesViewModel()
            {
                CustomerQuote     = customerquotes,
                Customers         = customers,
                CustomerDivisions = customerdivisions,
                MlsDivisions      = mlsdivisions,
                CQStatuses        = cqstatus
            };

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerQuote customerQuote = await db.CustomerQuotes.FindAsync(id);

            if (customerQuote == null)
            {
                return(HttpNotFound());
            }
            return(View("Edit", viewModel));
            //return View(customerQuote);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CustomerQuote customerQuote = await db.CustomerQuotes.FindAsync(id);

            db.CustomerQuotes.Remove(customerQuote);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        //public async Task<ActionResult> Edit([Bind(Include = "CustomerQuoteId,Pn,QuoteDate,QuotedPrice,PriceBreak,Tariff,Terms,QuoteBy,Notes")] CustomerQuote customerQuote)
        public async Task <ActionResult> Edit(CustomerQuote customerQuote)
        {
            if (ModelState.IsValid)
            {
                db.Entry(customerQuote).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", customerQuote));
            }
            return(View(customerQuote));
        }
        //public async Task<ActionResult> Create([Bind(Include = "CustomerQuoteId,Pn,QuoteDate,QuotedPrice,PriceBreak,Tariff,Terms,QuoteBy,Notes")] CustomerQuote customerQuote)
        public async Task <ActionResult> Create(CustomerQuote customerQuote)
        {
            if (ModelState.IsValid)
            {
                db.CustomerQuotes.Add(customerQuote);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", customerQuote));
            }

            return(View(customerQuote));
        }
        // GET: CustomerQuotes/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerQuote customerQuote = await db.CustomerQuotes.FindAsync(id);

            if (customerQuote == null)
            {
                return(HttpNotFound());
            }
            return(View(customerQuote));
        }
 // GET: Admin
 public ActionResult Index()
 {
     using (InsuranceEntities1 db = new InsuranceEntities1())
     {
         List <tbl_car>       cars           = db.tbl_car.ToList();
         List <CustomerQuote> customerQuotes = new List <CustomerQuote>();
         foreach (var entry in cars)
         {
             CustomerQuote customerQuote = new CustomerQuote();
             customerQuote.Id           = entry.tbl_customer.Customer_Id;
             customerQuote.FirstName    = entry.tbl_customer.First_Name;
             customerQuote.LastName     = entry.tbl_customer.Last_Name;
             customerQuote.EmailAddress = entry.tbl_customer.Email_Address;
             customerQuote.Quote        = entry.Car_Quote;
             customerQuotes.Add(customerQuote);
         }
         return(View(customerQuotes));
     }
 }
        // GET: Admin
        public ActionResult Index()

        {
            using (CarInsuranceEntities1 db = new CarInsuranceEntities1())
            {
                var customerList = db.CustomerQuotes;
                var customers    = new List <CustomerQuote>();
                foreach (var customer in customerList)
                {
                    var customersQuote = new CustomerQuote();
                    customersQuote.FirstName     = customer.FirstName;
                    customersQuote.LastName      = customer.LastName;
                    customersQuote.EmailAddress  = customer.EmailAddress;
                    customersQuote.QuoteEstimate = customer.QuoteEstimate;
                    customers.Add(customersQuote);
                }



                return(View(customers));
            }
        }
Example #8
0
        public ActionResult GetQuote(string firstName, string lastName, string emailAddress, int age, string dui, int carYear, string carMake, string carModel, int tickets, string coverage)
        {
            int runningQuote = 50;


            if (age < 18)
            {
                runningQuote = (runningQuote + 100);
            }

            else if (age < 25 || age > 100)
            {
                runningQuote = (runningQuote + 25);
            }


            if (carYear < 2000 || carYear > 2015)
            {
                runningQuote = runningQuote + 25;
            }


            if (carMake == "Porche" || carMake == "porche")
            {
                runningQuote = runningQuote + 25;
            }

            if (carMake == "Porche" || carMake == "porche" && carModel == "911 Carrera" || carModel == "911 carrera")
            {
                runningQuote = runningQuote + 25;
            }
            if (tickets > 0)
            {
                runningQuote = runningQuote + (tickets * 10);
            }


            if (dui == "yes" || dui == "ya" || dui == "yeah")

            {
                runningQuote = runningQuote + (runningQuote * (1 / 4));
            }

            if (coverage == "full")
            {
                runningQuote = runningQuote + (runningQuote * (1 / 2));
            }
            ViewBag.text = coverage;

            using (CarInsuranceEntities1 db = new CarInsuranceEntities1())
            {
                var customer = new CustomerQuote();
                customer.FirstName     = firstName;
                customer.LastName      = lastName;
                customer.EmailAddress  = emailAddress;
                customer.QuoteEstimate = runningQuote;

                db.CustomerQuotes.Add(customer);
                db.SaveChanges();
            }

            return(View("Quoted", runningQuote));
        }
Example #9
0
        public async Task <Stream> PostSalesQuote(SalesQuoteHeader model, List <SalesQuoteLine> lineItems)
        {
            var customerQuote = new CustomerQuote();

            customerQuote.ObjectNodeSenderTechnicalID = model.ExternalReference;
            customerQuote.BuyerID                          = model.ExternalReference;
            customerQuote.Name                             = model.Description;
            customerQuote.PostingDate                      = Convert.ToDateTime(model.PostingDate).ToString("s") + "Z";
            customerQuote.DataOriginTypeCode               = "4";
            customerQuote.AccountParty.PartyID             = model.AccountId;
            customerQuote.BillToParty.PartyID              = model.AccountId;
            customerQuote.EmployeeResponsibleParty.PartyID = model.EmployeeResponsible;
            customerQuote.SalesUnitParty.PartyID           = model.SalesUnitId;
            customerQuote.SalesAndServiceBusinessArea.DistributionChannelCode              = model.DistributionChannelCode;
            customerQuote.RequestedFulfillmentPeriodPeriodTerms.StartDateTime.Text         = Convert.ToDateTime(model.RequestedDate).ToString("s") + "Z";
            customerQuote.RequestedFulfillmentPeriodPeriodTerms.StartDateTime.TimeZoneCode = "UTC+1";

            var lineId = 10;

            foreach (var lineItem in lineItems)
            {
                var item = new Items();
                item.ID = lineId.ToString();
                item.ItemProduct.ProductInternalID      = lineItem.ProductId;
                item.ItemScheduleLine.Quantity.Text     = lineItem.Quantity;
                item.ItemScheduleLine.Quantity.UnitCode = "XCT";
                item.PriceAndTaxCalculationItem.TaxationCharacteristicsCode.Text   = lineItem.TaxCode;
                item.PriceAndTaxCalculationItem.TaxationCharacteristicsCode.ListID = "1";

                customerQuote.Items.Add(item);
                lineId += 10;
            }

            var customerQuoteXml = HelperExtensions.SerializeToXml(customerQuote);

            string filePath = Path.Combine(HostingEnvironment.ContentRootPath, "xmlfiles/salesQuote.xml");

            XmlDocument doc = new XmlDocument();

            doc.Load(filePath);
            var nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
            nsmgr.AddNamespace("glob", "http://sap.com/xi/SAPGlobal20/Global");

            var element = doc.SelectSingleNode("/soapenv:Envelope/soapenv:Body/glob:CustomerQuoteBundleMaintainRequest_sync", nsmgr);

            if (element != null)
            {
                var subDoc = new XmlDocument();
                subDoc.LoadXml(customerQuoteXml);
                var nsmgr1 = new XmlNamespaceManager(subDoc.NameTable);
                nsmgr1.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
                nsmgr1.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");

                var cqNode = subDoc.SelectSingleNode("//CustomerQuote", nsmgr1);
                var sb     = new StringBuilder();
                sb.AppendLine("<CustomerQuote>");
                sb.AppendLine(cqNode.InnerXml);
                sb.AppendLine("</CustomerQuote>");
                element.InnerXml = sb.ToString();

                var sqItemNodes = doc.SelectNodes("//CustomerQuote/Items");
                foreach (XmlNode node in sqItemNodes)
                {
                    XmlAttribute attribute = node.OwnerDocument.CreateAttribute("itemScheduleLineListCompleteTransmissionIndicator");
                    attribute.Value = "true";
                    node.Attributes.Append(attribute);
                }

                var     basicMsgNode      = doc.CreateNode(XmlNodeType.Element, "BasicMessageHeader", null);
                XmlNode customerQuoteNode = doc.SelectSingleNode("//CustomerQuote");
                element.InsertBefore(basicMsgNode, customerQuoteNode);
                doc.Save(filePath);

                StreamReader sr      = new StreamReader(filePath);
                string       soapXml = sr.ReadToEnd();
                sr.Close();

                var tenantSetting = await _tenantSettingService.GetSetting();

                UriBuilder urlBuilder = new UriBuilder(tenantSetting.BaseUrl)
                {
                    Path = "/sap/bc/srt/scs/sap/managecustomerquotein"
                };
                var request = new HttpRequestMessage(HttpMethod.Post, urlBuilder.ToString());
                request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("text/xml"));
                var byteArray = Encoding.ASCII.GetBytes($"{tenantSetting.User}:{tenantSetting.Password}");
                request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
                request.Content = new StringContent(soapXml, Encoding.UTF8, "text/xml");
                var response = await _client.HttpClient.SendAsync(request);

                if (response.IsSuccessStatusCode)
                {
                    var responseData = await response.Content.ReadAsStreamAsync();

                    return(responseData);
                }
            }

            return(null);
        }