private async Task <bool> ConditionMet(FlightPurchaseDto flightPurchase, Domain.Entities.PriceDiscount discount) { var purchases = new List <FlightPurchaseDto>(); purchases.Add(flightPurchase); var query = purchases.AsQueryable(); var queryString = string.Empty; queryString = await BuildQueryString(discount, queryString); if (string.IsNullOrEmpty(queryString) || query.Where(queryString).Any()) { return(true); } return(false); }
private async Task CheckConditionsAndApply(Domain.Entities.PriceDiscount discount, FlightPurchaseDto purchaseDto, Domain.Entities.FlightPurchase purchase) { // minimalna cena 20 if (purchase.Price - 5 < 20) { return; } if (await ConditionMet(purchaseDto, discount)) { purchase.Price -= 5; // zapis zniżek dla danej grupy if (purchaseDto.TenantGroup == Domain.Enums.TenantGroup.A) { purchase.Discounts.Add(discount); } } }