private void DoAdd()
        {
            if (SelectedSearch != null &&
                StartDate.HasValue)
            {
                DateTime reminderTime = StartDate.Value.AddMinutes(-1 * Minutes);

                ReminderService.CreateReminder(SelectedSearch, Index, StartDate.Value, Spoor, reminderTime);
            }
        }
示例#2
0
        public async Task Remind([Summary("The name of the reminder.")] string name, [Summary("The specified interval")] TimeSpan interval, [Summary("The message to remind you of.")][Remainder] string message)
        {
            bool nameFree = ReminderService.CreateReminder(Context.User, Context.Channel, name, message, interval);

            if (!nameFree)
            {
                await ReplyAsync("", embed : EmbedService.MakeFailFeedbackEmbed("A reminder with that name already exists on this channel."), lifeTime : Config.FeedbackMessageLifeTime);
            }
            else
            {
                await ReplyAsync("", embed : EmbedService.MakeSuccessFeedbackEmbed($"Successfully created the reminder {name.Bold().Underline()}, will trigger in {interval.ToNiceTime()}."));
            }
        }
示例#3
0
        public void CreateReminderShouldReturnReminder()
        {
            var      mockRepo = new Mock <IReminderRepository>();
            Reminder reminder = new Reminder {
                ReminderName = "SMS", ReminderDescription = "SMS reminder", ReminderType = "notification", CreatedBy = "John"
            };

            mockRepo.Setup(repo => repo.CreateReminder(reminder)).Returns(reminder);
            var service = new ReminderService(mockRepo.Object);

            var actual = service.CreateReminder(reminder);

            Assert.NotNull(actual);
            Assert.IsAssignableFrom <Reminder>(actual);
        }
示例#4
0
        public async Task RemindMeCmdAsync([Remainder] string input)
        {
            try
            {
                _rs.CreateReminder(Context.Message, input);
            }
            catch (Exception ex)
            {
                await Context.MarkCmdFailedAsync(ex.ToString());

                return;
            }

            await Context.MarkCmdOkAsync().ConfigureAwait(false);
        }
 public async Task CreateReminder(TimeSpan time, [Remainder] string toRemind)
 {
     if (await _remainder.CreateReminder(new Reminder()
     {
         Remind = toRemind,
         TimeSpan = time,
         UserId = Context.User.Id
     }))
     {
         await ReplyAsync($":white_check_mark: I will remind you in `{time.ToHumanReadable()}`");
     }
     else
     {
         await ReplyAsync("You have too many reminders !");
     }
 }