public void JoinTheNewGroupsAndPages(AccountViewModel account) { const string functionName = "Присоедениться к новым группам и страницам"; _notice.AddNotice(functionName, account.Id, "Отправляем запросы на присоединение аккаунта к группам и страницам..."); if (account.GroupSettingsId == null) { return; } var communities = new GetNewSettingsByAccountAndGroupIdQueryHandler(new DataBaseContext()).Handle( new GetNewSettingsByAccountAndGroupIdQuery { AccountId = account.Id, GroupId = (long)account.GroupSettingsId }); new DeleteNewSettingsCommandHandler(new DataBaseContext()).Handle(new DeleteNewSettingsCommand { AccountId = account.Id, GroupId = (long)account.GroupSettingsId }); foreach (var newSettingsData in communities) { _notice.AddNotice(functionName, account.Id, string.Format("В очереди {0} новых групп", newSettingsData.CommunityOptions.Groups.Count)); _notice.AddNotice(functionName, account.Id, string.Format("Начинаем отправлять запросы на присоединения к группам")); new JoinTheGroupsBySeleniumEngine().Execute(new JoinTheGroupsBySeleniumModel { Driver = _seleniumManager.RegisterNewDriver(account), Cookie = account.Cookie, Groups = newSettingsData.CommunityOptions.Groups, }); _notice.AddNotice(functionName, account.Id, string.Format("В очереди {0} новых страниц", newSettingsData.CommunityOptions.Pages.Count)); _notice.AddNotice(functionName, account.Id, string.Format("Начинаем отправлять запросы на присоединения к страницам")); new JoinThePagesBySeleniumEngine().Execute(new JoinThePagesBySeleniumModel { Driver = _seleniumManager.RegisterNewDriver(account), Cookie = account.Cookie, Pages = newSettingsData.CommunityOptions.Pages }); } _notice.AddNotice(functionName, account.Id, string.Format("Присоединения к группам и страницам успешно завершено")); }
public List <NewSettingsViewModel> GetNewSettings(long accountId, long groupId) { var settingsDbModels = new GetNewSettingsByAccountAndGroupIdQueryHandler(new DataBaseContext()).Handle( new GetNewSettingsByAccountAndGroupIdQuery { AccountId = accountId, GroupId = groupId }); var settingsModels = settingsDbModels.Select(data => new NewSettingsViewModel { AccountId = data.AccountId, Id = data.Id, SettingsGroupId = data.SettingsGroupId, CommunityOptions = new CommunityOptionsViewModel { Groups = data.CommunityOptions.Groups, Pages = data.CommunityOptions.Pages } }).ToList(); return(settingsModels); }