public ActionResult Save(Slide slide) { slide.Image = new ImageView { ImageUrl = Request["imageUrl"] }; if (ModelState.IsValid) { db.Slides.Add(slide); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PostId = new SelectList(db.Posts, "PostId", "Title", slide.PostId); return View("CreateStep3", slide); }
public ActionResult CreateStep3(ImageInput editor) { var image = new WebImage("~" + editor.Image.ImageUrl); var height = image.Height; var width = image.Width; var tempUrl = editor.Image.ImageUrl; var saveUrl = @BlogGlobals.SlideImageFolder + Path.GetFileName(image.FileName); image.Crop((int)editor.Top, (int)editor.Left, (int)(height - editor.Bottom), (int)(width - editor.Right)); image.Resize(190, 190, true, false); image.Save(saveUrl); System.IO.File.Delete(Server.MapPath(tempUrl)); ViewBag.PostId = new SelectList(db.Posts, "PostId", "Title"); ViewBag.imageUrl = saveUrl; Slide slide = new Slide(); return View("CreateStep3", slide); }
public ActionResult Edit(Slide slide) { if (ModelState.IsValid) { db.Entry(slide).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PostId = new SelectList(db.Posts, "PostId", "Title", slide.PostId); return View(slide); }