Ejemplo n.º 1
0
        /// <summary>
        /// Get product by id
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public async Task <GetProductDto> GetProduct(string productId)
        {
            GetProductDto response = null;

            try
            {
                var product = _repository.Product.GetProductById(Guid.Parse(productId));
                if (product != null)
                {
                    response = new GetProductDto(product.Id, product.Code, product.Name, product.Description,
                                                 null, product.PhotoName, product.Price, product.LastUpdated.ToString(), product.BlobName);

                    return(await Task.Run(() => response));
                }

                return(await Task.Run(() => response));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(await Task.Run(() => GetProductDto.PrepareExceptionResponse(Guid.Empty, "ERROR_SYSTEM")));
            }
        }