public IHttpActionResult Submit(int contentId) { try { var request = Context.GetCurrentRequest(); var siteId = request.GetQueryInt("siteId"); if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, ApplicationUtils.PluginId)) { return(Unauthorized()); } var replyContent = request.GetPostString("replyContent"); var fileInfoList = request.GetPostObject <List <FileInfo> >("fileInfoList"); var fileInfoListDatabase = FileDao.GetFileInfoList(siteId, contentId); DataDao.UpdateStateAndReply(siteId, contentId, replyContent, fileInfoList.Count > 0); LogManager.Reply(siteId, contentId, request.AdminId); foreach (var fileInfo in fileInfoList) { if (fileInfo.Id == 0) { fileInfo.SiteId = siteId; fileInfo.DataId = contentId; FileDao.Insert(fileInfo); } } foreach (var fileInfoDatabase in fileInfoListDatabase) { if (fileInfoList.Exists(f => f.Id == fileInfoDatabase.Id)) { continue; } var filePath = Context.UtilsApi.GetUploadFilePath(siteId, fileInfoDatabase.FileName); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } FileDao.Delete(fileInfoDatabase.Id); } return(Ok(new { Value = true })); } catch (Exception ex) { return(InternalServerError(ex)); } }