public ActionResult Create(FormCollection form) { var slider = new Slider(); TryUpdateModel(slider, new[] {"Url"}); if (Request.Files["banner"] != null && !string.IsNullOrEmpty(Request.Files["banner"].FileName)) { string fileName = IOHelper.GetUniqueFileName("~/Content/Images", Request.Files["banner"].FileName); string filePath = Server.MapPath("~/Content/Images"); filePath = Path.Combine(filePath, fileName); Request.Files["banner"].SaveAs(filePath); slider.ImageSource = fileName; } _context.AddToSlider(slider); _context.SaveChanges(); return RedirectToAction("Index", "Slider", new { area = "Admin" }); }
/// <summary> /// Deprecated Method for adding a new object to the Slider EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSlider(Slider slider) { base.AddObject("Slider", slider); }
/// <summary> /// Create a new Slider object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="url">Initial value of the Url property.</param> /// <param name="imageSource">Initial value of the ImageSource property.</param> public static Slider CreateSlider(global::System.Int32 id, global::System.String url, global::System.String imageSource) { Slider slider = new Slider(); slider.Id = id; slider.Url = url; slider.ImageSource = imageSource; return slider; }