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(); }