Advertisement
onzulin

registro de usuario

Dec 22nd, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. public async static Task<bool> RegisterUser(usuarios user)
  2.         {
  3.             //MobileServiceCollection<usuarios, usuarios> items;
  4.             IMobileServiceTable<usuarios> usuariosTable = App.MobileService.GetTable<usuarios>();
  5.            
  6.  
  7.             MobileServiceInvalidOperationException exception = null;
  8.             try
  9.             {
  10.                 // Query that returns all items.  
  11.                 List<usuarios> userList = await usuariosTable.Take(1).Where(x => x.email == user.email).ToListAsync();
  12.                 /*
  13.                 por algun motivo que desconozco no hace bien el metodo ToListAsync() y bno hay manera de hacerlo funcionar, me gustaria que alguien me pudiera ayudar,
  14.                 estoy con este proyecto parado por culpa de esto, veo el proyecto de ejemplo que debe funcionar perfectamente y no se porque en mi proyecto no funciona,
  15.                 a ver si alguien me pudiera explicar que esta pasando
  16.                 */
  17.                 if (userList.Count == 0)
  18.                 {
  19.                     await App.MobileService.GetTable<usuarios>().InsertAsync(user);
  20.                     return true;
  21.                 }
  22.                 else
  23.                 {
  24.                     return false;
  25.                 }
  26.             }
  27.             catch (MobileServiceInvalidOperationException e)
  28.             {
  29.                 exception = e;
  30.             }
  31.             if (exception != null)
  32.             {
  33.                 await new MessageDialog(exception.Message, "Error loading items").ShowAsync();
  34.                 return false;
  35.             }
  36.             return true;
  37.                 // proceder a la insercion del regisstro
  38.  
  39.                
  40.            
  41.  
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement