Beispiel #1
0
 public ActionResult AddImage(IEnumerable<HttpPostedFileBase> fileUpload)
 {
     using (var context = new CatalogueContainer())
     {
         foreach (var file in fileUpload)
         {
             if (file != null)
             {
                 string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                 string filePath = Server.MapPath("~/Content/Images");
                 filePath = Path.Combine(filePath, fileName);
                 file.SaveAs(filePath);
                 var mpi = new MainPageImage() {ImageSource = fileName};
                 context.AddToMainPageImage(mpi);
                 context.SaveChanges();
             }
         }
         return RedirectToAction("Index", "Home", new {area = ""});
     }
 }
Beispiel #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the MainPageImage EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMainPageImage(MainPageImage mainPageImage)
 {
     base.AddObject("MainPageImage", mainPageImage);
 }
Beispiel #3
0
 /// <summary>
 /// Create a new MainPageImage object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="imageSource">Initial value of the ImageSource property.</param>
 public static MainPageImage CreateMainPageImage(global::System.Int32 id, global::System.String imageSource)
 {
     MainPageImage mainPageImage = new MainPageImage();
     mainPageImage.Id = id;
     mainPageImage.ImageSource = imageSource;
     return mainPageImage;
 }