Beispiel #1
0
 public bool GetContacts(TLClient client, ContactRepository contactRepo)
 {
     try
     {
         bool output = false;
         var  c      = Task.Run(() => client.GetContactsAsync());
         c.Wait();
         var contacts = c.Result.Users.ToList();
         output = true;
         foreach (var co in contacts)
         {
             var     cc       = co as TLUser;
             Contact contacto = new Contact
             {
                 Phone      = string.IsNullOrEmpty(cc.Phone) ? "" : cc.Phone,
                 Id         = cc.Id,
                 FirstName  = string.IsNullOrEmpty(cc.FirstName) ? "" : cc.FirstName,
                 LastName   = string.IsNullOrEmpty(cc.LastName) ? "" : cc.LastName,
                 Username   = string.IsNullOrEmpty(cc.Username) ? "" : cc.Username,
                 Status     = cc.Status == null ? "" : cc.Status.ToString().Split('.')[2].ToString().Substring(12).ToString(),
                 AccessHash = cc.AccessHash.Value,
                 Blocked    = false
             };
             contactRepo.InsertContact(contacto);
         }
         return(output);
     }
     catch (Exception ex)
     {
         throw;
     }
 }