예제 #1
0
        internal bool DoesCategoryExist(int id)
        {
            bool exist = true;

            CategoryData categoryData = new CategoryData();
            var          data         = categoryData.GetCategoryById(id);

            if (data == null)
            {
                exist = false;
            }

            return(exist);
        }
        public HttpResponseMessage Get(int id)
        {
            if (id <= 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "Id parameter must be greater than 0." }));
            }

            CategoryData    data     = new CategoryData();
            CategoryDBModel category = data.GetCategoryById(id);

            HttpResponseMessage response;

            if (category == null)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "No data found matching given parameters values." });
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.OK, category);
            }

            return(response);
        }