Пример #1
0
        public IActionResult GetImagenPorIDArticulo(int idArticulo)
        {
            IActionResult result;

            try
            {
                var ad     = new AdaptadorAtc(_configuration);
                var a      = ad.ImagenesLeerPorIDArticulo(idArticulo);
                var memory = new MemoryStream(a);

                if (a.Length < 1)
                {
                    var ex = new Exception("Imagen no encontrada");
                    result = new ObjectResult(ex)
                    {
                        StatusCode = (int)HttpStatusCode.Conflict
                    };
                    Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
                    return(result);
                }
                else
                {
                    //memory.Position = 0;
                    result = new ObjectResult(memory)
                    {
                        StatusCode = (int)HttpStatusCode.OK
                    };
                }


                return(result);
            }
            catch (Exception ex)
            {
                result = new ObjectResult(ex)
                {
                    StatusCode = (int)HttpStatusCode.Conflict
                };
                Request.HttpContext.Response.Headers.Add("dsError", ex.Message);
                return(result);
            }
        }