Esempio n. 1
0
        public override async Task <CouponModel> GetDiscount(GetDiscountRequest request, ServerCallContext context)
        {
            var coupon = await _repo.GetDiscount(request.ProductName);

            if (coupon == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound,
                                                  $"Discount with ProductName={request.ProductName} cannot be found."));
            }

            _logger.LogInformation(
                $"Discount is being retrieved fro ProductName : {coupon.ProductName}, Amount: {coupon.Amount}");

            return(_mapper.Map <CouponModel>(coupon));
        }
Esempio n. 2
0
        public async Task <ActionResult <Coupon> > GetDiscount(string productName)
        {
            var coupon = await _repo.GetDiscount(productName);

            return(Ok(coupon));
        }