public async Task <IActionResult> Edit(int id, [Bind("Id,Description,UploadDate,Content,ImageFormat,ImageName,TechnologyId")] TechnologyImage technologyImage) { if (id != technologyImage.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(technologyImage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TechnologyImageExists(technologyImage.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TechnologyId"] = new SelectList(_context.Technologies, "Id", "Id", technologyImage.TechnologyId); return(View(technologyImage)); }
public async Task <IActionResult> Create([Bind("Id,Description,UploadDate,Content,ImageFormat,ImageName,TechnologyId")] TechnologyImage technologyImage) { if (ModelState.IsValid) { _context.Add(technologyImage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TechnologyId"] = new SelectList(_context.Technologies, "Id", "Id", technologyImage.TechnologyId); return(View(technologyImage)); }
public void AerodynamicsButtonPressed() { FeatureImage.SetActive(false); FeaturePanel.SetActive(false); AerodynamicsImage.SetActive(true); AerodynamicsPanel.SetActive(true); SafetyImage.SetActive(false); safetyPanel.SetActive(false); ConnectivityImage.SetActive(false); ConnectivityPanel.SetActive(false); TechnologyImage.SetActive(false); TechnologyPanel.SetActive(false); }
public async Task <ActionResult> RenderImage(int id) { TechnologyImage item = await _context.TechnologyImage.FindAsync(id); byte[] photoBack = item.Content; if (item.ImageFormat == ImageFormat.JPEG) { return(File(photoBack, "image/jpeg")); } else { return(File(photoBack, "image/png")); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Description")] Technology technology, IFormFile technologyImage) { if (id != technology.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var oldEntity = _context.Technologies.Where(x => x.Id == id).Include(x => x.Images).FirstOrDefault(); if (technologyImage != null) { var newIMage = new TechnologyImage { Content = GetResized(technologyImage), Description = "", ImageName = technologyImage.FileName, UploadDate = DateTime.Now, ImageFormat = technologyImage.ContentType.ToUpper().Contains("PNG") ? ImageFormat.PNG : ImageFormat.JPEG }; oldEntity.Images.Add(newIMage); } oldEntity.Description = technology.Description; _context.Update(oldEntity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TechnologyExists(technology.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BrandId"] = new SelectList(_context.Brands, "Id", "Id", technology.BrandId); return(View(technology)); }