コード例 #1
0
ファイル: BannerController.cs プロジェクト: fathurxzz/aleqx
 public ActionResult Create(FormCollection collection, HttpPostedFileBase fileUpload)
 {
     try
     {
         using (var context = new SiteContainer())
         {
             var banner = new Banner();
             TryUpdateModel(banner, new[] { "Description", "Link", "Price" });
             if (fileUpload != null)
             {
                 string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName);
                 string filePath = Server.MapPath("~/Content/Images");
                 filePath = Path.Combine(filePath, fileName);
                 fileUpload.SaveAs(filePath);
                 banner.ImageSource = fileName;
             }
             context.AddToBanner(banner);
             context.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }
コード例 #2
0
ファイル: Site.Designer.cs プロジェクト: fathurxzz/aleqx
 /// <summary>
 /// Create a new Banner object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="imageSource">Initial value of the ImageSource property.</param>
 public static Banner CreateBanner(global::System.Int32 id, global::System.String imageSource)
 {
     Banner banner = new Banner();
     banner.Id = id;
     banner.ImageSource = imageSource;
     return banner;
 }
コード例 #3
0
ファイル: Site.Designer.cs プロジェクト: fathurxzz/aleqx
 /// <summary>
 /// Deprecated Method for adding a new object to the Banner EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBanner(Banner banner)
 {
     base.AddObject("Banner", banner);
 }