예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
                }
            }
        }
예제 #10
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);
            }
        }