/// <summary> /// Processes the save. /// </summary> private void ProcessSave() { if (Session["Upload_File"] != null && !string.IsNullOrWhiteSpace(Session["Upload_File"].ToString())) { var fileName = Session["Upload_File"].ToString(); var cropUtils = new CropImageUtility(this.UploadPath, this.OriginalPath, ""); var result = cropUtils.SaveUploadImageToOriginalFolder(fileName); if (!result["result"].Equals("Success", StringComparison.OrdinalIgnoreCase)) { ClientScriptHelper.ShowMessage(this.Page, result["msg"], RegisterScriptType.Start); } else { var instance = new UploadImage { ID = Guid.NewGuid(), OriginalImage = fileName, CreateDate = DateTime.Now }; instance.UpdateDate = instance.CreateDate; _service.Add(instance); this.HiddenField_ID.Value = instance.ID.ToString(); this.Image_Upload.ImageUrl = string.Format("{0}/{1}/{2}", this.WebSiteRootPath, this.OriginalFolder.Replace("~", ""), fileName); this.Button_Save.Visible = false; this.Button_Cancel.Visible = false; if (!string.IsNullOrWhiteSpace(this.HiddenField_ID.Value)) { this.Button_Crop.Visible = true; } } } }
public JsonResult Save(string fileName) { var jo = new Dictionary <string, string>(); var cropUtils = new CropImageUtility(this.UploadPath, this.OriginalPath, ""); var result = cropUtils.SaveUploadImageToOriginalFolder(fileName); if (!result["result"].Equals("Success", StringComparison.OrdinalIgnoreCase)) { jo.Add("result", result["result"]); jo.Add("msg", result["msg"]); return(Json(jo)); } try { var instance = new ImageCrop.Common.UploadImage { ID = Guid.NewGuid(), OriginalImage = fileName, CreateDate = DateTime.Now }; instance.UpdateDate = instance.CreateDate; _service.Add(instance); jo.Add("result", "Success"); jo.Add("msg", string.Format(@"/{0}/{1}", OriginalFolder, fileName)); jo.Add("id", instance.ID.ToString()); } catch (Exception ex) { jo.Add("result", "Exception"); jo.Add("msg", ex.Message); } return(Json(jo)); }
public JsonResult Save(string fileName) { var jo = new Dictionary <string, string>(); CropImageUtility cropUtils = new CropImageUtility(this.UploadPath, this.OriginalPath, string.Empty); var result = cropUtils.SaveUploadImageToOriginalFolder(fileName); if (!result["result"].Equals("success", StringComparison.OrdinalIgnoreCase)) { jo.Add("result", result["result"]); jo.Add("msg", result["msg"]); return(Json(jo)); } try { UploadImage instance = new UploadImage() { ID = Guid.NewGuid(), OriginalImage = fileName, CreateDate = DateTime.Now, UpdateDate = DateTime.Now }; service.Add(instance); jo.Add("result", "success"); jo.Add("msg", string.Format(@"/{0}/{1}", OriginalFolder, fileName)); jo.Add("id", instance.ID.ToString()); return(Json(jo)); } catch (Exception ex) { return(Json(MiscUtility.GetExceptionMsg(ex.Message))); } }