// GET: ModelMasterController/Edit/5 public ActionResult Edit(int id) { var colourInfo = _colourMasterService.GetColourByIdAsync(id); if (colourInfo == null) { return(RedirectToAction("List")); } var viewModel = new ColourMasterModel { Id = colourInfo.Id, ColourCode = colourInfo.ColourCode, ColourName = colourInfo.ColourName, ColourType = colourInfo.ColourType, FriendlyName = colourInfo.FriendlyName, Active = colourInfo.Active, ContinueEditing = IsContinueEditingAllowed() }; foreach (VarientTypeEnum e in Enum.GetValues(typeof(VarientTypeEnum))) { viewModel.AvaillabelVarientTypes.Add(new SelectListItem { Value = e.ToString(), Text = e.ToString() }); } return(View(viewModel)); }
public async Task <IActionResult> GenarateQuote(GenerateQuotationModel model, IFormCollection form) { decimal totalAmount = 0; var custId = Convert.ToInt32(form["CustId"]); var varientInfo = _varientMasterService.GetVarientByIdAsync(model.VarientId); var priceList = await _priceListMasterService.GetModelPriceByModelCodeAsync(varientInfo.VarientCode, varientInfo.VerientName, model.VarientType); if (priceList != null) { model.CustomerDetails.CustomerName = form["CustomerName"].ToString(); model.CustomerDetails.Address1 = form["Address1"].ToString(); model.CustomerDetails.Address2 = !string.IsNullOrEmpty(form["Address2"].ToString()) ? form["Address2"].ToString() : string.Empty; model.CustomerDetails.EmailId = form["EmailId"].ToString(); model.CustomerDetails.Pin = form["Pin"].ToString(); model.CustomerDetails.MobileNo1 = Convert.ToDecimal(form["MobileNo1"]); model.CustomerDetails.MobileNo2 = Convert.ToDecimal(form["MobileNo2"]); var custInfo = await _customerService.GetAllCustomerByIdAsync(custId); if (custInfo == null) { //create cust entry var customer = new CustomerDetailsTable { CustomerName = form["CustomerName"], Address1 = form["Address1"], Address2 = !string.IsNullOrEmpty(form["Address2"].ToString()) ? form["Address2"].ToString() : string.Empty, EmailId = form["EmailId"], Pin = form["Pin"], Taluka = form["Taluka"], District = form["District"], State = Convert.ToInt32(form["StateId"]), MobileNo1 = Convert.ToDecimal(form["MobileNo1"]), MobileNo2 = Convert.ToDecimal(form["MobileNo2"]), DateUpdated = DateTime.UtcNow, DateCreated = DateTime.UtcNow }; await _customerService.InsertAsync(customer); custId = customer.Id; } //add quotation info var quotation = new QuotationDetails { BranchId = 1, ModelId = model.ModelId, VarientId = model.VarientId, VarientType = model.VarientType, ColourId = model.VarientColourId, CustomerId = custId, ScId = model.SalesConsultantId, LeadSource = model.SourceOfEnquiry, BookingAmount = model.BookingAmount, DateCretaed = DateTime.UtcNow, CreatedBy = Convert.ToInt32(HttpContext.User.FindFirst(claim => claim.Type == System.Security.Claims.ClaimTypes.NameIdentifier)?.Value) }; await _quotationManagerService.InsertAsync(quotation); //prepare quote model model.QuoteDate = DateTime.UtcNow.ToString("dd/MM/yyyy"); model.quoteNo = quotation.Id; var scInfo = await _userMasterService.GetUserByIdAsync(model.SalesConsultantId); model.ModelName = _modelsMasterService.GetModelbyIdAsync(model.ModelId).ModelName; model.VarientName = varientInfo.VerientName; model.ColourName = _colourMasterService.GetColourByIdAsync(model.VarientColourId).ColourName; model.SCName = scInfo.FirstName + " " + scInfo.LastName; model.SCMobileNumber = scInfo.ContactNumber.ToString(); var tlInfo = await _userMasterService.GetUserByIdAsync(model.TeamLeaderId); model.TLName = tlInfo.FirstName + " " + tlInfo.LastName; if (Convert.ToBoolean(form["Ex Showroom Price"])) { model.VehiclePriceList.ExShowroomPrice = Convert.ToDecimal(priceList.ExShowroomPrice); totalAmount += Convert.ToDecimal(priceList.ExShowroomPrice); } if (Convert.ToBoolean(form["Fast Tag"])) { model.VehiclePriceList.FastTag = Convert.ToDecimal(priceList.FastTag); totalAmount += Convert.ToDecimal(priceList.FastTag); } if (Convert.ToBoolean(form["TCS"])) { model.VehiclePriceList.TCS = Convert.ToDecimal(priceList.Tcs); totalAmount += Convert.ToDecimal(priceList.Tcs); } if (Convert.ToBoolean(form["Honda Assure Insurance"])) { model.VehiclePriceList.Insurance = Convert.ToDecimal(priceList.Hainsurance); totalAmount += Convert.ToDecimal(priceList.Hainsurance); } if (Convert.ToBoolean(form["Honda Assure Insurance + Key Protect"])) { model.VehiclePriceList.InsuranceWithKeyProtect = Convert.ToDecimal(priceList.HanilDepWithKeyProtect); totalAmount += Convert.ToDecimal(priceList.HanilDepWithKeyProtect); } if (Convert.ToBoolean(form["Honda Assure Insurance + Engine Protect"])) { model.VehiclePriceList.InsuranceWithEngineProtect = Convert.ToDecimal(priceList.HartiwithEngineProtect); totalAmount += Convert.ToDecimal(priceList.HartiwithEngineProtect); } if (Convert.ToBoolean(form["Registration (Indv/Comp)"])) { model.VehiclePriceList.Registration = Convert.ToDecimal(priceList.Rtoindividual); totalAmount += Convert.ToDecimal(priceList.Rtoindividual); } if (Convert.ToBoolean(form["Accessory Combo Kit"])) { model.VehiclePriceList.Accessories = Convert.ToDecimal(priceList.AccessoryComboKit); totalAmount += Convert.ToDecimal(priceList.AccessoryComboKit); } if (Convert.ToBoolean(form["Extended Warranty"])) { model.VehiclePriceList.ExtendedWarranty = Convert.ToDecimal(priceList.ExtendedWarranty); totalAmount += Convert.ToDecimal(priceList.ExtendedWarranty); } if (Convert.ToBoolean(form["RSA"])) { model.VehiclePriceList.RSA = Convert.ToDecimal(priceList.Rsa); totalAmount += Convert.ToDecimal(priceList.Rsa); } if (Convert.ToBoolean(form["Clay Bar"])) { model.VehiclePriceList.ClayBar = Convert.ToDecimal(priceList.ClayBar); totalAmount += Convert.ToDecimal(priceList.ClayBar); } if (Convert.ToBoolean(form["Antirust"])) { model.VehiclePriceList.Antirust = Convert.ToDecimal(priceList.Antirust); totalAmount += Convert.ToDecimal(priceList.Antirust); } if (Convert.ToBoolean(form["Carpet Lamination"])) { model.VehiclePriceList.Lamination = Convert.ToDecimal(priceList.CarpetLamination); totalAmount += Convert.ToDecimal(priceList.CarpetLamination); } model.VehiclePriceList.Total = totalAmount; model.VehiclePriceList.GrandTotal = model.VehiclePriceList.Total; model.Url = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value; //generate quote var quote = await _viewToStringRendererService.RenderToStringAsync("GenerateQuotation/QuoteTemplate", model); HtmlToPdf converter = new HtmlToPdf(); PdfDocument doc = converter.ConvertHtmlString(quote.ToString()); byte[] pdf = doc.Save(); doc.Close(); return(File(pdf, "application/pdf", "quote.pdf")); } model.IsErrorFound = true; model.Error = "Vehicle price list not found"; return(View(model)); }