Ejemplo n.º 1
0
 internal static DeviceResponse SaveDevice(NewDevice device)
 {
     DeviceResponse dr=new DeviceResponse();
     var dev = repo.Select<Device>().Where(k => k.DevicePhoneNumber == device.DevicePhoneNumber);
     var count = dev.Any();
     if(count)
     {
         dr.Status = false;
         dr.StatusMessage = "Phone number already exist";
         dr.Device = dev.FirstOrDefault();
     }
     else
     {
         repo.Insert(new Device {DevicePhoneNumber = device.DevicePhoneNumber, DeviceToken = device.DeviceToken});
         dr.Status = true;
         dr.StatusMessage = "Saved";
         dr.Device = dev.FirstOrDefault();
     }
     return dr;
 }
Ejemplo n.º 2
0
 internal static DeviceResponse UpdateDevice(NewDevice device)
 {
     var dev = repo.Select<Device>().FirstOrDefault(k => k.DevicePhoneNumber == device.DevicePhoneNumber);
     DeviceResponse dr=new DeviceResponse();
     if (dev != null)
     {
         dev.DeviceToken = device.DeviceToken;
         repo.Update(dev);
         dr.Status = true;
         dr.StatusMessage = "Updated";
         dr.Device = dev;
     }
     else
     {
         dr.Status = false;
         dr.StatusMessage = "Device not found";
         dr.Device=new Device();
     }
     return dr;
 }