Exemple #1
0
        public ActionResult Create(Banner banner, HttpPostedFileBase imagen)
        {
            if (ModelState.IsValid)
            {
                banner.Timestamp = DateTime.Now;

                var filename = Guid.NewGuid();

                bool IsExist = Directory.Exists(Server.MapPath("~/Content/Upload/Banners/" + banner.IdBannerType));
                if (!IsExist)
                    Directory.CreateDirectory(Server.MapPath("~/Content/Upload/Banners/" + banner.IdBannerType));

                var path = Server.MapPath("~/Content/Upload/Banners/" + banner.IdBannerType + "/" + filename.ToString().Substring(0, 8) + ".jpg");
                imagen.SaveAs(path);
                banner.URL = "~/Content/Upload/Banners/" + banner.IdBannerType + "/" + filename.ToString().Substring(0, 8) + ".jpg";
                banner.Featured = false;
                db.Banner.AddObject(banner);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.IdBannerType = new SelectList(db.BannerType, "Id", "Name", banner.IdBannerType);
            return View(banner);
        }
Exemple #2
0
 /// <summary>
 /// Create a new Banner object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="uRL">Initial value of the URL property.</param>
 /// <param name="timestamp">Initial value of the Timestamp property.</param>
 /// <param name="featured">Initial value of the Featured property.</param>
 /// <param name="active">Initial value of the Active property.</param>
 /// <param name="idBannerType">Initial value of the IdBannerType property.</param>
 public static Banner CreateBanner(global::System.Int32 id, global::System.String uRL, global::System.DateTime timestamp, global::System.Boolean featured, global::System.Boolean active, global::System.Int32 idBannerType)
 {
     Banner banner = new Banner();
     banner.Id = id;
     banner.URL = uRL;
     banner.Timestamp = timestamp;
     banner.Featured = featured;
     banner.Active = active;
     banner.IdBannerType = idBannerType;
     return banner;
 }
Exemple #3
0
 /// <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);
 }