Пример #1
0
        public ActionResult Edit(Banner model, FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                var bellboy = context.Bellboy.Where(b => b.Id == model.Id).First();
                string fileName = bellboy.ImageSource;

                if (fileUpload != null)
                {
                    IOHelper.DeleteFile("~/Content/Bellboy", bellboy.ImageSource);

                    fileName = IOHelper.GetUniqueFileName("~/Content/Bellboy", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Bellboy");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);
                }
                TryUpdateModel(bellboy, new[] { "TopText", "TopLink", "BottomText", "BottomLink" });
                bellboy.ImageSource = fileName;
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Bellboy", new { Area = "Admin" });
        }
Пример #2
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                if (fileUpload != null)
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Banners", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Banners");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);

                    var banner = new Banner();
                    TryUpdateModel(banner, new[] { "Price", "Title", "Title2", "ContentName" });
                    banner.BannerType = Convert.ToInt32(form["BannerType"]);
                    banner.ImageSource = fileName;
                    context.AddToBanner(banner);
                    context.SaveChanges();
                }

            }
            return RedirectToAction("Index", "Banner", new { Area = "Admin" });
        }
Пример #3
0
        public ActionResult Edit(Banner model, FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                var banner = context.Banner.Where(b => b.Id == model.Id).First();
                string fileName = banner.ImageSource;

                if (fileUpload != null)
                {
                    IOHelper.DeleteFile("~/Content/Banners", banner.ImageSource);

                    fileName = IOHelper.GetUniqueFileName("~/Content/Banners", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Banners");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);
                }
                TryUpdateModel(banner, new[] { "Price", "Title", "Title2", "ContentName" });
                banner.BannerType = Convert.ToInt32(form["BannerType"]);
                banner.ImageSource = fileName;
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Banner", new { Area = "Admin" });
        }
Пример #4
0
        public ActionResult Edit(Banner model, FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                var tour = context.ActualTours.First(t => t.Id == model.Id);
                string fileName = tour.ImageSource;

                if (fileUpload != null)
                {
                    IOHelper.DeleteFile("~/Content/ActualTours", tour.ImageSource);

                    fileName = IOHelper.GetUniqueFileName("~/Content/ActualTours", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/ActualTours");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);
                }
                TryUpdateModel(tour, new[] { "Price", "Title", "Description", "Sign1", "Sign2", "Sign3", "Sign4", "Sign5" });
                tour.Text = HttpUtility.HtmlDecode(form["Text"]);
                tour.ImageSource = fileName;
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Home", new { Area = "",id="" });
        }
Пример #5
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);
 }
Пример #6
0
 /// <summary>
 /// Create a new Banner object.
 /// </summary>
 /// <param name="bannerType">Initial value of the BannerType property.</param>
 /// <param name="id">Initial value of the Id property.</param>
 public static Banner CreateBanner(global::System.Int32 bannerType, global::System.Int32 id)
 {
     Banner banner = new Banner();
     banner.BannerType = bannerType;
     banner.Id = id;
     return banner;
 }