Beispiel #1
0
        public HttpResponseMessage PutReview(ReviewArticle article)
        {
            try
            {
                if (article.Id > 0)
                {
                    article.MarkOld(); article.MarkDirty();
                }
                article.Save(_articleRepository);

                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Beispiel #2
0
        public HttpResponseMessage Add(int categoryId, int articleTypeId)
        {
            try
            {
                var articleType = _articleRepository.FetchType(articleTypeId);
                if (articleType.Name == "News")
                {
                    var obj = NewsArticle.NewNewsArticle(categoryId, _articleRepository);
                    return(Request.CreateResponse(HttpStatusCode.OK, obj.GetJSONModel()));
                }

                if (articleType.Name == "Review")
                {
                    var obj = ReviewArticle.NewReviewArticle(categoryId);
                    return(Request.CreateResponse(HttpStatusCode.OK, obj.GetJSONModel()));
                }

                throw new ArgumentException("Unknown Article Type");
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }