public async Task <IActionResult> GetArticleById([FromBody] GetAriticleByIdRequest request)
        {
            return(await MethodWrapper(async (param) =>
            {
                GetArticleByIdResponse response = new GetArticleByIdResponse();

                var article = await Context.Articles
                              .Include(o => o.Images)
                              .Include(o => o.Preview)
                              .SingleOrDefaultAsync(m => m.ID == int.Parse(Request.Path.Value.Split('/', StringSplitOptions.None).Last()));

                if (article == null)
                {
                    return NotFound();
                }

                response.Images = article.Images.ToList();
                response.Preview = article.Preview.Preview;
                response.Title = article.Preview.Title;
                response.DateTime = article.Preview.DateTime;
                response.Content = article.Content;
                response.Id = article.ID;

                return Ok(response);
            }, request));
        }
        public GetArticleByIdResponse GetArticleById(int articleId)
        {
            SystemFail             error    = new SystemFail();
            GetArticleByIdResponse response = new GetArticleByIdResponse();
            Article    article = articleService.GetArticleById(articleId, error);
            ArticleDTO dto     = new ArticleDTO();

            dto.Description  = article.Description;
            dto.Id           = article.Id;
            dto.Name         = article.Name;
            dto.Price        = article.Price;
            dto.StoreId      = article.StoreId;
            dto.TotalInShelf = article.TotalInShelf;
            dto.TotalInVault = article.TotalInVault;

            response.success = !error.Error;
            response.article = dto;
            return(response);
        }
        public async Task <IActionResult> EditArticle([FromBody] EditArticleRequest request)
        {
            return(await MethodWrapper(async (param) =>
            {
                List <TorImage> images = new List <TorImage>();

                Article article = await Context.Articles
                                  .Include(o => o.Preview).FirstOrDefaultAsync(art => art.ID == param.Id);

                if (!string.IsNullOrEmpty(param.Content))
                {
                    article.Content = param.Content;
                }

                if (!string.IsNullOrEmpty(param.Preview))
                {
                    article.Preview.Preview = param.Preview;
                }

                if (!string.IsNullOrEmpty(param.Title))
                {
                    article.Preview.Title = param.Title;
                }

                Context.Articles.Update(article);

                await Context.SaveChangesAsync();

                GetArticleByIdResponse response = new GetArticleByIdResponse
                {
                    Preview = article.Preview.Preview,
                    Title = article.Preview.Title,
                    DateTime = article.Preview.DateTime,
                    Content = article.Content,
                    Id = article.ID
                };

                return Ok(response);
            }, request));
        }
        public static Article GetArticleById(int articleId, ISystemFail error)
        {
            Article article = null;

            try
            {
                string webServiceUrl = string.Concat(AppKeys.WebServiceURL, AppKeys.WebServiceArticleControllerName);
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("articleId", articleId.ToString());


                string response = Proxy.ProxyService.GetRequestURlConcatParameters(webServiceUrl, error, parameters);
                if (!string.IsNullOrEmpty(response) && !error.Error)
                {
                    GetArticleByIdResponse apiResponse = JsonConvert.DeserializeObject <GetArticleByIdResponse>(response);
                    if (apiResponse.success)
                    {
                        article = apiResponse.article;
                    }
                    else
                    {
                        error.Error   = true;
                        error.Message = string.Concat("An error has ocurred obtaining the specific article");
                    }
                }
                else
                {
                    error.Error   = true;
                    error.Message = string.Concat("An error has ocurred obtaining the specific article. Error:", error.Message);
                }
            }
            catch (Exception ex)
            {
                error.Error     = true;
                error.Exception = ex;
                error.Message   = string.Concat("An error has ocurred obtaining the specific article. Error:", ex.Message);
            }
            return(article);
        }