public async Task <IActionResult> Index(int page = 1, string sortExpression = nameof(AllSubscribersViewModel.DtAdd)) { if (!_userHelperService.HasSelectedGroup(User)) { return(RedirectToAction(nameof(GroupsController.Index), "Groups")); } var groupInfo = _userHelperService.GetSelectedGroup(User); var subscribers = _context.Subscribers .Include(x => x.VkUser) .Where(x => x.IdGroup == groupInfo.Key && !x.IsUnsubscribed) .Select(x => new AllSubscribersViewModel() { Id = x.Id, IdVk = x.IdVkUser, Birthday = x.VkUser.Birthday, City = x.VkUser.City, Country = x.VkUser.Country, DtAdd = x.DtAdd, FIO = $"{x.VkUser.LastName} {x.VkUser.FirstName}", Link = x.VkUser.Link, Photo = x.VkUser.PhotoSquare50, Sex = x.VkUser.Sex, IsSubscriber = x.IsSubscribedToGroup, IsChatAllowed = x.IsChatAllowed }); var model = await PagingList.CreateAsync(subscribers, nameof(Index), "Subscribers", 20, page, sortExpression, nameof(AllSubscribersViewModel.DtAdd)); ViewBag.IdGroup = groupInfo.Key; ViewBag.GroupName = groupInfo.Value; ViewBag.LinkGroup = $"https://vk.com/public{groupInfo.Key}"; return(View(model)); }
public async Task <IActionResult> Index() { if (!_userHelperService.HasSelectedGroup(User)) { return(RedirectToAction(nameof(GroupsController.Index), "Groups")); } var selectedGroup = _userHelperService.GetSelectedGroup(User); var model = await _context.RepostScenarios .Where(x => x.WallPost.IdGroup == selectedGroup.Key) .Select(x => new IndexRepostScenarioViewModel() { Id = x.Id, Name = x.Name, IdCheckingChain = x.CheckingChainContent.IdChain, CheckingChainName = x.CheckingChainContent.Chain.Name, CheckIsSubscriber = x.CheckIsSubscriber, HasGoToChain = x.IdGoToChain.HasValue, HasGoToChain2 = x.IdGoToErrorChain1.HasValue, GoToChainName = x.GoToChain != null ? x.GoToChain.Name : string.Empty, GoToChain2Name = x.GoToErrorChain1 != null ? x.GoToErrorChain1.Name : string.Empty, MessageIndex = x.CheckingChainContent.Index, MessageTextPart = x.CheckingChainContent.Message.TextPart, PostLink = new Uri($"https://vk.com/wall-{selectedGroup.Key}_{x.WallPost.IdVk}") }).ToArrayAsync(); return(View("Index", model)); }
public async Task <IActionResult> GetList() { var groupInfo = _userHelperService.GetSelectedGroup(User); var shortLinks = await _context.ShortUrls.Where(x => x.IdGroup == groupInfo.Key).Select(x => new { x.Id, x.Name }).ToDictionaryAsync(x => x.Id, x => x.Name); return(Json(shortLinks)); }
public async Task <IActionResult> Index() { var groupInfo = _userHelperService.GetSelectedGroup(User); var model = new IndexViewModel() { IsMaleBirthdayEnabled = await _context.BirthdayScenarios.Where(x => x.IdGroup == groupInfo.Key && x.IsMale).Select(x => (bool?)x.IsEnabled).FirstOrDefaultAsync(), IsFemaleBirthdayEnabled = await _context.BirthdayScenarios.Where(x => x.IdGroup == groupInfo.Key && !x.IsMale).Select(x => (bool?)x.IsEnabled).FirstOrDefaultAsync(), IsBirthdayWallEnabled = await _context.BirthdayWallScenarios.Where(x => x.IdGroup == groupInfo.Key).Select(x => (bool?)x.IsEnabled).FirstOrDefaultAsync() }; return(View(model)); }
public async Task <IActionResult> Index() { if (!_userHelperService.HasSelectedGroup(User)) { return(RedirectToAction(nameof(GroupsController.Index), "Groups")); } var selectedGroup = _userHelperService.GetSelectedGroup(User); var model = await _context.ShortUrlsScenarios .Where(x => x.ShortUrl.IdGroup == selectedGroup.Key) .Select(x => new IndexViewModel() { Id = x.Id, Name = x.Name, IsEnabled = x.IsEnabled, CheckingChainName = x.CheckingChainContent.Chain.Name, CheckIsSubscriber = x.CheckIsSubscriber, MessageIndex = x.CheckingChainContent.Index, MessageText = x.CheckingChainContent.Message.Text, ShortUrlName = x.ShortUrl.Name }).ToArrayAsync(); return(View(nameof(Index), model)); }
public async Task <ChartInfoViewModel> Generate(ReportsViewModel indexViewModel) { if (!DateTime.TryParseExact(indexViewModel.DtStart, "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dtStart) || !DateTime.TryParseExact(indexViewModel.DtEnd, "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dtEnd)) { return(null); } dtStart = DateTime.SpecifyKind(dtStart, DateTimeKind.Local).ToUniversalTime(); dtEnd = DateTime.SpecifyKind(dtEnd, DateTimeKind.Local).ToUniversalTime().AddMinutes(1); var function = statisticTypes.FirstOrDefault(x => x.Item1 == indexViewModel.StatisticType); if (function == null) { return(null); } var groupInfo = _userHelperService.GetSelectedGroup(User); return(await function.Item3.Invoke(_context, groupInfo.Key, dtStart, dtEnd)); }
public async Task <IActionResult> Create() { if (!_userHelperService.HasSelectedGroup(User)) { return(RedirectToAction(nameof(GroupsController.Index), "Groups")); } ScenarioViewModel newScenario = new ScenarioViewModel() { IsStrictMatch = true }; var selectedGroup = _userHelperService.GetSelectedGroup(User); ViewBag.Chains = await _context.Chains .Where(x => x.IdGroup == selectedGroup.Key) .ToDictionaryAsync(x => x.Id, x => x.Name); return(View("Edit", newScenario)); }
public async Task <IActionResult> Index() { var groupInfo = _userHelperService.GetSelectedGroup(User); var model = await _context.Scheduler_Messaging .Where(x => x.Message.IdGroup == groupInfo.Key) .Where(x => x.Status != Models.Database.Common.MessagingStatus.Finished) .Select(x => new MessagingViewModel() { DtAdd = x.DtAdd, DtStart = x.DtStart, HasImages = x.Message.Files.Any(), Message = x.Message.Text, Name = x.Name, HasKeyboard = !string.IsNullOrEmpty(x.Message.Keyboard), IdMessaging = x.Id, RecipientsCount = x.RecipientsCount, Status = x.Status }).ToArrayAsync(); ViewBag.IdGroup = groupInfo.Key; return(View(nameof(Index), model)); }
// GET: Chains public async Task <IActionResult> Index() { if (!_userHelperService.HasSelectedGroup(User)) { return(RedirectToAction(nameof(GroupsController.Index), "Groups")); } var selectedGroup = _userHelperService.GetSelectedGroup(User); var model = await _context.Chains .Where(x => x.IdGroup == selectedGroup.Key) .Select(x => new IndexViewModel() { Id = x.Id, Name = x.Name, IsEnabled = x.IsEnabled, SubscribersInChain = _context.SubscribersInChains.Count(y => !y.IsSended && y.ChainStep.IdChain == x.Id), TotalSubscribersInChain = _context.History_SubscribersInChainSteps .Where(y => y.ChainStep.IdChain == x.Id) .GroupBy(y => y.IdSubscriber).Count() }).ToListAsync(); return(View(model)); }
public async Task <IActionResult> Index() { ViewBag.NotificationElementTypes = NotificationElementTypes; ViewBag.NotificationTypes = NotificationTypes; var groupInfo = _userHelperService.GetSelectedGroup(User); var notifications = await _context.Notifications .Where(x => x.IdGroup == groupInfo.Key) .Select(x => new IndexViewModel() { Id = x.Id, DtCreate = x.DtCreate.ToLocalTime(), IsEnabled = x.IsEnabled, Name = x.Name, ElementType = x.ElementType, IdElement = Guid.Parse(x.IdElement), NotificationType = x.NotificationType, NotifyTo = x.NotifyTo }) .ToArrayAsync(); var model = new List <IndexViewModel>(); if (notifications.Length == 0) { return(View(model)); } model.AddRange(notifications); var scenariosNames = await _context.Scenarios.Where(x => model.Where(y => y.ElementType == 0).Select(y => y.IdElement).Contains(x.Id)).Select(x => new { x.Id, x.Name }).ToDictionaryAsync(x => x.Id, x => x.Name); var chainsNames = await _context.Chains.Where(x => model.Where(y => y.ElementType == 1).Select(y => y.IdElement).Contains(x.Id)).Select(x => new { x.Id, x.Name }).ToDictionaryAsync(x => x.Id, x => x.Name); var chainStepsNames = await _context.ChainContents.Where(x => model.Where(y => y.ElementType == 2).Select(y => y.IdElement).Contains(x.Id)).Select(x => new { x.Id, x.Chain.Name, x.Index }).ToDictionaryAsync(x => x.Id, x => string.Concat(x.Name, " - шаг ", x.Index)); var vkNames = await _context.VkUsers.Where(x => model.Where(y => y.NotificationType == 0).Select(y => long.Parse(y.NotifyTo)).Contains(x.IdVk)).Select(x => new { x.IdVk, x.FirstName, x.LastName }).ToDictionaryAsync(x => x.IdVk, x => string.Concat(x.FirstName, " ", x.LastName)); foreach (var item in model) { switch (item.ElementType) { case 0: { item.ElementName = scenariosNames[item.IdElement]; break; } case 1: { item.ElementName = chainsNames[item.IdElement]; break; } case 2: { item.ElementName = chainStepsNames[item.IdElement]; break; } } switch (item.NotificationType) { case 0: { item.NotifyToUrl = string.Concat("https://vk.com/id", item.NotifyTo); item.NotifyTo = vkNames[long.Parse(item.NotifyTo)]; break; } case 1: { item.NotifyToUrl = "mailto:" + item.NotifyTo; break; } } } return(View(model)); }