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); }
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); }
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); }
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); }
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); }
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); }