public List <PriceComponent> CalculatePrice(PriceCalculationParametersDTO PriceCalculationParameters) { var components = new List <PriceComponent>(); var run = _runRepository.GetRunDetails(PriceCalculationParameters.PlaceInRun.RunId); var train = _trainRepository.GetTrainDetails(run.TrainId); var place = train.Carriages .Select(car => car.Places.SingleOrDefault(pl => pl.Number == PriceCalculationParameters.PlaceInRun.Number && car.Number == PriceCalculationParameters.PlaceInRun.CarriageNumber)) .SingleOrDefault(x => x != null); var placeComponent = new PriceComponent() { Name = "Main price" }; placeComponent.Value = place.Carriage.DefaultPrice * place.PriceMultiplier; components.Add(placeComponent); if (placeComponent.Value > 30) { var cashDeskComponent = new PriceComponent() { Name = "Cash desk service tax", Value = placeComponent.Value * 0.2m }; components.Add(cashDeskComponent); } return(components); }
public List <PriceComponent> CalculatePrice(PriceCalculationParametersDTO PriceCalculationParameters) { var components = new List <PriceComponent>(); components.AddRange(_priceCalculationStrategy.CalculatePrice(PriceCalculationParameters)); if (PriceCalculationParameters.IsTea == true) { var cashForTea = new PriceComponent() { Name = "Pay for tea", Value = 7, }; components.Add(cashForTea); } if (PriceCalculationParameters.IsCoffee == true) { var cashForCoffee = new PriceComponent() { Name = "Pay for Coffee", Value = 8 }; components.Add(cashForCoffee); } if (PriceCalculationParameters.IsBed == true) { var cashForBed = new PriceComponent() { Name = "Pay for Bed", Value = 15 }; components.Add(cashForBed); } return(components); }