예제 #1
0
        public IHttpActionResult GetArticlesByStore(string storeId)
        {
            int storeIdInt;
            var response = new PluralArticleResponse();
            var result   = new List <ArticleDTO>();

            try
            {
                // Validate request
                if (string.IsNullOrEmpty(storeId) || !int.TryParse(storeId, out storeIdInt))
                {
                    return(Ok(ResponseHandler.Error(400)));
                }

                result = ContextBehaviours.GetArticlesByStore(storeIdInt);

                // Validate if find record
                if (result.Count == 0)
                {
                    return(Ok(ResponseHandler.Error(404)));
                }

                // Prepare  success response
                response.articles       = result;
                response.success        = true;
                response.total_elements = result.Count;
            }
            catch (Exception ex)
            {
                return(Ok(ResponseHandler.Error(500)));
            }
            return(Ok(response));
        }
예제 #2
0
        public IHttpActionResult GetArticles()
        {
            var response = new PluralArticleResponse();
            var result   = new List <ArticleDTO>();

            try
            {
                result = ContextBehaviours.GetArticles();

                // Validate if find record
                if (result.Count == 0)
                {
                    return(Ok(ResponseHandler.Error(404)));
                }

                // Prepare success response
                response.articles       = result;
                response.total_elements = result.Count;
                response.success        = true;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(Ok(ResponseHandler.Error(500)));
            }
        }
예제 #3
0
        // GET: Article
        public ActionResult Index()
        {
            var articleResponse = new PluralArticleResponse();
            var response        = SuperZapatosAPI.CallGetAPI("services/GetArticles/");

            if (response.IsSuccessStatusCode)
            {
                // Creating Json Request Object
                articleResponse = new JavaScriptSerializer().Deserialize <PluralArticleResponse>(response.Content.ReadAsStringAsync().Result);
            }

            return(View(articleResponse.articles));
        }