Esempio n. 1
0
        public List <ArticleModel> GetArticles(ISystemResponse error)
        {
            List <ArticleModel> articles = new List <ArticleModel>();

            try
            {
                string request = WebAPIClient.GetRequest("Articles", "Get", new Dictionary <string, string>(), error);

                if (!string.IsNullOrEmpty(request) && !error.Error)
                {
                    JavaScriptSerializer  serializer = new JavaScriptSerializer();
                    ArticlesResponseModel response   = serializer.Deserialize <ArticlesResponseModel>(request);

                    if (response != null && !error.Error && response.articles != null)
                    {
                        articles = response.articles;
                    }
                }
            }
            catch (Exception ex)
            {
                error.Error     = true;
                error.Message   = "No se pudieron obtener los articulos";
                error.Exception = ex;
            }

            return(articles);
        }
Esempio n. 2
0
        public Article GetArticle(int articleId, ISystemResponse error)
        {
            Article article = new Article();

            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("articleId", articleId.ToString());
                parameters.Add("bit", "false");

                string request = WebAPIClient.GetRequest("Articles", "Get", parameters, error);

                if (!string.IsNullOrEmpty(request) && !error.Error)
                {
                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    ArticleResponseModel response   = serializer.Deserialize <ArticleResponseModel>(request);

                    if (response != null && !error.Error && response.article != null)
                    {
                        article = response.article;
                    }
                }
            }
            catch (Exception ex)
            {
                error.Error     = true;
                error.Message   = "No se pudo obtener la informacion del articulo solicitado";
                error.Exception = ex;
            }

            return(article);
        }
Esempio n. 3
0
        public StoreModel GetStore(int storeId, ISystemResponse error)
        {
            StoreModel store = new StoreModel();

            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("storeId", storeId.ToString());

                string request = WebAPIClient.GetRequest("Stores", "Get", parameters, error);

                if (!string.IsNullOrEmpty(request) && !error.Error)
                {
                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    StoreResponseModel   response   = serializer.Deserialize <StoreResponseModel>(request);

                    if (response != null && !error.Error && response.store != null)
                    {
                        store = response.store;
                    }
                }
            }
            catch (Exception ex)
            {
                error.Error     = true;
                error.Message   = "No se pudo obtener la informacion de la tienda solicitada";
                error.Exception = ex;
            }

            return(store);
        }