public ActionResult SavePage(PageEditModel model) { if (!(model.icon_url.IndexOf("http") >= 0)) { string path = Server.MapPath("~" + model.icon_url); using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { System.Drawing.Image image = System.Drawing.Image.FromStream(fs); int width = image.Width; int height = image.Height; if (width != height) { throw new HimallException("图片必须为正方形"); } } model.icon_url = this._iShakeAroundService.UploadImage(path); } if (model.id == 0) { bool result = this._iShakeAroundService.AddPage(model.title, model.description, model.page_url, model.icon_url, model.comment); return(Json(new { success = result })); } else { bool result = this._iShakeAroundService.UpdatePage(model.page_id, model.title, model.description, model.page_url, model.icon_url, model.comment); return(Json(new { success = result })); } }
public ActionResult SavePage(PageEditModel model) { if (model.icon_url.IndexOf("http") < 0) { string str = Server.MapPath(string.Concat("~", model.icon_url)); using (FileStream fileStream = new FileStream(str, FileMode.Open, FileAccess.Read)) { Image image = Image.FromStream(fileStream); if (image.Width != image.Height) { throw new HimallException("图片必须为正方形"); } } model.icon_url = _saService.UploadImage(str); } if (model.id == 0) { bool flag = _saService.AddPage(model.title, model.description, model.page_url, model.icon_url, model.comment); return(Json(new { success = flag })); } bool flag1 = _saService.UpdatePage(model.page_id, model.title, model.description, model.page_url, model.icon_url, model.comment); return(Json(new { success = flag1 })); }