Esempio n. 1
0
        public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
        {
            var deleted = await repository.DeleteDiscountAsync(request.ProductName);

            var response = new DeleteDiscountResponse
            {
                Success = deleted
            };

            return(response);
        }
Esempio n. 2
0
        public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
        {
            var res = await this.discountRepository.DeleteDiscount(request.ProductName);

            DeleteDiscountResponse deleteDiscountResponse = new DeleteDiscountResponse()
            {
                Success = res
            };

            return(deleteDiscountResponse);
        }
Esempio n. 3
0
        public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
        {
            var deleted = await _discountRepository.Delete(request.ProductName);

            _logger.LogInformation("Discount is successfully deleted. ProductName : {productName}", request.ProductName);

            var response = new DeleteDiscountResponse
            {
                Success = deleted
            };

            return(response);
        }
Esempio n. 4
0
        public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
        {
            var coupon = await _repository.GetCoupon(request.Id, trackChanges : false);

            _repository.DeleteCoupon(coupon);
            await _repository.SaveChangesAsync();

            var response = new DeleteDiscountResponse
            {
                Success = true
            };

            return(response);
        }
Esempio n. 5
0
        public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
        {
            bool deleted = await _discountRepository.DeleteDiscount(request.ProductId);

            if (!deleted)
            {
                _logger.LogError(new RpcException(new Status(StatusCode.NotFound,
                                                             $"Error finding result for productId={request.ProductId}")),
                                 $"Discount with ProductId={request.ProductId} has not been found.");
            }

            var response = new DeleteDiscountResponse {
                Success = deleted
            };

            return(response);
        }
Esempio n. 6
0
        public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
        {
            try
            {
                var deleted = await _repository.DeleteDiscount(request.ProductName);
            }
            catch (Exception ex)
            {
                throw new Exception($"Failed to delete coupon", ex);
            }

            var result = new DeleteDiscountResponse
            {
                Success = true
            };

            return(result);
        }