コード例 #1
0
        public async Task VideoCommand([Remainder] string videoTitle)
        {
            if (!VideoService.IsReady)
            {
                await ReplyAsync("Bot has not finished downloading all videos yet.").ConfigureAwait(false);

                return;
            }
            if (string.IsNullOrWhiteSpace(videoTitle))
            {
                await ReplyAsync("Empty video title given, please specify").ConfigureAwait(false);

                return;
            }
            var dict = new Dictionary <string, Tuple <string, Func <EmbedBuilder> > >();
            int i    = 1;

            string reply = "Which of these videos did you mean?" + Environment.NewLine;

            string videoTitleToLower = videoTitle.ToLower();

            foreach (Result video in VideoService.AllVideos.Values
                     .OrderByDescending(x => x.Name.ToLower().LongestCommonSubstring(videoTitleToLower).Length).Take(20)
                     .OrderBy(x => x.Name.LevenshteinDistance(videoTitle)).Take(10))
            {
                dict.Add(i.ToString(), Tuple.Create <string, Func <EmbedBuilder> >("", () => video.ToEmbed()));
                reply += $"{i++}. {video.Name} {Environment.NewLine}";
            }
            var messageToEdit =
                await ReplyAsync(reply +
                                 "Just type the number you want, this command will self-destruct in 2 minutes if no action is taken.").ConfigureAwait(false);

            FollowUpService.AddNewFollowUp(new FollowUp(Services, dict, Context.User.Id, Context.Channel.Id,
                                                        messageToEdit));
        }
コード例 #2
0
        public ActionResult FollowUpEdit(int id, FollowUpEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.FollowUpID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpService(userId);

            if (service.UpdateFollowUp(model))
            {
                TempData["SaveResult"] = "Your Follow-up was updated.";
                return(RedirectToAction("FollowUpIndex"));
            }

            ModelState.AddModelError("", "Your Follow-up could not be updated.");
            return(View(model));
        }
コード例 #3
0
        public ActionResult Delete(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpService(userId);
            var model   = service.GetFollowUpById(id);

            return(View(model));
        }
コード例 #4
0
        // GET: FollowUp
        public ActionResult FollowUpIndex()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpService(userId);
            var model   = service.GetFollowUps();

            return(View(model));
        }
コード例 #5
0
        public ActionResult FollowUpDelete(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpService(userId);

            service.DeleteFollowUp(id);

            TempData["SaveResult"] = "Your Follow-up was deleted";

            return(RedirectToAction("FollowUpIndex"));
        }
コード例 #6
0
        public ActionResult FollowUpCreate(FollowUpCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpService(userId);

            service.CreateFollowUp(model);

            return(RedirectToAction("FollowUpIndex"));
        }
コード例 #7
0
        public ActionResult FollowUpEdit(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpService(userId);
            var detail  = service.GetFollowUpById(id);
            var model   =
                new FollowUpEdit
            {
                FollowUpID       = detail.FollowUpID,
                ShortDescription = detail.ShortDescription,
                FollowUpStatusID = detail.FollowUpStatusID,
                Notes            = detail.Notes,
                DueUtc           = (DateTimeOffset)detail.DueUtc
            };

            return(View(model));
        }