public Conductor ModificarConductor(Conductor c) { using (uruguay_busEntities db = new uruguay_busEntities()) { try { if (c == null) { throw new Exception("No se encontro ningun conductor con ese ID"); } conductor con = db.conductor.Find(c.id); if (con == null) { throw new Exception("No se encontro ningun conductor con ese ID"); } con.vencimiento_libreta = c.vencimiento_libreta; db.SaveChanges(); c = ConductorConverter.convert(con); c.persona = PersonaConverter.convert(con.persona); return(c); } catch (Exception e) { throw e; } } }
void Start() { con = FindObjectOfType <conductor>(); crotchet = 60 / con.songBpm; cube = gameObject.GetComponent <Renderer>(); }
public static void asociarHorarios(conductor c, ICollection <horario> h) { foreach (var item in h) { item.conductor = c; item.conductor_id = c.id; c.horario.Add(item); } }
public void AsignarRol(int idUsuario, Rol rol, DateTime?fechaVencLibreta) { using (uruguay_busEntities db = new uruguay_busEntities()) { try { persona per = db.usuario.Find(idUsuario).persona; if (per == null) { throw new Exception("El ID del usuario es incorecto."); } if (rol.Equals(Rol.CONDUCTOR)) { if (fechaVencLibreta == null) { throw new Exception("Se deve ingresar la fecha de vencimiento de la libreta."); } if (!db.conductor.Any(x => x.id == per.id)) { conductor con = new conductor(); con.persona = per; con.vencimiento_libreta = (DateTime)fechaVencLibreta; db.conductor.Add(con); } } else if (rol.Equals(Rol.ADMIN)) { if (!db.admin.Any(x => x.id == per.id)) { admin adm = new admin(); adm.persona = per; db.admin.Add(adm); } } else if (rol.Equals(Rol.SUPERADMIN)) { if (!db.superadmin.Any(x => x.id == per.id)) { superadmin spm = new superadmin(); spm.persona = per; db.superadmin.Add(spm); } } db.SaveChanges(); } catch (Exception e) { throw e; } } }
public static conductor convert(Conductor c) { if (c == null) { return(null); } conductor ret = new conductor() { id = c.id, vencimiento_libreta = c.vencimiento_libreta }; return(ret); }
public Horario ModificarHorario(Horario h) { using (uruguay_busEntities db = new uruguay_busEntities()) { try { horario horarioModificado = db.horario.Find(h.id); if (h.hora != null) { horarioModificado.hora = h.hora; } if (h.conductor != null) { conductor conductor = db.conductor.Find(h.conductor.id); if (conductor.Equals(null)) { throw new Exception("El conductor que se desa asociar al horario no existe"); } horarioModificado.conductor = conductor; } if (h.vehiculo != null) { vehiculo vehiculo = db.vehiculo.Find(h.vehiculo.id); if (vehiculo.Equals(null)) { throw new Exception("El vehiculo que se desa asociar al horario no existe"); } horarioModificado.vehiculo = vehiculo; } db.Entry(horarioModificado).State = EntityState.Modified; db.SaveChanges(); return(HorarioConverter.convert(horarioModificado)); } catch (Exception e) { throw e; } } }
public ActionResult Solicitar(String vorigen, String vdestino, String vconductor) { int jj = Int32.Parse(vconductor); conductor vconductor2 = db.conductor.Where(p => p.idConductor == jj).FirstOrDefault(); viaje vj = new viaje { origen = vorigen, destino = vdestino, fecha = DateTime.Today, conductor = vconductor2, idTransporte = vconductor2.idTransporte, idConductor = Int32.Parse(vconductor), idEstado = 3 //Solicitado }; // Add the new object to the Orders collection. db.viaje.Add(vj); string datos = "ok"; try { db.SaveChanges(); } catch (DbEntityValidationException dbEx) { datos = "Surgio un error grabe" + dbEx.Message; } return(Json(datos, JsonRequestBehavior.AllowGet));; }
public ICollection <Viaje> ListarViajesDelDia(int idConductor) { using (uruguay_busEntities db = new uruguay_busEntities()) { try { ICollection <Viaje> ret = new List <Viaje>(); conductor c = db.conductor.Find(idConductor); if (c == null) { throw new Exception("No se pudo encontrar el conductor."); } foreach (var h in c.horario) { foreach (var v in h.viaje) { if (v.fecha.CompareTo(DateTime.Today) == 0 && v.finalizado == null) { Viaje Vi = ViajeConverter.convert(v); Vi.horario = HorarioConverter.convert(v.horario); Vi.horario.linea = LineaConverter.convert(v.horario.linea); ret.Add(Vi); } } } return(ret); } catch (Exception e) { throw e; } } }
public ActionResult Summary(String var1, String var2) { var1 = var1.Replace(".", ","); var2 = var2.Replace(".", ","); var transporte = db.transporte.Where(p => p.estado == "A"); double l1 = double.Parse(var1); double l2 = double.Parse(var2); String encabezado = "<table class='table table-hover table-condensed' data-click-to-select='true' data-select-item-name='radioName'> <thead><tr><th data-radio='true'>*</th> <th><b>Nombre</b></th><th><b>Distancia</b><th></tr></thead><tbody>"; String detalle = ""; //int i = 0; conductor[] n = new conductor[10]; double[] nn = new double[10]; List <transporte> vtransporte = transporte.ToList(); for (int i = 0; i < 5; i++) { int cc = 0; int mas = 0; foreach (var elementos in vtransporte) { conductor vvConductor = null; var vconductor = db.conductor.Where(p => p.idTransporte == elementos.idTransporte); foreach (var cond in vconductor) { vvConductor = cond; } // var vconductor = db.conductor.Where(c => c.idTransporte == elementos.idTransporte ).First(); double ll1 = double.Parse(elementos.latitud); double ll2 = double.Parse(elementos.longitud); //double distance = Calc(ll1, ll2, l1, l2); double distance = GetDistance(ll1, ll2, l1, l2); if (cc == 0) { n[i] = vvConductor; nn[i] = distance; } if (distance < nn[i]) { n[i] = vvConductor; nn[i] = distance; mas = cc; //vtransporte.Remove(elementos); } cc++; } vtransporte.RemoveAt(mas); } for (int x = 0; x < 5; x++) { if (n[x] != null) { double mas = Convert.ToDouble(nn[x]); mas = Math.Round(mas, 2); detalle += "<tr class= 'motorista' mot = '" + n[x].idConductor + "' data-index='" + x + "' >"; detalle += "<td><input class= 'check' type='checkbox' id= 'check" + n[x].idConductor + "' mot = '" + n[x].idConductor + "' ></td><td><img data-toggle='modal' data-target='#myModal' mot= '" + n[x].idConductor + "' width='70' height='70' class= 'imgMoto center-block img-responsive img-rounded' src = '/images/blog-img.jpg' ></td><td>" + n[x].nombre + "</td> <td>" + mas + " km. </td></tr>"; } } encabezado = encabezado + detalle + "</tbody></table>"; return(Json(encabezado, JsonRequestBehavior.AllowGet)); }