public UberDriver GetUberDriver(string placa) { UberDriver UberFound = null; string strCmd = "SELECT * FROM UberDriver WHERE Placa = @placa"; using (SqlConnection sqlCnx = new SqlConnection(cadenaConexion)) { sqlCnx.Open(); using (SqlCommand sqlCmd = new SqlCommand(strCmd, sqlCnx)) { sqlCmd.Parameters.Add(new SqlParameter("@placa", placa)); using (SqlDataReader sqlDR = sqlCmd.ExecuteReader()) { if (sqlDR.Read()) { UberFound = new UberDriver() { UPlaca = (int)sqlDR["Placa"], UNombres = (string)sqlDR["Nombres"], UApellidos = (string)sqlDR["Apellidos"], UCelular = (int)sqlDR["Celular"], UModeloAuto = (string)sqlDR["ModeloAuto"], UReputacion = (int)sqlDR["Reputacion"], UFechaIngreso = (DateTime)sqlDR["FechaIngreso"] }; } } } } return(UberFound); }
//-------------------------------- OPERACIONES PARA UBERDRIVER public List <UberDriver> ListTaxiUber() { List <UberDriver> UbersFound = new List <UberDriver>(); UberDriver UberFound = null; string strCmd = "SELECT * FROM UberDriver"; using (SqlConnection sqlCnx = new SqlConnection(cadenaConexion)) { sqlCnx.Open(); using (SqlCommand sqlCmd = new SqlCommand(strCmd, sqlCnx)) { using (SqlDataReader sqlDR = sqlCmd.ExecuteReader()) { while (sqlDR.Read()) { UberFound = new UberDriver() { UPlaca = (int)sqlDR["Placa"], UNombres = (string)sqlDR["Nombres"], UApellidos = (string)sqlDR["Apellidos"], UCelular = (int)sqlDR["Celular"], UModeloAuto = (string)sqlDR["ModeloAuto"], UReputacion = (int)sqlDR["Reputacion"], UFechaIngreso = (DateTime)sqlDR["FechaIngreso"] }; UbersFound.Add(UberFound); } } } } return(UbersFound); }
private UberDriver obtenerChoferUber(string placa) { JavaScriptSerializer js = new JavaScriptSerializer(); string url = string.Format("http://localhost:2133/UberDrivers.svc/UberDrivers/{0}", placa); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; request.ContentType = "application/json"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string tramaJson = reader.ReadToEnd(); UberDriver uber = js.Deserialize <UberDriver>(tramaJson); return(uber); }
public ActionResult Pagar(string proveedor, string placa) { if (SessionExpirada()) { return(RetornarLogin()); } ReservaService.Reserva reseva = ObtenerReserva(); ReservaModel model = new ReservaModel(); model.Origen = reseva.Origen; model.Destino = reseva.Destino; model.AutoPlaca = placa; if (proveedor == "UBER") { CandidatoModel candidato = candidatoUber(placa); model.Precio = candidato.Precio; UberDriver uber = obtenerChoferUber(placa); model.Conductor = uber.UNombres + ", " + uber.UApellidos; model.AutoModelo = uber.UModeloAuto; } else if (proveedor == "CABIFY") { CandidatoModel candidato = candidatoCabify(placa); model.Precio = candidato.Precio; CabifyDriver cabify = obtenerChoferCabify(placa); model.Conductor = cabify.nombres + ", " + cabify.apellidos; model.AutoModelo = cabify.automodelo; } //AsignarReserva(reseva); ClienteService.ClienteServiceClient proxy = new ClienteService.ClienteServiceClient(); ClienteService.Tarjeta[] tarjetas = proxy.ListarTarjetaxCliente(ObtenerCliente().DNI); model.Tarjetas = tarjetas; return(View(model)); }