コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }