private async Task SaveQuoteInternalAsync(QuotesViewModel vm) { //if (vm.Id == 0) { vm.Id = await _service.SaveAsync(vm, UserId).ConfigureAwait(false); } }
public async Task <IActionResult> SaveQuoteAsync(QuotesViewModel vm, IEnumerable <DesignViewModel> dvm) { var _dvm = dvm; await _service.SaveAsync(vm, UserId); return(RedirectToAction("Index")); }
public async Task <IActionResult> PartialStandardVariation(QuotesViewModel quoteModel) { await SaveQuoteInternalAsync(quoteModel); var subCategoryId = Request.Form["SubCategoryId"][0]; var description = Request.Form["VariationDescription"][0]; var category = Request.Form["VariationCategory"][0]; var costVariation = Request.Form["CostVariation"][0]; InclusionDetailViewModel inclusionViewDetail = null; if (!string.IsNullOrEmpty(subCategoryId) && !string.IsNullOrEmpty(description) && !string.IsNullOrEmpty(subCategoryId)) { inclusionViewDetail = new InclusionDetailViewModel { Category = category, SubCategory = subCategoryId, Description = description, Cost = string.IsNullOrEmpty(costVariation) ? 0 : Convert.ToDecimal(costVariation), QuoteId = Convert.ToInt32(quoteModel.Id) }; if (quoteModel.AdditionalInclusions == null) { quoteModel.AdditionalInclusions = new List <InclusionDetailViewModel>(); } quoteModel.AdditionalInclusions.Add(inclusionViewDetail); } await _service.SaveVariationInclusionAsync(inclusionViewDetail); var result = await _service.GetQuoteByIdAsync(quoteModel.Id); return(PartialView("_inclusionVariationPartial", result)); }
public async Task <IActionResult> New() { var quote = new QuotesViewModel(); this.SetQuotesDropDownSources(quote); return(View("Form", quote)); }
public async Task <IActionResult> Save(QuotesViewModel model) { try { if (!ModelState.IsValid) { // I don't like this, will need to repeat filling up values for drop down lists // Perhaps best to convert these sources to WEB API and invoke it on client side this.SetQuotesDropDownSources(model); return(View("Form", model)); } if (model.Id == 0) { var quote = _mapper.Map <Quotes>(model); _context.Add(quote); } else { var quotesInDb = await _context.Quotes.SingleOrDefaultAsync(c => c.Id == model.Id); _mapper.Map(model, quotesInDb); } await _context.SaveChangesAsync(); } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(RedirectToAction("Index", "Quotes")); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); SupportActionBar.Title = "Quotes"; MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); var request = Intent.GetStringExtra("request"); Request item = JsonConvert.DeserializeObject <Request>(request); Request = new Request(); Request = item; quotesViewModel = new QuotesViewModel(); await quotesViewModel.GetQuotes(Request); if (quotesViewModel.Quotes.Count > 0) { var contactsAdapter = new ContactsAdapter(this, quotesViewModel.Quotes); var contactsListView = FindViewById <ListView>(Resource.Id.ContactsListView); contactsListView.Adapter = contactsAdapter; contactsListView.ItemClick += ItemClick; SaveQuoteRequest(quotesViewModel.Quotes, Request, quotesViewModel); } else { messageDialog.SendToast("There are no couriers available within 50KM from your pick up location."); Intent intent = new Intent(this, typeof(RequestCourierActivity)); StartActivity(intent); } messageDialog.HideLoading(); }
public async Task <IActionResult> CreateQuoteForContactAsync(long id) { var vm = await _contactService.GetContactAsync(id, UserId); var facades = await _service.GetFacadesAsync(); var promotions = await _service.GetPromotionsAsync(); var packages = await _service.GetPackagesAsync(); var inclusions = await _service.GetInclusionsAsync(); var houseDesigns = await _service.GetHouseDesignsAsync(); var inclusionDetails = await _service.GetInclusionDetailsAsync(); var quoteModel = new QuotesViewModel(facades, promotions, houseDesigns, packages, inclusions, inclusionDetails, new List <DocumentViewModel>()); quoteModel.CustomerFirstName = vm.FirstName; quoteModel.CustomerLastName = vm.LastName; quoteModel.CustomerEmail = vm.Email; quoteModel.CustomerAddress = $"{vm.MailingStreet} {vm.City} {vm.MailingState} {vm.MailingZip} {vm.State}"; quoteModel.CustomerContact = vm.Phone; var newQuoteID = await _service.SaveAsync(quoteModel, UserId); return(RedirectToAction("GetQuotesAsync", new { id = newQuoteID })); }
public ShellViewModel(AddSymbolViewModel addSymbol, SymbolsViewModel symbols, StatusViewModel status, AutoRefreshViewModel autoRefresh, QuotesViewModel quotes) { AddSymbol = addSymbol; Symbols = symbols; Status = status; Quotes = quotes; AutoRefresh = autoRefresh; }
void UpdateQuote() { //_fadeOut.Begin(); //_scroll.Stop(); DataContext = new QuotesViewModel(this, GetQuote()); _scroll.Begin(); //_fadeIn.Begin(); }
public async Task <IActionResult> ConvertQuoteAsync(QuotesViewModel vm) { var data = await _service.GetQuoteByIdAsync(vm.Id); data.IsTender = true; await _service.SaveAsync(data, UserId); return(RedirectToAction("Index", new { type = "tender" })); }
private void SetQuotesDropDownSources(QuotesViewModel model) { var categories = _context.QuoteCategory.ToList(); var sources = _context.QuoteSource.ToList(); var authors = _context.Author.ToList(); model.Categories = categories; model.Sources = sources; model.Authors = authors; }
public QuotesPage() { InitializeComponent(); BindingContext = new QuotesViewModel(); FloatingActionButtonAdd.Clicked = async(sender, args) => { await Navigation.PushAsync(new AddEditQuotePage()); }; this.Title = "Quotes"; }
public async Task <long> DeleteCustomPdfAsync(QuotesViewModel vm) { var m = _mapper.Map <Quote>(vm); var current = await _repository.FirstOrDefaultAsync(a => a.Id == m.Id); current.PdfUrl = string.Empty; await _repository.UpdateAsync(current, current.Id); return(m.Id); }
public BrowseItemsAdapter(Activity activity, QuotesViewModel viewModel) { this.viewModel = viewModel; this.activity = activity; this.viewModel.Quotes.CollectionChanged += (sender, args) => { this.activity.RunOnUiThread(NotifyDataSetChanged); }; }
public async Task SendEmailAsync(QuotesViewModel quoteModel) { if (quoteModel.Documents == null || quoteModel.Documents.Count == 0) { return; } var apiKey = _appSettings.SendGridKey; // Using Razor templating package (or set using AddRazorRenderer in services) Email.DefaultRenderer = new RazorRenderer(); Email.DefaultSender = new SendGridSender(apiKey); //Create a stream for the file Stream stream = null; var mailAddresses = new List <Address> { new Address(quoteModel.CustomerEmail) }; try { var fileNameOfAttachment = quoteModel.Documents.First().Name; stream = GetStreamFromUrl(fileNameOfAttachment); // var stream = File.OpenRead($"{Directory.GetCurrentDirectory()}/wwwroot/Images/EH10001-Quote-24012020.pdf"); var emailToSend = Email .From("test email") .To(mailAddresses) .CC(quoteModel.EmailCC ?? string.Empty) .Subject("Your Building Quote") .UsingTemplateFromFile($"{Directory.GetCurrentDirectory()}/Templates/QuoteTemplate.cshtml", quoteModel) // TODO replace Path with actual data store nd add in config .Attach(new FluentEmail.Core.Models.Attachment { Data = stream, Filename = fileNameOfAttachment }); await emailToSend.SendAsync(); } catch (Exception ex) { } finally { if (stream != null) { //Close the input stream stream.Close(); } } }
public async Task <IActionResult> PartialDeleteQuote(QuotesViewModel quoteModel) { var documentName = Request.Form["deleteID"][0]; quoteModel.Documents = await _service.GetDocuments(quoteModel.Id); var documentToDelete = quoteModel.Documents.Where(d => d.Name == documentName).FirstOrDefault(); await _azureStorageService.DeleteDocAsync(documentToDelete.Name); await _service.DeleteDocumentAsync(documentToDelete); quoteModel.Documents = await _service.GetDocuments(quoteModel.Id); return(PartialView("_quoteEmailPartial", quoteModel)); }
public async Task <IActionResult> PartialDeleteVariation(QuotesViewModel quoteModel) { try { var inclusionID = Request.Form["deleteID"][0]; await _service.DeleteInclustionAsync(Convert.ToInt32(inclusionID)); } catch { Response.StatusCode = (int)HttpStatusCode.BadRequest; } var result = await _service.GetQuoteByIdAsync(quoteModel.Id); return(PartialView("_inclusionVariationPartial", result)); }
public async Task <IActionResult> SendEnquiryEmail(QuotesViewModel quoteModel) { if (Request.Form["SendEnquiryEmail"].Count > 0) { var facades = await _service.GetFacadesAsync(); var promotions = await _service.GetPromotionsAsync(); var packages = await _service.GetPackagesAsync(); var inclusions = await _service.GetInclusionsAsync(); var houseDesigns = await _service.GetHouseDesignsAsync(); var inclusionDetails = await _service.GetInclusionDetailsAsync(); quoteModel.SetMasterData(facades, promotions, houseDesigns, packages, inclusions, inclusionDetails); DesignViewModel houseDesign = quoteModel.HouseDesignId.HasValue ? quoteModel.HouseDesigns.First(x => x.Id == quoteModel.HouseDesignId.Value) : quoteModel.HouseDesigns.First(); FacadeViewModel facade = quoteModel.FacadeId.HasValue ? quoteModel.Facades.First(x => x.Id == quoteModel.FacadeId.Value) : quoteModel.Facades.First(); InclusionViewModel inclusion = quoteModel.InclusionId.HasValue ? quoteModel.Inclusions.First(x => x.Id == quoteModel.InclusionId.Value) : quoteModel.Inclusions.First(); quoteModel.HouseDesignName = houseDesign.Name; quoteModel.InclusionName = inclusion.Name; quoteModel.FacadeName = facade.Name; quoteModel.BasePrice = houseDesign.Cost; quoteModel.Documents = await _service.GetDocuments(quoteModel.Id); if (quoteModel.Documents == null) { quoteModel.Documents = new List <DocumentViewModel>(); } await _emailSender.SendEmailAsync(quoteModel); TempData["SuccessMessage"] = "Your enquiry has been sent successfully."; return(View("CreateQuote", quoteModel)); } else { var vmReturn = await GeneratePdfDocument(quoteModel); TempData["SuccessMessage"] = "Your quote has been generated successfully."; return(View("CreateQuote", vmReturn)); } }
public async Task <IActionResult> SendEnquiryEmail(QuotesViewModel quoteModel) { if (quoteModel.Documents == null) { quoteModel.Documents = new List <DocumentViewModel>(); } if (!ModelState.IsValid) { return(PartialView("_quoteEmailPartial", quoteModel)); } await _emailSender.SendEmailAsync(quoteModel); TempData["SuccessMessage"] = "Your enquiry has been sent successfully."; return(PartialView("_quoteEmailPartial", quoteModel)); }
public async Task <IActionResult> PartialDeleteCustomPdf(QuotesViewModel quoteModel) { try { var fileName = Request.Form["deleteID"][0]; await _azureStorageService.DeleteDocAsync(fileName); await _service.DeleteCustomPdfAsync(quoteModel); } catch { Response.StatusCode = (int)HttpStatusCode.BadRequest; } var result = await _service.GetQuoteByIdAsync(quoteModel.Id); return(PartialView("_inclusionVariationPartial", result)); }
public async Task <IActionResult> Edit(int id) { var quoteInDB = await _context.Quotes .AsNoTracking() .SingleOrDefaultAsync(x => x.Id == id); if (quoteInDB == null) { return(NotFound()); } var model = new QuotesViewModel(); _mapper.Map(quoteInDB, model); this.SetQuotesDropDownSources(model); return(View("Form", model)); }
public async Task <IActionResult> PartialEnquiryEmail(QuotesViewModel quoteModel) { var facades = await _service.GetFacadesAsync(); var promotions = await _service.GetPromotionsAsync(); var packages = await _service.GetPackagesAsync(); var inclusions = await _service.GetInclusionsAsync(); var houseDesigns = await _service.GetHouseDesignsAsync(); var inclusionDetails = await _service.GetInclusionDetailsAsync(); quoteModel.EmailCC = Request.Form["EmailCC"][0]; if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json("Error .. Please check email format ..")); } quoteModel.SetMasterData(facades, promotions, houseDesigns, packages, inclusions, inclusionDetails); DesignViewModel houseDesign = quoteModel.HouseDesignId.HasValue ? quoteModel.HouseDesigns.First(x => x.Id == quoteModel.HouseDesignId.Value) : quoteModel.HouseDesigns.First(); FacadeViewModel facade = quoteModel.FacadeId.HasValue ? quoteModel.Facades.First(x => x.Id == quoteModel.FacadeId.Value) : quoteModel.Facades.First(); InclusionViewModel inclusion = quoteModel.InclusionId.HasValue ? quoteModel.Inclusions.First(x => x.Id == quoteModel.InclusionId.Value) : quoteModel.Inclusions.First(); quoteModel.HouseDesignName = houseDesign.Name; quoteModel.InclusionName = inclusion.Name; quoteModel.FacadeName = facade.Name; quoteModel.BasePrice = houseDesign.Cost; quoteModel.Documents = await _service.GetDocuments(quoteModel.Id); if (quoteModel.Documents == null) { quoteModel.Documents = new List <DocumentViewModel>(); } await _emailSender.SendEmailAsync(quoteModel); TempData["SuccessMessage"] = "Your enquiry has been sent successfully."; return(PartialView("_quoteEmailPartial", quoteModel)); }
public async Task <long> SaveAsync(QuotesViewModel vm, long loggedinUserId) { var m = _mapper.Map <Quote>(vm); if (m.Id > 0) { var current = await _repository.FirstOrDefaultAsync(a => a.Id == m.Id); current.ModifiedBy = loggedinUserId; current.ModifiedOn = DateTime.UtcNow; current.Status = vm.Status; current.Notes = vm.Notes; current.CustomerAddress = vm.CustomerAddress; current.CustomerFirstName = vm.CustomerFirstName; current.CustomerEmail = vm.CustomerEmail; current.CustomerLastName = vm.CustomerLastName; current.CustomerProjectAddress = vm.CustomerProjectAddress; current.CustomerContact = vm.CustomerContact; current.FacadeId = vm.FacadeId; current.HouseDesignId = vm.HouseDesignId; current.InclusionId = vm.InclusionId; current.IsTender = vm.IsTender; current.ValidDays = vm.ValidDays; current.GarageHand = vm.GarageHand; current.FrontAlignment = vm.FrontAlignment; // current.SupervisorContact //current.CompanyName = vm.CompanyName; //current.Email = vm.Email; //current.UserName = vm.UserName; await _repository.UpdateAsync(current, current.Id); } else { m.CreatedBy = loggedinUserId; m.CreatedOn = DateTime.UtcNow; m.IsActive = true; await _repository.AddAsync(m); } return(m.Id); }
public async Task <IActionResult> PartialGenerateQuote(QuotesViewModel quoteModel) { quoteModel.Email = quoteModel.CustomerEmail; await SaveQuoteInternalAsync(quoteModel); quoteModel.Documents = await _service.GetDocuments(quoteModel.Id); var docsFounds = quoteModel.Documents.Where(x => x.Title.ToLower().Contains(quoteModel.RequestTypeLower)).ToList(); if (docsFounds != null && docsFounds.Count >= 2) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json($"Max limit reached: maximum of 2 {quoteModel.RequestType} allowed per contact, please delete an existing {quoteModel.RequestType} to create new one..")); } var vmReturn = await GeneratePdfDocument(quoteModel); TempData["SuccessMessage"] = "Your {quoteModel.RequestType} has been generated successfully."; vmReturn.Documents = await _service.GetDocuments(vmReturn.Id); vmReturn.Email = vmReturn.CustomerEmail; return(PartialView("_quoteEmailPartial", vmReturn)); }
public QuotesPage() { InitializeComponent(); BindingContext = new QuotesViewModel(); }
public async void SaveQuoteRequest(ObservableRangeCollection <Quote> quotes, Request request, QuotesViewModel quotesViewModel) { ObservableRangeCollection <Quote> ada = quotesViewModel.Quotes; string df = string.Format("{0} - {1}", Build.Manufacturer, Build.Model); string ddf = Build.VERSION.Release.ToString(); DateTime dt = DateTime.Now; QuoteRequest quoteRequest = new QuoteRequest() { Phone = df, OSVersion = ddf, RequestDatetime = dt, Request = request, Quotes = ada, }; quotesViewModel.SaveQuoteRequest(quoteRequest); }
public async Task <IActionResult> GenerateDoc(QuotesViewModel vm) { var vmReturn = await GeneratePdfDocument(vm); return(View("CreateQuote", vmReturn)); }
// GET: /<controller>/ public IActionResult Index(QuotesViewModel vm) { var quoteModel = new QuoteViewModel { Name = "TestQuote", FileNameOfAttachment = "Test Quote.pdf" }; var list = new List <FacadeViewModel>(); list.Add(new FacadeViewModel { Name = "Test A/c name", Cost = 24900, ImageUrl = "image url" }); list.Add(new FacadeViewModel { Name = "Test A/c name2", Cost = 25100, ImageUrl = "image url" }); list.Add(new FacadeViewModel { Name = "Test A/c name3", Cost = 26900, ImageUrl = "image url" }); list.Add(new FacadeViewModel { Name = "Test A/c name4", Cost = 29900, ImageUrl = "image url" }); list.Add(new FacadeViewModel { Name = "Test A/c name5", Cost = 24900, ImageUrl = "image url" }); list.Add(new FacadeViewModel { Name = "Test A/c name6", Cost = 25100, ImageUrl = "image url" }); quoteModel.Facades = list; var listPackages = new List <PackageViewModel>(); listPackages.Add(new PackageViewModel { Name = "Test A/c name", Cost = 634900, ImageUrl = "image url" }); listPackages.Add(new PackageViewModel { Name = "Test A/c name2", Cost = 614990, ImageUrl = "image url" }); listPackages.Add(new PackageViewModel { Name = "Test A/c name3", Cost = 849000, ImageUrl = "image url" }); listPackages.Add(new PackageViewModel { Name = "Test A/c name4", Cost = 611900, ImageUrl = "image url" }); listPackages.Add(new PackageViewModel { Name = "Test A/c name5", Cost = 598990, ImageUrl = "image url" }); listPackages.Add(new PackageViewModel { Name = "Test A/c name6", Cost = 799000, ImageUrl = "image url" }); var listInclusions = new List <InclusionViewModel>(); listInclusions.Add(new InclusionViewModel { Name = "Standard Inclusions", Cost = 0, ImageUrl = "/images/standard.jpg" }); listInclusions.Add(new InclusionViewModel { Name = "Gold Inclusions", Cost = 61499, ImageUrl = "/images/gold.jpg" }); listInclusions.Add(new InclusionViewModel { Name = "Platinum Inclusions", Cost = 71499, ImageUrl = "/images/platinum.jpg" }); var listDesigns = new List <DesignViewModel>(); listDesigns.Add(new DesignViewModel { Name = "Test A/c name", Cost = 634900, ImageUrl = "image url" }); listDesigns.Add(new DesignViewModel { Name = "Test A/c name2", Cost = 614990, ImageUrl = "image url" }); listDesigns.Add(new DesignViewModel { Name = "Test A/c name3", Cost = 849000, ImageUrl = "image url" }); listDesigns.Add(new DesignViewModel { Name = "Test A/c name4", Cost = 611900, ImageUrl = "image url" }); listDesigns.Add(new DesignViewModel { Name = "Test A/c name5", Cost = 598990, ImageUrl = "image url" }); var listPromotions = new List <PromotionViewModel>(); listPromotions.Add(new PromotionViewModel { Name = "Break Free Promotion", Cost = -1850, ImageUrl = "/images/promo1.jpg" }); listPromotions.Add(new PromotionViewModel { Name = "Spring Promotion", Cost = -2500, ImageUrl = "/images/promo2.jpg" }); quoteModel.Packages = listPackages; quoteModel.Inclusions = listInclusions; quoteModel.Designs = listDesigns; quoteModel.Promotions = listPromotions; // var htmmlString = RenderPartialViewToString("QuotePdfTemplate", vm); return(View("QuotePdfTemplate", vm)); }
private async Task <QuotesViewModel> GeneratePdfDocument(QuotesViewModel vm) { //var doc = @"https://docs.google.com/document/d/1Lm4WZMynzfOwjsFTFF7SLDvKYfb2AG6YRfpc9tFcepc"; // Response.Redirect($"{doc}"); //if (!ModelState.IsValid) //{ // return PartialView("_quoteEmailPartial", quoteModel); //} var facades = await _service.GetFacadesAsync(); var promotions = await _service.GetPromotionsAsync(); var packages = await _service.GetPackagesAsync(); var inclusions = await _service.GetInclusionsAsync(); var houseDesigns = await _service.GetHouseDesignsAsync(); var inclusionDetails = await _service.GetInclusionDetailsAsync(); var additionalInclusionDetails = await _service.GetAdditionalInclusionDetailsAsync(vm.Id); vm.SetMasterData(facades, promotions, houseDesigns, packages, inclusions, inclusionDetails, additionalInclusionDetails); DesignViewModel houseDesign = vm.HouseDesignId.HasValue ? vm.HouseDesigns.First(x => x.Id == vm.HouseDesignId.Value) : vm.HouseDesigns.First(); FacadeViewModel facade = vm.FacadeId.HasValue ? vm.Facades.First(x => x.Id == vm.FacadeId.Value) : vm.Facades.First(); InclusionViewModel inclusion = vm.InclusionId.HasValue ? vm.Inclusions.First(x => x.Id == vm.InclusionId.Value) : vm.Inclusions.First(); vm.HouseDesignName = houseDesign.Name; vm.InclusionName = inclusion.Name; vm.FacadeName = facade.Name; vm.BasePrice = houseDesign.Cost; vm.FacadeCost = facade.Cost == 0 ? "Included" : facade.Cost.ToString("C0"); var fileName = vm.JobNumber + "-" + Guid.NewGuid().ToString() + ".pdf"; var masterdata = inclusionDetails.ToTableData(vm.BasePrice, facade.Cost, vm.AdditionalInclusions); // await _service.GetContractDetails(); vm.TableData = masterdata; var htmmlString = RenderPartialViewToString("QuotePdfTemplate", vm); IronPdf.License.LicenseKey = _appSettings.IronPdfKey; var Renderer = new IronPdf.HtmlToPdf(); // Build a footer using html to style the text // mergable fields are: // {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title} Renderer.PrintOptions.Footer = new HtmlHeaderFooter() { Height = 30, HtmlFragment = "<center><div class=\"stl_01\" style=\"top: 64.9321em;white-space:nowrap;left:25.3123em;\"><span class=\"stl_20\">{page}</span></div></center>" + "<center><div class=\"stl_01\" style=\"top: 66.1712em; left: 13.3647em; \"><span class=\"stl_21 stl_10\" style=\"word - spacing:0.02em; \">(Test Company Pty Ltd) T/A Pty Ltd | ABN 12 345 678 900|</span><span class=\"stl_21 stl_10\" style=\"word-spacing:0.03em;\">company address</span>" + "<span class=\"stl_21 stl_10\" style=\"word-spacing:0.05em;\"></span></div></center>" + "<center><div class=\"stl_01\" style=\"top: 67.0469em; left:18.9945em;z-index:801;\"><span class=\"stl_21 stl_10\" style=\"word-spacing:0.27em;\">Ph: (02)</span>" + "<span class=\"stl_21 stl_10\" style=\"word-spacing:0.02em;\"> 8630</span><span class=\"stl_21 stl_10\" style=\"word-spacing:0.02em;\"> 8996 |</span>" + "<span class=\"stl_21 stl_10\" style=\"word-spacing:0em;\"> </span><a href = \"company url\" target=\"_blank\"><span class=\"stl_22\" style=\"word-spacing:0em;\"></span></a>" + "<a href = \"company url\" target=\"_blank\"><span class=\"stl_23 stl_10\" style=\"word-spacing:0em;\">www.testcompany<span class=\"stl_14\">.com.au </span></span></a></div></center>" + "<div class=\"stl_01\" style=\"top: 67.7975em; margin-left:3.7308em;\"><span class=\"stl_21 stl_14\" style=\"word-spacing:0em;\">Client Initial........../<span class=\"stl_10\">.......... </span></span></div>" + "<div class=\"stl_01\" style=\"top: 68.6107em; margin-left:3.7308em;\"><span class=\"stl_21 stl_10\" style=\"word-spacing:0.03em;\">Test Company - © 2020 </span></div>", DrawDividerLine = true }; // Build a header using an image asset // Note the use of BaseUrl to set a relative path to the assets //if cover page un comment below line Renderer.PrintOptions.FirstPageNumber = 2; Renderer.PrintOptions.Header = new HtmlHeaderFooter() { Height = 30, HtmlFragment = System.IO.File.ReadAllText($"{_env.WebRootPath}/templates/header.html"), BaseUrl = $"{_env.WebRootPath}/templates", Spacing = 5, DrawDividerLine = true, LoadStylesAndCSSFromMainHtmlDocument = true }; Renderer.PrintOptions.Zoom = 100; Renderer.PrintOptions.FitToPaperWidth = true; Renderer.PrintOptions.MarginTop = 0; //millimenters Renderer.PrintOptions.MarginLeft = 0; //millimenters Renderer.PrintOptions.MarginRight = 0; //millimenters Renderer.PrintOptions.MarginBottom = 50; var coverPageRenderer = new IronPdf.HtmlToPdf(); coverPageRenderer.PrintOptions.Zoom = 100; coverPageRenderer.PrintOptions.FitToPaperWidth = true; coverPageRenderer.PrintOptions.MarginTop = 0; //millimenters coverPageRenderer.PrintOptions.MarginLeft = 0; //millimenters coverPageRenderer.PrintOptions.MarginRight = 0; //millimenters Renderer.PrintOptions.MarginBottom = 0; var coverpageHtml = System.IO.File.ReadAllText($"{_env.WebRootPath}/templates/coverpage1.html").Replace("{{Name}}", vm.Name).Replace("{{JobNumber}}", vm.JobNumber).Replace("{{RequestType}}", vm.RequestType); var coverpage = coverPageRenderer.RenderHtmlAsPdf(coverpageHtml, $"{_env.WebRootPath}/templates"); //Renderer.RenderHtmlAsPdf(htmmlString).PrependPdf(coverPage).SaveAs("html-string.pdf"); //Renderer.RenderHtmlAsPdf(htmmlString).SaveAs("html-string.pdf"); var quoteDoc = Renderer.RenderHtmlAsPdf(htmmlString).PrependPdf(coverpage); //.Stream; //var stream = coverpage.Stream; // .SaveAs("html-string.pdf"); //var inclusionDoc = PdfDocument.FromFile($"{_env.WebRootPath}{inclusion.FileUrl}"); //quoteDoc = quoteDoc.AppendPdf(inclusionDoc); var quoteFromDb = await _service.GetQuoteByIdAsync(vm.Id); if (quoteFromDb.IsTender.HasValue && quoteFromDb.IsTender.Value && !string.IsNullOrEmpty(quoteFromDb.PdfUrl)) { // read file from Azure Syore using (MemoryStream mem = new MemoryStream()) { ConvertToStream(quoteFromDb.CustomPdfUrl, mem); var customPdfDoc = new PdfDocument(mem); quoteDoc = quoteDoc.AppendPdf(customPdfDoc); } } var stream = quoteDoc.Stream; //.SaveAs("html-string.pdf"); //await _azureStorageService.UploadDocAsync("html-string.pdf", vm.JobNumber +"-"+ Guid.NewGuid().ToString()+".pdf"); await _azureStorageService.UploadDocAsync(stream, fileName); var docVM = new DocumentViewModel { Name = fileName, Title = $"{vm.JobNumber} {vm.RequestType}", QuoteId = vm.Id }; await _service.SaveDocumentAsync(docVM, UserId); var docs = await _service.GetDocuments(vm.Id); vm.Documents = docs; //var context = new CustomAssemblyLoadContext(); //context.LoadUnmanagedLibrary(Path.Combine(Directory.GetCurrentDirectory(), "DinkToPdf.dll")); //var converter = new SynchronizedConverter(new PdfTools()); //converter.Convert(pdf); //var basePath = $"https://docs.google.com/document/d/"; //var id =_docGeneration.GenerateDoc(vm); //vm.DocUrl = $"{basePath}{id}"; //TempData["SuccessMessage"] = "The document has been generated successfully!!"; return(vm); }
// GET: /<controller>/ public IActionResult Index(string search, string sortOrder) { List <Quote> myQuotes = new List <Quote>(); string mySelectQuery = "SELECT" + " q.quoteID " + ", q.dateAdded " + ", q.firstName " + ", q.lastName " + ", q.deskID " + ", q.shippingDays " + ", q.shippingPrice " + ", q.quoteAmount " + ", d.deskWidth " + ", d.deskLength " + ", d.drawers " + ", d.materialID " + ", m.materialID " + ", m.description " + ", m.price " + " FROM Quote q " + " INNER JOIN(" + " SELECT" + " deskId, " + " deskWidth, " + " deskLength, " + " drawers, " + " materialID " + " FROM Desk ) AS d " + " on d.deskId = q.deskID " + " INNER JOIN(" + " SELECT " + " materialID," + " description," + " price " + " FROM Material) AS m " + " on m.materialID = d.materialID "; if (search != null) { mySelectQuery += " WHERE q.lastName LIKE '%" + search + "%'"; } if (sortOrder != null) { mySelectQuery += " ORDER BY " + sortOrder; } MySqlConnection myConnection = new MySqlConnection(connecitonString); MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); myConnection.Open(); MySqlDataReader myReader; myReader = myCommand.ExecuteReader(); // Always call Read before accessing data. while (myReader.Read()) { myQuotes.Add( new Quote { Id = Int32.Parse(myReader["quoteID"].ToString()), Date = DateTime.Parse(myReader["dateAdded"].ToString()), FirstName = myReader["firstName"].ToString(), LastName = myReader["lastName"].ToString(), DeskWidth = Double.Parse(myReader["deskWidth"].ToString()), DeskLength = Double.Parse(myReader["deskLength"].ToString()), Drawers = Int32.Parse(myReader["drawers"].ToString()), Material = myReader["description"].ToString(), MaterialPrice = Double.Parse(myReader["price"].ToString()), ShippingDays = Int32.Parse(myReader["shippingDays"].ToString()), ShippingPrice = Double.Parse(myReader["shippingPrice"].ToString()), Amount = Double.Parse(myReader["quoteAmount"].ToString()) }); } QuotesViewModel vm = new QuotesViewModel { myQuotes = myQuotes, search = search, sort = sortOrder }; return(View(vm)); }