// GET: Quotes/Create public IActionResult Create(long? id, string role, string quoteNumber) { if (id == null || string.IsNullOrWhiteSpace(role)) { return NotFound(); } var model = new iPromo.Entities.Quote(); if (string.IsNullOrWhiteSpace(quoteNumber)) { model.QuoteStatusResultID = 12; model.QuoteStatusLevelID = 2; model.SubmitDatetime = DateTime.Now; model.NeedPriceApprovedBy = DateTime.Now.AddDays(3);//TODO?: Hardcode value, need from configuration? model.QuoteNumber = "Auto Assigned"; } else { model = _context.Quote.FirstOrDefault(f => f.QuoteNumber == quoteNumber); string soldToName = string.Empty; mtCustomer mcSoldToName = _context.mtCustomer.FirstOrDefault(f => f.CustomerNumber == model.PlanningAccountNumber); if (mcSoldToName != null) soldToName = mcSoldToName.Customer_Desc; ViewBag.SoldToName = soldToName; string tier2CustomerName = string.Empty; mtCustomer mcTier2CustomerName = _context.mtCustomer.FirstOrDefault(f => f.CustomerNumber == model.EndCustomerID); if (mcTier2CustomerName != null) tier2CustomerName = mcTier2CustomerName.Customer_Desc; ViewBag.Tier2CustomerName = tier2CustomerName; string endCustomerName = string.Empty; mtCustomer mcEndCustomerName = _context.mtCustomer.FirstOrDefault(f => f.CustomerNumber == model.EndUser); if (mcEndCustomerName != null) endCustomerName = mcEndCustomerName.Customer_Desc; ViewBag.EndCustomerName = endCustomerName; ViewBag.Currency = string.IsNullOrEmpty(model.Currency) ? null : model.Currency; string accountManagerName = string.Empty; SalesOrg soAccountManagerName = _context.SalesOrg.FirstOrDefault(f => f.UserID == model.AccountManagerID); if (soAccountManagerName != null) accountManagerName = soAccountManagerName.UserName; ViewBag.AccountManagerName = accountManagerName; ViewBag.QuoteNumber = model.QuoteNumber; var uploadPath = Directory.GetCurrentDirectory() + "/wwwroot/_Documents/" + quoteNumber; if (Directory.Exists(uploadPath) == true) { var files = Directory.GetFiles(uploadPath); var fileList = new Dictionary<string, string>(); for (int i = 0; i < files.Length; i++) { fileList[files[i].Substring(files[i].LastIndexOf("\\") + 1)] = files[i].Substring(files[i].LastIndexOf("/_Documents")); } ViewBag.Files = fileList; } } return View(model); }
public async Task<IActionResult> ReadOnly(long? id, string role, string quoteNumber) { ViewBag.QuoteNumber = quoteNumber; if (id == null || string.IsNullOrWhiteSpace(role) || string.IsNullOrWhiteSpace(quoteNumber)) { return NotFound(); } var quote = await _context.Quote .SingleOrDefaultAsync(m => m.QuoteNumber == quoteNumber); if (quote == null) { return NotFound(); } string soldToName = string.Empty; mtCustomer mcSoldToName = _context.mtCustomer.FirstOrDefault(f => f.CustomerNumber == quote.PlanningAccountNumber); if (mcSoldToName != null) soldToName = mcSoldToName.Customer_Desc; ViewBag.SoldToName = soldToName; string tier2CustomerName = string.Empty; mtCustomer mcTier2CustomerName = _context.mtCustomer.FirstOrDefault(f => f.CustomerNumber == quote.EndCustomerID); if (mcTier2CustomerName != null) tier2CustomerName = mcTier2CustomerName.Customer_Desc; ViewBag.Tier2CustomerName = tier2CustomerName; string endCustomerName = string.Empty; mtCustomer mcEndCustomerName = _context.mtCustomer.FirstOrDefault(f => f.CustomerNumber == quote.EndUser); if (mcEndCustomerName != null) endCustomerName = mcEndCustomerName.Customer_Desc; ViewBag.EndCustomerName = endCustomerName; ViewBag.Currency = string.IsNullOrEmpty(quote.Currency) ? null : quote.Currency; string accountManagerName = string.Empty; SalesOrg soAccountManagerName = _context.SalesOrg.FirstOrDefault(f => f.UserID == quote.AccountManagerID); if (soAccountManagerName != null) accountManagerName = soAccountManagerName.UserName; ViewBag.AccountManagerName = accountManagerName; ViewBag.QuoteNumber = quote.QuoteNumber; var uploadPath = Directory.GetCurrentDirectory() + "/wwwroot/_Documents/" + quoteNumber; if (Directory.Exists(uploadPath) == true) { var files = Directory.GetFiles(uploadPath); var fileList = new Dictionary<string, string>(); for (int i = 0; i < files.Length; i++) { fileList[files[i].Substring(files[i].LastIndexOf("\\") + 1)] = files[i].Substring(files[i].LastIndexOf("/_Documents")); } ViewBag.Files = fileList; } return View("ReadOnly", quote); }