コード例 #1
0
 public List <User> GetAll()
 {
     using (var context = new LocationProviderContext())
     {
         return(context.User.ToList());
     }
 }
コード例 #2
0
 public List <Location> GetAllByDevice(int deviceId)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Location.Where(x => x.DeviceId == deviceId).ToList());
     }
 }
コード例 #3
0
 public Device Get(int id)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Device.Include("Geofence").FirstOrDefault(a => a.DeviceId == id));
     }
 }
コード例 #4
0
 public Geofence Get(int id)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Geofence.FirstOrDefault(a => a.GeofenceId == id));
     }
 }
コード例 #5
0
 public User Get(int id)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.User.FirstOrDefault(a => a.Id == id));
     }
 }
コード例 #6
0
 public User GetByUserId(string userId)
 {
     using (var context = new LocationProviderContext())
     {
         return(context.User.FirstOrDefault(a => a.UserId == userId));
     }
 }
コード例 #7
0
 public List <Device> GetAll()
 {
     using (var context = new LocationProviderContext())
     {
         return(context.Device.ToList());
     }
 }
コード例 #8
0
 public void Remove(Device device)
 {
     using (var context = new LocationProviderContext())
     {
         context.Device.Remove(device);
         context.SaveChanges();
     }
 }
コード例 #9
0
 public void Update(Location Location)
 {
     using (var context = new LocationProviderContext())
     {
         context.Location.AddOrUpdate(Location);
         context.SaveChanges();
     }
 }
コード例 #10
0
 public void Remove(Geofence geofence)
 {
     using (var context = new LocationProviderContext())
     {
         context.Geofence.Remove(geofence);
         context.SaveChanges();
     }
 }
コード例 #11
0
 public void Add(Geofence geofence)
 {
     using (var context = new LocationProviderContext())
     {
         context.Geofence.AddOrUpdate(geofence);
         context.SaveChanges();
     }
 }
コード例 #12
0
 public void Update(Device device)
 {
     using (var context = new LocationProviderContext())
     {
         context.Device.AddOrUpdate(device);
         context.SaveChanges();
     }
 }
コード例 #13
0
 public void Remove(Location Location)
 {
     using (var context = new LocationProviderContext())
     {
         context.Location.Remove(Location);
         context.SaveChanges();
     }
 }
コード例 #14
0
 public void Remove(User user)
 {
     using (var context = new LocationProviderContext())
     {
         context.User.Remove(user);
         context.SaveChanges();
     }
 }
コード例 #15
0
 public void Update(User user)
 {
     using (var context = new LocationProviderContext())
     {
         context.User.AddOrUpdate(user);
         context.SaveChanges();
     }
 }
コード例 #16
0
 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();
     }
 }
コード例 #17
0
 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();
         }
     }
 }
コード例 #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();
            }
        }
コード例 #19
0
        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);
            }
        }