Пример #1
0
        public static async Task Rename(string showName)
        {
            Show s = await PrepareShow(fileQueue.ToArray(), showName);

            for (int i = 0; i < s.seasonList.Count; i++)
            {
                for (int y = 0; y < s.seasonList[i].episodeList.Count; y++)
                {
                    Episode e = s.seasonList[i].episodeList[y];
                    if (!File.Exists(e.path))
                    {
                        NotificationManager.AddNotification("File not found", "File not found at path:" + e.path + ". If the path is obviously incorrect, please report this as a bug.");
                    }
                    else
                    {
                        string newPath = Path.GetDirectoryName(e.path) + "/" + RegexTitle(RenameData.regex, s.seasonList[i].episodeList[y]) + Path.GetExtension(e.path);
                        if (!File.Exists(newPath))
                        {
                            File.Move(e.path, newPath);
                            RenameInQueue(e.path, newPath);
                            e.path = newPath;
                        }
                        else
                        {
                            NotificationManager.AddNotification(new Notification("Could not rename", "There is already " + Path.GetFileName(newPath)));
                        }
                    }
                }
            }
        }
        public async Task <ActionResult> _PostReview(Models.VM.CreateReviewVM review)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    TravelerProfile tpcheck = await ProfileManager.LoadUserAndTravelerProfile(User);

                    TravelerProfile tp = await ProfilesController.LoadProfile(review.ID);

                    if (tpcheck.ID == tp.ID)
                    {
                        throw new Exception("Access Violation Post Review! User tried to Review his own profile", new AccessViolationException());
                    }
                    TravelerProfileReviews treviews = tp.Reviews;
                    var             tpRevUpdate     = treviews;
                    TravelerProfile tPoster         = await ProfileManager.LoadUserAndTravelerProfile(User);

                    Review rev = new Review(review, tPoster.ID, tp.TravelerReviewsID);
                    tpRevUpdate.Reviews.Add(rev);
                    using (var db = new ApplicationDbContext())
                    {
                        db.Reviews.Add(rev);

                        await db.SaveChangesAsync();
                    }
                }
                catch (Exception e)
                {
                    NotificationManager.AddException(e);
                    NotificationManager.AddNotification(NotificationType.Error, "Oops, something went wrong!");
                }
            }
            return(RedirectToAction("Details", new { id = review.ID }));
        }
Пример #3
0
        private void AdvancedTitleIcon_MouseUp(object sender, MouseButtonEventArgs e)
        {
            TitleRegexWindow trw = new TitleRegexWindow();

            if (Functions.fileQueue != null && Functions.fileQueue.Length > 0)
            {
                Episode ep = Functions.GetEpisodeFromName(Functions.fileQueue[0].path);
                if (ep == null)
                {
                    NotificationManager.AddNotification(new Notification("Could not resolve show", "Show name format is invalid or unsupported", false, Importance.important));
                    return;
                }
                if (!string.IsNullOrEmpty(InputShowName.Text))
                {
                    ep.show = new Show(InputShowName.Text);
                }
                trw.Initialize(ep);
            }

            trw.Left = Left + 10;
            trw.Top  = Top + (Height - trw.ActualHeight) / 4 - 15;

            if (trw.ShowDialog() == true)
            {
                trw.GetResults(out RenameData.regex, out RenameData.episodeAdd, out RenameData.seasonAdd);
                UpdatePreview();
            }
        }
        public void AddNotification_Adds_Notification()
        {
            var manager = new NotificationManager();
            Assert.IsTrue(manager.GetNotifications().Count == 0);

            manager.AddNotification(new DummyError());
            Assert.IsTrue(manager.GetNotifications().Count == 1);
        }
Пример #5
0
 private async void RenameButtonClick(object sender, RoutedEventArgs e)
 {
     if (Functions.fileQueue == null || Functions.fileQueue.Length == 0)
     {
         NotificationManager.AddNotification("No file added", "But don't worry, everything was renamed.");
         return;
     }
     await Functions.Rename(InputShowName.Text);
 }