public IHttpActionResult GetFlights()
        {
            try
            {
                IList <FlightDetailViewModel> flights = null;

                CreatioLogin login        = new CreatioLogin("http://*****:*****@gmail.com", "Newuser@1").ToString();

                using (var ctx = new BookingFlightEntities())
                {
                    flights = (from flight in ctx.Flights
                               join flightDetail in ctx.FlightDetails
                               on flight.Id equals flightDetail.FlightId
                               join flightSchedule in ctx.FlightScheduleDetails
                               on flightDetail.Id equals flightSchedule.FlightDetailId
                               select new FlightDetailViewModel
                    {
                        Id = flightSchedule.Id,
                        FlightName = flight.FlightName,
                        Departure = flightDetail.Departure,
                        Arrival = flightDetail.Arrival,
                        JourneyDate = flightSchedule.JourneyDate,
                        FromCity = flightDetail.FromCity,
                        ToCity = flightDetail.ToCity,
                        Price = flightSchedule.Price,
                        SeatAvailability = flightSchedule.SeatAvailability,
                        token = token
                    }).ToList <FlightDetailViewModel>();
                }

                //CreatioLogin login = new CreatioLogin("http://localhost:86/", "Supervisor", "Supervisor");
                // login.TryLogin();

                if (!flights.Any())
                {
                    return(NotFound());
                }

                return(Ok(flights));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public IHttpActionResult PostTicketBooking(TicketDetail ticket)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid data."));
                }
                using (var ctx = new BookingFlightEntities())
                {
                    var tickets = new TicketDetail()
                    {
                        BookingStatus          = ticket.BookingStatus,
                        PassengerCount         = ticket.PassengerCount,
                        TotalFare              = ticket.TotalFare,
                        CancellationFare       = ticket.CancellationFare,
                        FlightScheduleDetailId = ticket.FlightScheduleDetailId
                    };
                    ctx.TicketDetails.Add(tickets);

                    ctx.SaveChanges();

                    var flightdetail = ctx.FlightScheduleDetails.Where(x => x.Id == tickets.FlightScheduleDetailId).FirstOrDefault();
                    if (flightdetail != null)
                    {
                        flightdetail.SeatAvailability -= tickets.PassengerCount;
                    }

                    ctx.SaveChanges();
                    IList <TicketDetailViewModel> ticketdetails = null;
                    var t = new TicketDetailViewModel();

                    ticketdetails = (from flight in ctx.Flights
                                     join flightDetail in ctx.FlightDetails
                                     on flight.Id equals flightDetail.FlightId
                                     join flightSchedule in ctx.FlightScheduleDetails
                                     on flightDetail.Id equals flightSchedule.FlightDetailId
                                     where flightSchedule.Id == tickets.FlightScheduleDetailId
                                     select new TicketDetailViewModel
                    {
                        FlightName = flight.FlightName,
                        JourneyDate = flightSchedule.JourneyDate,
                        FromCity = flightDetail.FromCity,
                        ToCity = flightDetail.ToCity,
                        Price = flightSchedule.Price,
                        PassengerCount = ticket.PassengerCount,
                        TotalFare = ticket.TotalFare,
                        BookingStatus = ticket.BookingStatus.ToString(),
                        Id = tickets.Id,
                        Departure = flightDetail.Departure,
                        Arrival = flightDetail.Arrival
                    }).ToList <TicketDetailViewModel>();

                    CreatioLogin login        = new CreatioLogin("http://localhost:86/", "Supervisor", "Supervisor");
                    var          loginRequest = login.TryLogin();

                    CreatioLogin logins = new CreatioLogin("http://localhost:86/");
                    logins.CallWebService(loginRequest, ticketdetails);

                    return(Json(new { id = tickets.Id }));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }