public IHttpActionResult Comments(string token, Guid referenceId) { if (auth.IsNotValid(token)) { return(base.StatusCode(System.Net.HttpStatusCode.Unauthorized)); } if (Guid.Empty == referenceId) { return(this.BadRequest("Reference Identifier")); } var userId = auth.Device.UserIdentifier; var results = this.socialCore.SearchComment(userId, referenceId); var comments = results.Select(r => ApiComment.Map(r)); return(this.Ok <IEnumerable <ApiComment> >(comments)); }
public IHttpActionResult SaveComment(SecuredSocialComment comment) { if (auth.IsNotValid(comment)) { return(base.StatusCode(HttpStatusCode.Unauthorized)); } if (null == comment) { return(this.BadRequest("comment")); } if (comment.Delete) { if (Guid.Empty == comment.Identifier) { return(this.BadRequest("Identifier")); } } else { if (Guid.Empty == comment.ReferenceIdentifier) { return(this.BadRequest("Reference Identifier")); } if (string.IsNullOrWhiteSpace(comment.Comment)) { return(this.BadRequest("Comment must be specified")); } } comment.UserIdentifier = auth.Device.UserIdentifier; var newComment = this.socialCore.SaveComment(comment); emailCore.NewsFeedComment(newComment); var results = null != newComment?this.socialCore.SearchComment(comment.UserIdentifier, newComment.ReferenceIdentifier) : null; var comments = results.Select(r => ApiComment.Map(r)); return(this.Ok <IEnumerable <ApiComment> >(comments)); }