public ActionResult Receive(HttpPostedFileBase fileData, string atlasId) { var remark = String.Empty; if (String.IsNullOrEmpty(atlasId)) { remark = @"图册编号为空,请确认后再提交"; var data = new { state = false, description = remark }; return(Json(data)); } if (fileData != null && fileData.ContentLength > 0) { var atlasGuid = new Guid(atlasId); var temp = _atlasService.GetAtlasById(atlasGuid); if (temp == null) { remark = String.Format("未能根据编号[{0}]找到该分享图册", atlasId); var data = new { state = false, description = remark }; return(Json(data)); } const bool isWater = false; const bool isThumbnail = true; var upload = new UploadUtility(StoreAreaForUpload.ForGallery); var photoDto = upload.PictureSaveAs(fileData, isThumbnail, isWater, false); if (photoDto.PhotoId == Guid.Empty) { var data = new { state = false, description = photoDto.Remark }; return(Json(data, JsonRequestBehavior.AllowGet)); } photoDto.AtlasId = atlasGuid; photoDto.Remark = @"暂无描述..."; _photoService.AddPhoto(photoDto); var result = new { state = true, item = photoDto }; return(Json(result, JsonRequestBehavior.AllowGet)); } var error = new { state = false, description = @"无上传的图片" }; return(Json(error, JsonRequestBehavior.AllowGet)); }
public ActionResult Receive(HttpPostedFileBase fileData) { if (fileData != null && fileData.ContentLength > 0) { const bool isWater = false; const bool isThumbnail = true; var upload = new UploadUtility(); var photoDto = upload.PictureSaveAs(fileData, isThumbnail, isWater, false); if (photoDto.PhotoId == Guid.Empty) { var data = new { state = false, description = photoDto.Remark }; return(Json(data, JsonRequestBehavior.AllowGet)); } _photoService.AddPhoto(photoDto); var result = new { state = true, item = photoDto }; return(Json(result, JsonRequestBehavior.AllowGet)); } var error = new { state = false, description = @"无上传的图片" }; return(Json(error, JsonRequestBehavior.AllowGet)); }