public JsonResult Save(ReportEditDto detail) { bool status = false; string msg = ""; if (detail.Id > 0) { try { var oldReport = _reportAppService.GetReportByIdAsync(new EntityDto <int>(detail.Id.Value)); if (oldReport != null) { detail.Img = oldReport.Result.Img; ImgUploadHelpers uploadHelpers = new ImgUploadHelpers(Request.Files, Server.MapPath("/")); var uploadResult = uploadHelpers.UploadImg(); if (uploadResult.Item1 == ImageUploadStatus.Success) { detail.Img = uploadResult.Item2; _reportAppService.CreateOrUpdateReportAsync( new CreateOrUpdateReportInput { ReportEditDto = detail }); status = true; } else if (uploadResult.Item1 == ImageUploadStatus.NoFile) { _reportAppService.CreateOrUpdateReportAsync( new CreateOrUpdateReportInput { ReportEditDto = detail }); status = true; } else { status = false; msg = uploadResult.Item2; } } } catch (Exception e) { status = false; msg = "运行时出错"; } } else { try { ImgUploadHelpers uploadHelpers = new ImgUploadHelpers(Request.Files, Server.MapPath("/")); var uploadResult = uploadHelpers.UploadImg(); if (uploadResult.Item1 == ImageUploadStatus.Success) { detail.Img = uploadResult.Item2; detail.IsShow = true; _reportAppService.CreateOrUpdateReportAsync( new CreateOrUpdateReportInput { ReportEditDto = detail }); status = true; } else { status = false; msg = uploadResult.Item2; } } catch (Exception e) { status = false; msg = "运行时出错"; } } return(Json(new { status = status, message = msg })); }