コード例 #1
0
        public static List <Article> GetAllArticles(ISystemFail error)
        {
            List <Article> articles = null;

            try
            {
                string webServiceUrl = string.Concat(AppKeys.WebServiceURL, AppKeys.WebServiceArticleControllerName);
                string response      = Proxy.ProxyService.GetRequestURlConcatParameters(webServiceUrl, error);
                if (!string.IsNullOrEmpty(response) && !error.Error)
                {
                    GetAllArticleResponse apiResponse = JsonConvert.DeserializeObject <GetAllArticleResponse>(response);
                    if (apiResponse.success)
                    {
                        articles = apiResponse.articles;
                    }
                    else
                    {
                        error.Error   = true;
                        error.Message = string.Concat("An error has ocurred obtaining the list of articles.");
                    }
                }
                else
                {
                    error.Error   = true;
                    error.Message = string.Concat("An error has ocurred obtaining the list of articles. Error:", error.Message);
                }
            }
            catch (Exception ex)
            {
                error.Error     = true;
                error.Exception = ex;
                error.Message   = string.Concat("An error has ocurred obtaining the list of articles. Error:", ex.Message);
            }
            return(articles);
        }
コード例 #2
0
        public GetAllArticleResponse GetStoreArticles(int id, string dummy)
        {
            SystemFail            error    = new SystemFail();
            List <Article>        articles = articleService.GettStoreArticles(id, error).ToList();
            GetAllArticleResponse response = new GetAllArticleResponse();

            response.success        = !error.Error;
            response.total_elements = articles.Count;
            response.articles       = articles.Select(x => new ArticleDTO()
            {
                Id           = x.Id,
                Name         = x.Name,
                Description  = x.Description,
                Price        = x.Price,
                StoreId      = x.StoreId,
                TotalInShelf = x.TotalInShelf,
                TotalInVault = x.TotalInVault
            }).ToList();

            return(response);
        }