using drinkMe.Server.Services.Interfaces;
using drinkMe.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace drinkMe.Server.Services
{
	public class PaymentService : IPaymentService
	{
		public async Task<bool> Pay(PurchaseCart purchaseCart)
		{
			if (!purchaseCart.IsPayedWithCash &&
				(purchaseCart.CreditCardNumber is { Length: 0 } || purchaseCart.CreditCardExpirationYear is { Length: 0 } ||
				purchaseCart.CreditCardExpirationMonth is { Length: 0 } || purchaseCart.CreditCardCVVCode is { Length: 0 }))
				return false;

			if (purchaseCart.PurchasingItems.Count == 0)
				return false;
			//completing the purchase
			return true;
		}
	}
}
