public async Task <IActionResult> Edit(int id, [Bind("ProductOptionId,ProductId,Type,Name,FileName,Image,FormFile,Default,StockCode,Disabled")] ProductOption productOption) { if (id != productOption.ProductOptionId) { return(NotFound()); } if (ModelState.IsValid) { if (productOption.FormFile != null) { MemoryStream ms = new MemoryStream(); await productOption.FormFile.CopyToAsync(ms); productOption.FileName = productOption.FormFile.FileName; productOption.Image = ms.ToArray(); } try { _context.Update(productOption); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductOptionExists(productOption.ProductOptionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index), new { id = productOption.ProductId })); } productOption.Types = new SelectList(new List <string>() { "Fabric", "Mesh", "Frame", "Arms", "Castors" }); return(View(productOption)); }
public async Task <IActionResult> Edit(int id, Production production) { if (id != production.User.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { if (production.User.Shipped == null) { production.User.Shipped = DateTime.Now; } _context.Update(production.User); await _context.SaveChangesAsync(); if (!string.IsNullOrEmpty(production.User.TrackingNumber)) { EmailUser(production.User); } } catch (DbUpdateConcurrencyException) { if (!UserExists(production.User.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(production)); }
public async Task <IActionResult> Edit(int id, [Bind("ProductImageId,ProductId,ProductOption1Id,ProductOption2Id,ProductOption3Id,FileName,Image,FormFile")] ProductImage productImage) { if (id != productImage.ProductImageId) { return(NotFound()); } if (ModelState.IsValid) { try { if (productImage.FormFile != null) { MemoryStream ms = new MemoryStream(); await productImage.FormFile.CopyToAsync(ms); productImage.FileName = productImage.FormFile.FileName; productImage.Image = ms.ToArray(); } _context.Update(productImage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductImageExists(productImage.ProductImageId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index), new { id = productImage.ProductId })); } return(View(productImage)); }
public async Task <IActionResult> Edit(int id, [Bind("ProductId,DealerCode,Ponumber,Chair,Image,FormFile3,Language,LogoFile,LogoImage,FormFile,LogoFile2,LogoImage2,FormFile2,InstallGuide,UserGuide,VideoUrl,SitFitGuide,VerifyOnly,Shipper,Config")] Product product) { if (id != product.ProductId) { return(NotFound()); } if (ModelState.IsValid) { if (product.FormFile != null) { MemoryStream ms = new MemoryStream(); await product.FormFile.CopyToAsync(ms); product.LogoFile = product.FormFile.FileName; product.LogoImage = ms.ToArray(); } if (product.FormFile2 != null) { MemoryStream ms = new MemoryStream(); await product.FormFile2.CopyToAsync(ms); product.LogoFile2 = product.FormFile2.FileName; product.LogoImage2 = ms.ToArray(); } if (product.FormFile3 != null) { MemoryStream ms = new MemoryStream(); await product.FormFile3.CopyToAsync(ms); product.Image = ms.ToArray(); } try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } product.Languages = new SelectList(new List <string>() { "English", "French" }); product.Shippers = new SelectList(new List <string>() { "FEDEX", "UPS" }); return(View(product)); }
public async Task <IActionResult> Create([Bind("UserId,ProductId,EmailAddress,Language,Pin,Address1,Address2,City,ProvinceState,PostalZip,Country,SpecialInstructions,Commercial,Emailed,Completed,InProduction,Shipped")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); var product = await _context.Product.FirstOrDefaultAsync(m => m.ProductId == user.ProductId); List <ProductOption> productOptions = await _context.ProductOption.Where(x => x.ProductId == user.ProductId).ToListAsync(); foreach (var item in productOptions) { if (item.Default) { _context.Add(new UserSelection() { UserId = user.UserId, ProductOptionId = item.ProductOptionId, Type = item.Type }); } } await _context.SaveChangesAsync(); if (!string.IsNullOrEmpty(user.Pin) && user.Emailed == null) { string url = _configuration.GetValue <string>("AppSettings:UserUrl") + user.ProductId; string body = "<a href='" + url + "'>Click here</a> to access the site.<br/><br/>Your log in PIN is " + user.Pin + "."; string file = _env.WebRootPath + "\\emails\\email1_" + user.Language + ".txt"; if (product.VerifyOnly) { file = _env.WebRootPath + "\\emails\\email1v_" + user.Language + ".txt"; } StreamReader sr = new StreamReader(file); if (sr != null) { string[] parameters = new string[] { url, user.Pin }; body = string.Format(sr.ReadToEnd(), parameters); sr.Close(); sr.Dispose(); } string subject = "The way we sit matters."; if (user.Language == "French") { subject = "La position dans laquelle nous nous assoyons révèle bien des choses."; } var emessage = new MailMessage("*****@*****.**", user.EmailAddress, subject, body) { IsBodyHtml = true, BodyEncoding = System.Text.Encoding.UTF8 }; emessage.Bcc.Add("*****@*****.**"); emessage.Bcc.Add("*****@*****.**"); using SmtpClient SmtpMail = new SmtpClient("allfs90.allseating.com", 25) { UseDefaultCredentials = true }; SmtpMail.Send(emessage); emessage.Dispose(); user.Emailed = DateTime.Now; _context.Update(user); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } user.Languages = new SelectList(new List <string>() { "English", "French" }); return(View(user)); }