Ejemplo n.º 1
0
        public override async Task <ProductItemResponse?> GetProductByDeclinationAndReference(ProductItemRequest request, ServerCallContext context)
        {
            if (string.IsNullOrWhiteSpace(request.Declination) || string.IsNullOrWhiteSpace(request.Reference))
            {
                context.Status = new Status(StatusCode.InvalidArgument, "Arguments are invalid, declination and Reference can't be null or empty");
                return(null);
            }

            try
            {
                Models.Product product = await iProductFetcher.GetProductByDeclinationAndReference(request.Declination, request.Reference);

                return(mapper.Map <ProductItemResponse>(product));
            }
            catch (ProductNotFoundException exception)
            {
                context.Status = new Status(StatusCode.NotFound, exception.Message);
                return(null);
            }
            catch (Exception exception)
            {
                context.Status = new Status(StatusCode.Internal, exception.Message);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public async Task <ProductDto> GetProductByDeclinationAndReference(string declination, string reference)
        {
            Models.Product product = await iProductFetcher.GetProductByDeclinationAndReference(declination, reference);

            return(iMapper.Map <ProductDto>(product));
        }