static void Main(string[] args) { var controller = new AirportContoller(); var model = new AirportPostModel() { Flight = "Kiev - New-York", FlightNumber = 1, FlightTime = DateTime.UtcNow }; var a = controller.CreateAirportRequest(model); var ab = controller.GetAll(); }
public AirportViewModel CreateAirportRequest(AirportPostModel model) { if (string.IsNullOrWhiteSpace(model.Flight)) { throw new Exception("Invalid flight"); } if (model.FlightNumber <= 0) { throw new Exception("Invalid number of flight"); } var airportModel = _mapper.Map <AirportModel>(model); var CreatedAirport = _airportService.CreateAirport(airportModel); return(_mapper.Map <AirportViewModel>(CreatedAirport)); }