public ActionResult Index() { ServicioWeb.ServicioDeComunicacionSoapClient a = new ServicioWeb.ServicioDeComunicacionSoapClient(); ViewBag.Message = "Bienvenidos a nuestra agencia de viajes"; ViewBag.Destinos = new SelectList(a.Aeropuertos(), "Id", "Lugar"); ViewBag.Procedencia = new SelectList(a.Aeropuertos(), "Id", "Lugar"); return View(); }
// // GET: /Boletos/ public ActionResult Index(int tipo) { if (Session["usuario"] != null) { Cliente cliente = (Cliente)Session["usuario"]; ServicioWeb.ServicioDeComunicacionSoapClient servicio=new ServicioWeb.ServicioDeComunicacionSoapClient(); Vuelo vuelo=new Vuelo(); var boletoes = db.Boletos.Include(b => b.Vuelo).Where(p=>p.Cliente.Id==cliente.Id && p.tipo==tipo); foreach(var a in boletoes){ a.BoletoCargar(); } return View(boletoes.ToList()); } else { Session["direccion"] = Request.Url.AbsoluteUri; return RedirectToAction("IniciarSesion", "Clients"); } }
public ActionResult BuscarVuelo(Vuelo model) { var b = (ServicioWeb.Vuelo[])null; var n = (ServicioWeb.Vuelo[])null; List<Vuelo> vuelos = new List<Vuelo>(); ServicioWeb.ServicioDeComunicacionSoapClient a = new ServicioWeb.ServicioDeComunicacionSoapClient(); Session.Contents.RemoveAll(); if (model.Modo.Equals("Ida")) { b = a.VuelosIda(Convert.ToInt32(model.Procedencia), Convert.ToInt32(model.Destino), model.Salida); ViewBag.aeropuertos = a.Aeropuertos().ToList(); foreach (var dato in b) { vuelos = new List<Vuelo>(); Vuelo vuelo = new Vuelo(); string[] time = dato.HoraSalida.Split(':'); string[] min = time[1].Split(' '); vuelo.Salida = dato.FechaSalida.AddHours(Convert.ToInt32(time[0])).AddMinutes(Convert.ToInt32(min[0])); vuelo.Llegada = vuelo.Salida.AddHours(dato.Duracion); vuelo.Id = dato.Id; vuelo.Destino = a.Aeropuertos().ToList().Find(p => p.Id == (Int32)dato.AeropuertoReference.EntityKey.EntityKeyValues.First().Value).Lugar; vuelo.Procedencia = a.Aeropuertos().ToList().Find(p => p.Id == (Int32)dato.Aeropuerto1Reference.EntityKey.EntityKeyValues.First().Value).Lugar; vuelos.Add(vuelo); Session["Ida"] = vuelos; } if (vuelos==null) { TempData["error"] = "No encontramos ningun vuelo que coincida con tu busqueda"; return RedirectToAction("Index", "Home"); } } else if (model.Modo.Equals("Ida y Vuelta")) { n = a.VuelosVuelta(Convert.ToInt32(model.Procedencia), Convert.ToInt32(model.Destino), model.Salida, model.Llegada); b = a.VuelosIda(Convert.ToInt32(model.Procedencia), Convert.ToInt32(model.Destino), model.Salida); ViewBag.aeropuertos = a.Aeropuertos().ToList(); Session.Contents.RemoveAll(); foreach (var dato in b) { vuelos = new List<Vuelo>(); Vuelo vuelo = new Vuelo(); string[] time = dato.HoraSalida.Split(':'); string[] min = time[1].Split(' '); vuelo.Salida = dato.FechaSalida.AddHours(Convert.ToInt32(time[0])).AddMinutes(Convert.ToInt32(min[0])); vuelo.Llegada = vuelo.Salida.AddHours(dato.Duracion); vuelo.Id = dato.Id; vuelo.Destino = a.Aeropuertos().ToList().Find(p => p.Id == (Int32)dato.AeropuertoReference.EntityKey.EntityKeyValues.First().Value).Lugar; vuelo.Procedencia = a.Aeropuertos().ToList().Find(p => p.Id == (Int32)dato.Aeropuerto1Reference.EntityKey.EntityKeyValues.First().Value).Lugar; vuelos.Add(vuelo); Session["Ida"] = vuelos; } foreach (var dato in n) { vuelos = new List<Vuelo>(); Vuelo vuelo = new Vuelo(); string[] time = dato.HoraSalida.Split(':'); string[] min = time[1].Split(' '); vuelo.Salida = dato.FechaSalida.AddHours(Convert.ToInt32(time[0])).AddMinutes(Convert.ToInt32(min[0])); vuelo.Llegada = vuelo.Salida.AddHours(dato.Duracion); vuelo.Id = dato.Id; vuelo.Destino = a.Aeropuertos().ToList().Find(p => p.Id == (Int32)dato.AeropuertoReference.EntityKey.EntityKeyValues.First().Value).Lugar; vuelo.Procedencia = a.Aeropuertos().ToList().Find(p => p.Id == (Int32)dato.Aeropuerto1Reference.EntityKey.EntityKeyValues.First().Value).Lugar; vuelos.Add(vuelo); Session["IdaVuelta"] = vuelos; } if (vuelos.Count == 0) { TempData["error"] = "No encontramos ningun vuelo que coincida con tu busqueda"; return RedirectToAction("Index", "Home"); } } return View(); }
public ActionResult ManejoBoleto(int tipo, int id) { if (Session["usuario"] != null) { ServicioWeb.ServicioDeComunicacionSoapClient servicio=new ServicioWeb.ServicioDeComunicacionSoapClient(); Boleto boleto = new Boleto(); if (servicio.asientosDisponibles(id)== 0) { return RedirectToAction("ListaEspera", "Boletos", new { id =id }); }else{ if (tipo == 1) { boleto.tipo = 1; boleto.RefIdVuelo = id; boleto.RefIdCliente = ((Cliente)Session["usuario"]).Id; boleto.fecha = DateTime.Now; db.Boletos.Add(boleto); db.SaveChanges(); return RedirectToAction("Index", "Boletos",new{tipo=1}); } else if (tipo == 2) { boleto.tipo = 2; boleto.RefIdVuelo = id; boleto.RefIdCliente = ((Cliente)Session["usuario"]).Id; boleto.fecha = DateTime.Now; db.Boletos.Add(boleto); db.SaveChanges(); return RedirectToAction("Index", "Boletos",new{tipo=2}); } } } Session["direccion"] = Request.Url.AbsoluteUri; return RedirectToAction("IniciarSesion", "Clients"); }