public VEHICLE GetVehicleAvailable(int codZone, int codTypeVehicle) { using (var Context = new TransporteModalEntities()) { bool exist = (from v in Context.VEHICLE.Include("TYPEVEHICLE").Include("ZONE").AsNoTracking() where v.Status == true && v.Available == true && v.ZONE.IdZone == codZone && v.TYPEVEHICLE.IdTypeVehicle == codTypeVehicle select v).Any(); if (exist) { var query = (from v in Context.VEHICLE.Include("TYPEVEHICLE").Include("ZONE").AsNoTracking() where v.Status == true && v.Available == true && v.ZONE.IdZone == codZone && v.TYPEVEHICLE.IdTypeVehicle == codTypeVehicle select v).First(); query.Available = false; Context.Entry(query).State = EntityState.Modified; Context.SaveChanges(); return(query); } else { return(null); } } }
public int CountUserByZone() { using (var Context = new TransporteModalEntities()) { var exist = (from a in Context.ACCESS.Include("STATION").Include("USER").AsNoTracking() join s in Context.STATION.Include("ZONE").AsNoTracking() on a.STATION.IdStation equals s.IdStation into leftAcess from la in leftAcess.DefaultIfEmpty() select a).Any(); if (exist) { var query = (from a in Context.ACCESS.Include("STATION").Include("USER").AsNoTracking() join s in Context.STATION.Include("ZONE").AsNoTracking() on a.STATION.IdStation equals s.IdStation into leftAcess from la in leftAcess.DefaultIfEmpty() select a).Count(); return(query); } else { return(0); } } }
public ZONE GetZone(int codZone) { using (var Context = new TransporteModalEntities()) { var query = (from z in Context.ZONE.AsNoTracking() where z.IdZone == codZone select z).First(); return(query); } }
public List <VEHICLE> GetListVehicle() { using (var Context = new TransporteModalEntities()) { var query = (from v in Context.VEHICLE.Include("TYPEVEHICLE").Include("ZONE").AsNoTracking() where v.Status == true select v).ToList(); return(query); } }
public TYPESTATION GetTypeStation(int codTypeStation) { using (var Context = new TransporteModalEntities()) { var query = (from s in Context.TYPESTATION.AsNoTracking() where s.IdTypeStation == codTypeStation select s).First(); return(query); } }
public List <STATION> GetListStation() { using (var Context = new TransporteModalEntities()) { var query = (from s in Context.STATION.Include("TYPESTATION").Include("ZONE").AsNoTracking() where s.Status == true orderby s.NameStation select s).ToList(); return(query); } }
public STATION GetStation(int codStation) { using (var Context = new TransporteModalEntities()) { var query = (from s in Context.STATION.Include("TYPESTATION").Include("ZONE").AsNoTracking() where s.Status == true && s.IdStation == codStation orderby s.NameStation select s).First(); return(query); } }
public bool UpdateStatus(int idStation, bool status) { using (var Context = new TransporteModalEntities()) { bool exist = (from s in Context.STATION.AsNoTracking() where s.IdStation == idStation select s).Any(); if (exist) { var entity = (from s in Context.STATION.AsNoTracking() where s.IdStation == idStation select s).FirstOrDefault(); entity.Status = status; Context.Entry(entity).State = EntityState.Modified; Context.SaveChanges(); exist = true; return(exist); } return(exist); } }
public int CountVehicleByZone() { using (var Context = new TransporteModalEntities()) { bool exist = (from v in Context.VEHICLE.Include("TYPEVEHICLE").Include("ZONE").AsNoTracking() where v.Status == true && v.Available == true select v).Any(); if (exist) { int count = (from v in Context.VEHICLE.Include("TYPEVEHICLE").Include("ZONE").AsNoTracking() where v.Status == true && v.Available == true select v).Count(); return(count); } else { return(0); } } }
public bool UpdateAvailable(string idVehicle) { using (var Context = new TransporteModalEntities()) { bool exist = (from v in Context.VEHICLE.AsNoTracking() where v.IdVehicle.ToUpper() == idVehicle.ToUpper() select v).Any(); if (exist) { var entity = (from v in Context.VEHICLE.AsNoTracking() where v.IdVehicle.ToUpper() == idVehicle.ToUpper() select v).FirstOrDefault(); entity.Available = true; Context.Entry(entity).State = EntityState.Modified; Context.SaveChanges(); exist = true; return(exist); } return(exist); } }