public List <User> GetAll()
 {
     using (var context = new LocationProviderContext())
     {
         return(context.User.ToList());
     }
 }
 public List <Location> GetAllByDevice(int deviceId)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Location.Where(x => x.DeviceId == deviceId).ToList());
     }
 }
 public Device Get(int id)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Device.Include("Geofence").FirstOrDefault(a => a.DeviceId == id));
     }
 }
Exemple #4
0
 public Geofence Get(int id)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Geofence.FirstOrDefault(a => a.GeofenceId == id));
     }
 }
 public User Get(int id)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.User.FirstOrDefault(a => a.Id == id));
     }
 }
 public User GetByUserId(string userId)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.User.FirstOrDefault(a => a.UserId == userId));
     }
 }
 public List <Device> GetAll()
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Device.ToList());
     }
 }
 public void Remove(Device device)
 {
     using (var context = new LocationProviderContext())
     {
         context.Device.Remove(device);
         context.SaveChanges();
     }
 }
 public void Update(Location Location)
 {
     using (var context = new LocationProviderContext())
     {
         context.Location.AddOrUpdate(Location);
         context.SaveChanges();
     }
 }
Exemple #10
0
 public void Remove(Geofence geofence)
 {
     using (var context = new LocationProviderContext())
     {
         context.Geofence.Remove(geofence);
         context.SaveChanges();
     }
 }
Exemple #11
0
 public void Add(Geofence geofence)
 {
     using (var context = new LocationProviderContext())
     {
         context.Geofence.AddOrUpdate(geofence);
         context.SaveChanges();
     }
 }
 public void Update(Device device)
 {
     using (var context = new LocationProviderContext())
     {
         context.Device.AddOrUpdate(device);
         context.SaveChanges();
     }
 }
 public void Remove(Location Location)
 {
     using (var context = new LocationProviderContext())
     {
         context.Location.Remove(Location);
         context.SaveChanges();
     }
 }
 public void Remove(User user)
 {
     using (var context = new LocationProviderContext())
     {
         context.User.Remove(user);
         context.SaveChanges();
     }
 }
 public void Update(User user)
 {
     using (var context = new LocationProviderContext())
     {
         context.User.AddOrUpdate(user);
         context.SaveChanges();
     }
 }
 public void AddLocation(int id, Location location)
 {
     using (var context = new LocationProviderContext())
     {
         var device = context.Device.FirstOrDefault(a => a.DeviceId == id);
         context.Set <Device>().Attach(device);
         device.Locations.Add(location);
         context.SaveChanges();
     }
 }
 public void AddNotExisting(string userId, User u)
 {
     using (var context = new LocationProviderContext())
     {
         var user = context.User.FirstOrDefault(a => a.UserId == userId);
         if (user == null)
         {
             context.User.AddOrUpdate(u);
             context.SaveChanges();
         }
     }
 }
Exemple #18
0
        public void Update(int id, float north, float south, float east, float west)
        {
            using (var context = new LocationProviderContext())
            {
                var device = context.Device.FirstOrDefault(a => a.DeviceId == id);

                device.Geofence.North = north;
                device.Geofence.South = south;
                device.Geofence.East  = east;
                device.Geofence.West  = west;

                context.Device.AddOrUpdate(device);

                context.SaveChanges();
            }
        }
        public List <Device> GetDevicesByUserId(string userId)
        {
            using (var context = new LocationProviderContext())
            {
                var user = context.User.FirstOrDefault(a => a.UserId == userId);

                List <Device> relatedList = new List <Device>();

                var deviceList = context.Device.ToList();

                foreach (var device in deviceList)
                {
                    if (device.User.Id == user.Id)
                    {
                        relatedList.Add(device);
                    }
                }

                return(relatedList);
            }
        }