public async Task <IActionResult> Send(int id)
        {
            var post = await _postApplicationService.GetById(id);

            if (post == null)
            {
                return(RedirectToAction(nameof(Index)));
            }
            var channels = await _channelApplicationService.GetAll(
                new PagedAndSortedResultRequestDto
            {
                MaxResultCount = int.MaxValue
            });

            return(View(new PostsSendViewModel
            {
                Id = id,
                Post = post,
                Channels = channels
            }));
        }
示例#2
0
        protected override void DoWork()
        {
            var items = _scheduleService.GetItems(Clock.Now, 20);

            foreach (var item in items)
            {
                var post    = _postService.GetById(item.PostId).Result;
                var channel = _channelService.Get(new EntityDto <long>(item.ChannelId)).Result;
                if (post != null && (channel?.Own ?? false))
                {
                    _bot.Client.SendTextMessageAsync(new ChatId(channel.Id), post.Body).Wait();
                }
                item.Done = true;
                _scheduleService.Update(item).Wait();
            }
        }