Example #1
0
        public void MoveAlbum(PerformerViewModel performerNew)
        {
            InitialPerformer.Albums.Remove(AlbumToMove);

            AlbumToMove.Performer = Mapper.Map <Performer>(performerNew);
            AlbumToMove.LocateImagePath();
        }
Example #2
0
        public void CreatePerformer(PerformerViewModel performerViewModel)
        {
            var performer = new Performer
            {
                Description   = performerViewModel.Performer.Description,
                IsActive      = true,
                Name          = performerViewModel.Performer.Name,
                PerformerType = performerViewModel.Performer.PerformerType,
                ImageUrl      = performerViewModel.Performer.ImageUrl,
                TourName      = performerViewModel.Performer.TourName
            };

            if (string.IsNullOrWhiteSpace(performer.ImageUrl))
            {
                performer.ImageUrl = DefaultImgSrc;
            }

            if (performer.PerformerType.Equals(PerformerType.Musician))
            {
                performer.Genre = performerViewModel.Performer.Genre;
            }
            else
            {
                performer.Topic = performerViewModel.Performer.Topic;
            }

            performer.IsActive = true;
            _context.Insert(performer);
            _context.Commit();
        }
Example #3
0
        private void BeginMoveAlbum()
        {
            if (SelectedAlbum == null)
            {
                return;
            }

            _albumToMove          = SelectedAlbum;
            _albumToMovePerformer = SelectedPerformer;

            MessageBox.Show("Now select the performer and click the 'Move album here' button");
        }
Example #4
0
        public void BeginMoveAlbum(AlbumViewModel album, PerformerViewModel performer)
        {
            if (album is null)
            {
                return;
            }

            AlbumToMove      = album;
            InitialPerformer = performer;

            MessageBox.Show("Now select the performer and click the 'Move album here' button");
        }
Example #5
0
        public PerformerViewModel NewPerformerViewModel()
        {
            var viewModel = new PerformerViewModel
            {
                Performer = new PerformerDto(),
            };

            viewModel.PerformerTypes = EnumUtil.GetValues <PerformerType>();
            viewModel.Genres         = EnumUtil.GetValues <Genre>();
            viewModel.Topics         = EnumUtil.GetValues <Topic>();

            return(viewModel);
        }
Example #6
0
        public void AddPerformerToCanvas(PerformerViewModel performerViewModel)
        {
            var pos = TopPerformers.Count;

            var left = (pos % ItemsPerRow) * ItemWidth + _randomizer.Next(-OffsetRandomness / 2, OffsetRandomness / 2);
            var top  = (pos / ItemsPerRow) * ItemHeight + _randomizer.Next(OffsetRandomness);

            TopPerformers.Add(new CanvasPerformerViewModel
            {
                Performer = performerViewModel,
                Left      = left,
                Top       = top
            });
        }
Example #7
0
        public PerformerViewModel ReturnPerformerViewModel(int id)
        {
            Performer performer = CheckPerformerNullValue(id);

            var viewModel = new PerformerViewModel
            {
                PerformerTypes = EnumUtil.GetValues <PerformerType>(),
                Genres         = EnumUtil.GetValues <Genre>(),
                Topics         = EnumUtil.GetValues <Topic>()
            };

            viewModel.Performer = MapPerformerToDto(performer);

            return(viewModel);
        }
Example #8
0
        public ActionResult Save(PerformerViewModel performerViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("PerformerForm", performerViewModel));
            }

            if (performerViewModel.Performer.Id == 0)
            {
                _performerService.CreatePerformer(performerViewModel);
            }
            else
            {
                _performerService.EditPerformer(performerViewModel, performerViewModel.Performer.Id);
            }

            return(RedirectToAction("Index", "Performers"));
        }
Example #9
0
        public ActionResult Performer(int?id, string sortOption, int pageSize = 10, int page = 1)
        {
            PerformerDTO       performerDto = performerService.Get(id);
            PerformerViewModel performer    = Mapper.Map <PerformerDTO, PerformerViewModel>(performerDto);

            if (sortOption == null)
            {
                sortOption = "default";
            }
            IEnumerable <SongDTO>       songDtos = songService.GetSongsChunkWithOrder(performer.Id, sortOption, page, pageSize);
            IEnumerable <SongViewModel> songs    = Mapper.Map <IEnumerable <SongDTO>, IEnumerable <SongViewModel> >(songDtos);
            int songsCount = songService.GetSongsCount(performer.Id);
            var pagedList  = new StaticPagedList <SongViewModel>(songs, page, pageSize, songsCount);

            ViewBag.page      = page;
            ViewBag.pageSize  = pageSize;
            ViewBag.pagedList = pagedList;
            return(Request.IsAjaxRequest()
                ? (ActionResult)PartialView("PartialSongList", pagedList)
                : View(performer));
        }
