Пример #1
0
        public HttpResponseMessage Get(string type, int id)
        {
            try
            {
                List <CommentModel> comments = new List <CommentModel>();

                switch (type)
                {
                case "article":

                    comments = CommentModel.GetList(id, _articleRepository);

                    break;

                case "gallery":
                    throw new NotImplementedException();

                default:
                    throw new ArgumentException("type not recognised");
                }

                if (comments == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NoContent));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, comments));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }