public TelstarResponse Get([FromBody] TelstarRequest telstarRequest) { string errorMsg = CommunicationValidation.verifyTelstarRequest(telstarRequest); if (errorMsg != null) { return(returnError(errorMsg)); } return(new TelstarResponse { price = GetPrice(), time = GetTime(), error = "NO_ERROR" }); }
public TelstarResponse Get([FromBody] TelstarRequest telstarRequest) { string errorMsg = CommunicationValidation.VerifyTelstarRequest(telstarRequest); if (errorMsg != null) { return(returnError(errorMsg)); } RoutesDAO routesDAO = new RoutesDAO(); Routes routes = routesDAO.FetchOne(GetId(telstarRequest.CityTo), GetId(telstarRequest.CityFrom)); return(new TelstarResponse { price = GetPrice(telstarRequest, routes.Price), time = routes.TravelTime, error = "NO_ERROR" }); }
public static int GetPrice(TelstarRequest telstarRequest, int originalPrice) { double price = originalPrice; if (telstarRequest.Company == CompanyEnum.EAST_INDIA_TRADING.ToString()) { price = price * 0.90; } else if (telstarRequest.Company == CompanyEnum.OCEANIC_AIRLINES.ToString()) { price = price * 1.05; } foreach (string feature in telstarRequest.Features) { if (feature.Equals(FeatureEnum.RECOMMENDED.ToString())) { price += 10; } if (feature.Equals(FeatureEnum.LIVE_ANIMALS.ToString())) { price = price * 1.5; } if (feature.Equals(FeatureEnum.CAUTIOUSLY.ToString())) { price = price * 1.75; } if (feature.Equals(FeatureEnum.REFIGERATED.ToString())) { price = price * 1.10; } } return((int)price); }