public JsonResult<CoreModels.CommentContainer> AddComment(CoreModels.Comment comment, string containerType, string containerId) { return API.Execute<CoreModels.CommentContainer>(r => { //todo: strip html? //comment.Official = false; comment.ApprovedDate = null; comment.Id = null; if (!string.IsNullOrEmpty(comment.Email)) CoreServices.Validation.ValidateEmail(comment.Email); r.Data = CoreServices.Comment.SaveComment(comment, containerType, containerId); r.AddMessage(Localization.GetPortalText("CommentAdded.Text", "Comment has been posted. It will show up here upon approval.")); }); }
public JsonResult<bool> Save(CoreModels.File file, string uniqueName) { return API.Execute<bool>(r => { if (!string.IsNullOrEmpty(file.Id) || !string.IsNullOrEmpty(uniqueName)) { CoreServices.Security.VerifyActivityAuthorized("File", "Administration"); var fileId = CoreServices.File.Save(file); if (!string.IsNullOrEmpty(uniqueName)) { var newFileName = Portal.GetFile(CoreServices.Portal.CurrentPortalId, fileId); if (System.IO.File.Exists(newFileName)) System.IO.File.Delete(newFileName); System.IO.File.Move(Portal.GetTempFile(CoreServices.Portal.CurrentPortalId, uniqueName), newFileName); } r.Data = !string.IsNullOrEmpty(fileId); } else throw new Exception(Localization.GetExceptionText("InvalidFile.Error", "In order to save, file must exist.")); }); }