/// <summary> /// Create a new TechnologyImage object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="imageSource">Initial value of the ImageSource property.</param> /// <param name="technologyItemId">Initial value of the TechnologyItemId property.</param> public static TechnologyImage CreateTechnologyImage(global::System.Int32 id, global::System.String imageSource, global::System.Int32 technologyItemId) { TechnologyImage technologyImage = new TechnologyImage(); technologyImage.Id = id; technologyImage.ImageSource = imageSource; technologyImage.TechnologyItemId = technologyItemId; return technologyImage; }
/// <summary> /// Deprecated Method for adding a new object to the TechnologyImage EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTechnologyImage(TechnologyImage technologyImage) { base.AddObject("TechnologyImage", technologyImage); }
public ActionResult AddImage(int id, FormCollection form) { var technologyItem = _context.TechnologyItem.Include("Technology").First(t => t.Id == id); var technology = _context.Technology.Include("Parent").First(t => t.Id == technologyItem.Technology.Id); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file == null) continue; if (string.IsNullOrEmpty(file.FileName)) continue; var ti = new TechnologyImage(); string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName); string filePath = Server.MapPath("~/Content/Images"); filePath = Path.Combine(filePath, fileName); //GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500); file.SaveAs(filePath); ti.ImageSource = fileName; technologyItem.TechnologyImages.Add(ti); _context.SaveChanges(); } string categoryId; string subCategoryId = null; if (technology.Parent == null) { categoryId = technology.Name; } else { categoryId = technology.Parent.Name; subCategoryId = technology.Name; } return RedirectToAction("Technologies", "Home", new { area = "", categoryId = categoryId, subCategoryId = subCategoryId }); }