Example #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);
                }
            }
        }
Example #2
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);
            }
        }
Example #3
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);
            }
        }