public ActionResult Save(EditStepTwo model) { ImageManager mngr = new ImageManager(); Picture pic = new Picture(); try { pic.ID = model.ID; pic.Link = model.Link; var im = Image.FromStream(model.Image.InputStream); if (im.Width > 1000 || im.Height > 1000) { throw new Exception("Too large image!"); } if (im.Height != model.Height || im.Width != model.Width) { throw new Exception("The image has to have same width and height as the old one!!"); } ImageConverter con = new ImageConverter(); pic.Data = (byte[])con.ConvertTo(im, typeof(byte[])); pic.ContentType = model.Image.ContentType; pic.User = User.Identity.Name; mngr.Save(pic); } catch (Exception ex) { return(View("Error", ex)); } return(View("EditSuccess")); }
public ActionResult EditStepTwo(string id, int width, int height) { EditStepTwo model = new EditStepTwo(); model.ID = id; model.Width = width; model.Height = height; return(View(model)); }