public async Task LikeClient(VkClient client) { try { await VkApisManager.RandomLikeUser(client.VkAcc, client.ProfileVkId); await this.SetClientStatus(client.VkClientId, VkClient.Status.Liked); } catch (Exception e) { Console.WriteLine(""); } }
private async Task UpdateClients(VkAcc vkAcc) { using (var db = new ModelScoutDbContext(this._dbOptionsBuilder.Options)) { int Count = 50; var acc = db.VkAccs.FirstOrDefault(e => e.VkAccId == vkAcc.VkAccId); vkAcc.VkClients.AddRange(await VkApisManager.GetNewClients( acc, Count, this, db)); await db.SaveChangesAsync(); } }
public async Task AddClientToFriends(VkClient client) { try { await VkApisManager.AddUserToFriends(client.VkAcc, client.ProfileVkId); await this.IncrementAddedFriends(client.VkAcc); await this.SetClientStatus(client.VkClientId, VkClient.Status.Ready); } catch (Exception e) { await this.ClearFriends(client.VkAcc); } }
private async Task<VkAcc> UpdateVkAccStatus(VkAcc vkAcc) { //TODO: Check status of acc var profileInfo = await VkApisManager.GetProfileInfo(vkAcc); if (profileInfo != null) { vkAcc.FirstName = profileInfo.FirstName; vkAcc.LastName = profileInfo.LastName; //TODO: Set status of acc } else { //TODO: Set status of acc } return vkAcc; }
public async Task<List<InputMediaPhoto>> GetVkProfilePhotosMaxSizesAsync(VkClient vkClient) { VkNet.Utils.VkCollection<VkNet.Model.Attachments.Photo> Photos; Photos = await VkApisManager.GetProfilePhotosClient(vkClient); List<InputMediaPhoto> inputPhotos = new List<InputMediaPhoto>(); foreach (var Photo in Photos) { var maxHeight = Photo.Sizes.Max(e => e.Height); var maxPhoto = Photo.Sizes.FirstOrDefault(e => e.Height == maxHeight); inputPhotos.Add(new InputMediaPhoto(new InputMedia(maxPhoto.Url.ToString()))); } return inputPhotos; }
public async Task<VkAcc> CreateVkAcc(string Token) { VkAcc vkAcc; var result = await VkApisManager.TryAuthorize(Token); if (result == true) { using (var db = new ModelScoutDbContext(this._dbOptionsBuilder.Options)) { var user = await db.Users.FirstOrDefaultAsync(e => e.UserId == User.UserId); vkAcc = new VkAcc() { AccessToken = Token, FriendsLimit = 40, CountAddedFriends = 0, }; await this.UpdateVkAccStatus(vkAcc); user.VkAccs.Add(vkAcc); await db.SaveChangesAsync(); } return vkAcc; } return null; }