Example #10
0
        public void EditPerformer(PerformerViewModel performerViewModel, int id)
        {
            Performer performerToEdit = CheckPerformerNullValue(id);

            performerToEdit.Description   = performerViewModel.Performer.Description;
            performerToEdit.IsActive      = true;
            performerToEdit.Name          = performerViewModel.Performer.Name;
            performerToEdit.PerformerType = performerViewModel.Performer.PerformerType;
            performerToEdit.TourName      = performerViewModel.Performer.TourName;
            performerToEdit.ImageUrl      = performerViewModel.Performer.ImageUrl;

            if (performerToEdit.PerformerType.Equals(PerformerType.Musician))
            {
                performerToEdit.Genre = performerViewModel.Performer.Genre;
            }
            else
            {
                performerToEdit.Topic = performerViewModel.Performer.Topic;
            }

            _context.Commit();
        }
Example #11
0
        public async Task <IActionResult> Performer(int id)
        {
            var settings = await _performerSchedulingService.GetSettingsAsync();

            var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings);

            if (schedulingStage < PsSchedulingStage.SchedulingPreview)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var performer = new PsPerformer();

            try
            {
                performer = await _performerSchedulingService.GetPerformerByIdAsync(id,
                                                                                    includeImages : true,
                                                                                    includePrograms : true,
                                                                                    includeSchedule : true,
                                                                                    onlyApproved : true);
            }
            catch (GraException gex)
            {
                ShowAlertDanger("Unable to view performer: ", gex);
                return(RedirectToAction(nameof(Performers)));
            }

            var system = await _performerSchedulingService
                         .GetSystemWithoutExcludedBranchesAsync(GetId(ClaimType.SystemId));

            var viewModel = new PerformerViewModel
            {
                AgeGroups = await _performerSchedulingService
                            .GetPerformerAgeGroupsAsync(performer.Id),
                BlackoutDates = await _performerSchedulingService.GetBlackoutDatesAsync(),
                Performer     = performer,
                Settings      = settings,
                System        = system
            };

            if (!performer.AllBranches)
            {
                viewModel.BranchAvailability = await _performerSchedulingService
                                               .GetPerformerBranchIdsAsync(performer.Id, system.Id);
            }

            if (performer.Images.Count > 0)
            {
                viewModel.ImagePath = _pathResolver.ResolveContentPath(
                    performer.Images[0].Filename);
            }

            if (!string.IsNullOrWhiteSpace(performer.Website) &&
                Uri.TryCreate(performer.Website, UriKind.Absolute, out Uri absoluteUri))
            {
                viewModel.Uri = absoluteUri;
            }

            var performerIndexList = await _performerSchedulingService
                                     .GetPerformerIndexListAsync(true);

            var index = performerIndexList.IndexOf(id);

            viewModel.ReturnPage = (index / PerformersPerPage) + 1;
            if (index != 0)
            {
                viewModel.PrevPerformer = performerIndexList[index - 1];
            }
            if (performerIndexList.Count != index + 1)
            {
                viewModel.NextPerformer = performerIndexList[index + 1];
            }

            return(View(viewModel));
        }
