/// <summary> /// Deprecated Method for adding a new object to the cg_Products_Photos EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTocg_Products_Photos(cg_Products_Photos cg_Products_Photos) { base.AddObject("cg_Products_Photos", cg_Products_Photos); }
public ActionResult product_photo_new(FormCollection collection) { long ProductId = Convert.ToInt64(collection["ProductId"]); cg_Products product = db.cg_Products.Where(p => p.ProductId == ProductId).FirstOrDefault(); cg_Products_Photos ppItem = new cg_Products_Photos(); // Get file HttpPostedFileBase file = Request.Files["OriginalFileName"]; string fileExtension = Path.GetExtension(file.FileName); // Add file info ppItem.ListOrder = Convert.ToInt32(collection["ListOrder"]); ppItem.OriginalFileName = file.FileName; ppItem.Description = collection["Description"]; ppItem.FileExtension = fileExtension; // Add object product.cg_Products_Photos.Add(ppItem); // Save to DB and get the new ID db.SaveChanges(); if (file.ContentLength > 0) { string filePath = Path.Combine(HttpContext.Server.MapPath("~/content/trip-photos"), ppItem.ProductPhotoId + fileExtension); file.SaveAs(filePath); } return RedirectToAction("product_edit", new { id = ProductId }); }
/// <summary> /// Create a new cg_Products_Photos object. /// </summary> /// <param name="productPhotoId">Initial value of the ProductPhotoId property.</param> public static cg_Products_Photos Createcg_Products_Photos(global::System.Int64 productPhotoId) { cg_Products_Photos cg_Products_Photos = new cg_Products_Photos(); cg_Products_Photos.ProductPhotoId = productPhotoId; return cg_Products_Photos; }
public ActionResult product_photos_add(FormCollection collection) { long ProductId = Convert.ToInt64(collection["ProductId"]); cg_Products product = db.cg_Products.Where(p => p.ProductId == ProductId).FirstOrDefault(); cg_Products_Photos newItem = new cg_Products_Photos(); // Get file HttpPostedFileBase file = Request.Files["OriginalFileName"]; //Response.Write("Request.Files: " + Request.Files.Count); //Response.End(); string fileExtension = Path.GetExtension(file.FileName); // Add mockup info newItem.OriginalFileName = file.FileName; newItem.Description = collection["Description"]; newItem.FileExtension = fileExtension; // Add object product.cg_Products_Photos.Add(newItem); db.SaveChanges(); if (file.ContentLength > 0) { string filePath = Path.Combine(HttpContext.Server.MapPath("~/content/galleries/items"), newItem.ProductPhotoId + fileExtension); file.SaveAs(filePath); } return RedirectToAction("product", new { id = ProductId }); }