예제 #1
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                if (fileUpload != null)
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/ActualTours", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/ActualTours");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);

                    var tour = new ActualTours();
                    TryUpdateModel(tour, new[] { "Price", "Title", "Description", "Sign1", "Sign2", "Sign3", "Sign4", "Sign5" });
                    tour.Text = HttpUtility.HtmlDecode(form["Text"]);
                    tour.ImageSource = fileName;
                    context.AddToActualTours(tour);
                    context.SaveChanges();
                }

            }
            return RedirectToAction("Index", "Home", new { Area = "", id = "" });
        }