Example #12
0
        private async void MoveAlbum()
        {
            if (_albumToMove == null)
            {
                MessageBox.Show("Please select album to move");
                return;
            }

            await _albumService.MoveAlbumToPerformerAsync(_albumToMove.Id, SelectedPerformer.Id);

            var album     = Mapper.Map <Album>(_albumToMove);
            var performer = Mapper.Map <Performer>(_selectedPerformer);

            _albumToMovePerformer.Albums.Remove(_albumToMove);
            _albumToMovePerformer.UpdateAlbumCollectionRate(_rateCalculator);

            _albumToMove.Performer = performer;
            _albumToMove.LocateImagePath();

            if (MessageBox.Show("Do you want to move all corresponding files as well?",
                                "Confirmation",
                                MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes)
            {
                await InsertAlbumToCollectionAsync(_albumToMove);

                return;
            }

            var pathlist = FileLocator.MakePerformerImagePathlist(performer);
            var path     = string.Empty;

            if (pathlist.Count == 1)
            {
                path = Path.GetDirectoryName(pathlist.First());
            }
            else
            {
                var choice = new ChoiceWindow();
                choice.SetChoiceList(pathlist.Select(p => Path.GetDirectoryName(p)));
                choice.ShowDialog();

                path = choice.ChoiceResult;

                Directory.CreateDirectory(path);
            }

            // move album cover image file

            var albumPath = FileLocator.GetAlbumImagePath(album);

            if (albumPath != string.Empty)
            {
                File.Move(albumPath, $"{path}\\{Path.GetFileName(albumPath)}");

                _albumToMove.LocateImagePath();
            }

            // move folder with song files

            var albumFolder = FileLocator.FindAlbumPath(album);

            if (albumFolder != string.Empty)
            {
                var destinationFolder = $"{Path.GetDirectoryName(path)}\\{new DirectoryInfo(albumFolder).Name}";

                if (Path.GetPathRoot(albumFolder) == Path.GetPathRoot(path))
                {
                    Directory.Move(albumFolder, destinationFolder);
                }

                // !!!!! .NET, are you kidding me? (((

                else
                {
                    Directory.CreateDirectory(destinationFolder);

                    foreach (string dir in Directory.GetDirectories(albumFolder, "*", SearchOption.AllDirectories))
                    {
                        Directory.CreateDirectory(Path.Combine(destinationFolder, dir.Substring(albumFolder.Length + 1)));
                    }

                    foreach (string file in Directory.GetFiles(albumFolder, "*", SearchOption.AllDirectories))
                    {
                        File.Copy(file, Path.Combine(destinationFolder, file.Substring(albumFolder.Length + 1)));
                    }

                    Directory.Delete(albumFolder, true);
                }
            }

            await InsertAlbumToCollectionAsync(_albumToMove);

            _albumToMove          = null;
            _albumToMovePerformer = null;
        }
Example #13
0
        private void UpdatePerformerRate(PerformerViewModel performer)
        {
            var rates = performer.Albums.Select(a => a.Rate);

            performer.AlbumCollectionRate = _rateCalculator.Calculate(rates);
        }
Example #14
0
 public PerformerPage()
 {
     InitializeComponent();
     BindingContext = model = new PerformerViewModel();
 }
Example #15
0
        public void MoveAlbumFiles(PerformerViewModel performerNew)
        {
            var album     = Mapper.Map <Album>(AlbumToMove);
            var performer = Mapper.Map <Performer>(performerNew);

            var initialAlbum = Mapper.Map <Album>(AlbumToMove);

            initialAlbum.Performer = Mapper.Map <Performer>(InitialPerformer);

            var pathlist = FileLocator.MakePerformerImagePathlist(performer);
            var path     = string.Empty;

            if (pathlist.Count == 1)
            {
                path = Path.GetDirectoryName(pathlist.First());
            }
            else
            {
                var parameters = new DialogParameters
                {
                    { "options", pathlist.Select(p => Path.GetDirectoryName(p)) }
                };

                _dialogService.ShowDialog("ChoiceWindow", parameters, r =>
                {
                    path = r.Parameters.GetValue <string>("choice");
                });

                Directory.CreateDirectory(path);
            }

            // move album cover image file

            var albumPath = FileLocator.GetAlbumImagePath(initialAlbum);

            if (albumPath != string.Empty)
            {
                File.Move(albumPath, $"{path}\\{Path.GetFileName(albumPath)}");

                AlbumToMove.LocateImagePath();
            }

            // move folder with song files

            var albumFolder = FileLocator.FindAlbumPath(initialAlbum);

            if (albumFolder != string.Empty)
            {
                var destinationFolder = $"{Path.GetDirectoryName(path)}\\{new DirectoryInfo(albumFolder).Name}";

                if (Path.GetPathRoot(albumFolder) == Path.GetPathRoot(path))
                {
                    Directory.Move(albumFolder, destinationFolder);
                }

                // !!!!! .NET, are you kidding me? (((

                else
                {
                    Directory.CreateDirectory(destinationFolder);

                    foreach (string dir in Directory.GetDirectories(albumFolder, "*", SearchOption.AllDirectories))
                    {
                        Directory.CreateDirectory(Path.Combine(destinationFolder, dir.Substring(albumFolder.Length + 1)));
                    }

                    foreach (string file in Directory.GetFiles(albumFolder, "*", SearchOption.AllDirectories))
                    {
                        File.Copy(file, Path.Combine(destinationFolder, file.Substring(albumFolder.Length + 1)));
                    }

                    Directory.Delete(albumFolder, true);
                }
            }
        }
Example #16
0
 public void EndMoveAlbum()
 {
     AlbumToMove      = null;
     InitialPerformer = null;
 }