public void ReportAbuse(string reviewId, string authorId, string authorName, string authorLocation) { // Validate Incoming parameters if (string.IsNullOrEmpty(reviewId)) throw new ArgumentNullException("reviewId"); if (string.IsNullOrEmpty(authorId)) throw new ArgumentNullException("authorId"); if (string.IsNullOrEmpty(authorName)) throw new ArgumentNullException("authorName"); if (string.IsNullOrEmpty(authorLocation)) throw new ArgumentNullException("authorLocation"); var review = FindReviewById(reviewId); if (review != null) { // Skip duplicated Abuse var abuseElement = FindReportAbuseByAuthor(reviewId, authorId); if (abuseElement != null) { return; } // Post Abuse var newAbuseElement = new ReportAbuseElement(); newAbuseElement.ReviewId = reviewId; //newAbuseElement.ReportAbuseElementId = Guid.NewGuid().ToString(); newAbuseElement.AuthorId = authorId; //newAbuseElement.AuthorFN = authorName; //newAbuseElement.AuthorLocation = authorLocation; //newAbuseElement.Status = "Pending"; _repository.Add(newAbuseElement); _repository.UnitOfWork.Commit(); } }
public HttpResponseMessage ReportAbuse(MReportAbuse abuse) { if (ModelState.IsValid) { try { var abuseEl = new ReportAbuseElement { AuthorId = UserHelper.CustomerSession.CustomerId, Comment = abuse.Comment, ReviewId = abuse.IsReview ? abuse.Id : null, CommentId = abuse.IsReview ? null : abuse.Id, Email = abuse.Email, Reason = abuse.Reason }; _repository.Add(abuseEl); _repository.UnitOfWork.Commit(); return Request.CreateResponse(HttpStatusCode.OK); } catch { var response = Request.CreateResponse(HttpStatusCode.NotFound); response.Content = new StringContent("Error while saving data to database.".Localize()); return response; } } return Request.CreateResponse(HttpStatusCode.BadRequest); }
public IHttpActionResult ReportAbuse(MReportAbuse abuse) { if (ModelState.IsValid) { try { var abuseEl = new ReportAbuseElement { AuthorId = UserHelper.CustomerSession.CustomerId, Comment = abuse.Comment, ReviewId = abuse.IsReview ? abuse.Id : null, CommentId = abuse.IsReview ? null : abuse.Id, Email = abuse.Email, Reason = abuse.Reason }; _repository.Add(abuseEl); _repository.UnitOfWork.Commit(); return Ok("ok"); } catch { return BadRequest("Error while saving data to database.".Localize()); } } return BadRequest(); }