public void MapToDetailRep_DoesNotReturnNull_WithValidInput()
        {
            ArtistMapper mapper = new ArtistMapper();
            ArtistDetail result = mapper.MapToDetailRep(_validDbArtist);

            Assert.NotNull(result);
        }
        public void MapToDetailRep_HasExpectedBioText_WithValidInput()
        {
            ArtistMapper mapper = new ArtistMapper();
            ArtistDetail result = mapper.MapToDetailRep(_validDbArtist);

            Assert.Equal(_validDbArtist.BioText, result.BioText);
        }
        void artist_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string       link = ((Hyperlink)sender).TargetName;
            ArtistDetail page = new ArtistDetail(link, EntityType.Movie);

            page.ShowDialog();
        }
        public async Task <IActionResult> Edit(int id)
        {
            EditArtistViewModel model = new EditArtistViewModel();
            var genresResult          = await _genreRepo.ListAsync(contentPublicationFlags : PublishStatus.PUBLISHED);

            model.Genres = genresResult.Genres.Select(g => new SelectableGenreViewModel
            {
                Name       = g.Name,
                IsSelected = false
            }).ToList();

            ArtistDetail artist = await _artistRepo.GetAsync(id);

            if (artist != null)
            {
                model.Id              = artist.Id;
                model.Name            = artist.Name;
                model.BioText         = artist.BioText;
                model.BioImageId      = artist.BioImageId;
                model.Created         = artist.CreatedUtc;
                model.Updated         = artist.UpdatedUtc;
                model.PublishedStatus = artist.PublishedStatus;
                model.Genres.Where(g => artist.Genres.Contains(g.Name)).ToList().ForEach(x => x.IsSelected = true);

                return(View(model));
            }
            else
            {
                // todo: show error message
                return(RedirectToAction(nameof(Index)));
            }
        }
예제 #5
0
        public async void AddArtist_ReturnsNonNullResult_WithValidInput()
        {
            Artist       input  = CreateValidCreateModel();
            ArtistDetail result = await this.repo.AddAsync(input);

            Assert.NotNull(result);
        }
        public async Task <IActionResult> Edit(EditArtistViewModel model)
        {
            ArtistDetail artist = await _artistRepo.GetAsync(model.Id);

            if (artist != null)
            {
                // set non postback properties
                model.BioImageId      = artist.BioImageId;
                model.Created         = artist.CreatedUtc;
                model.Updated         = artist.UpdatedUtc;
                model.PublishedStatus = artist.PublishedStatus;
                if (ModelState.IsValid)
                {
                    int?createdBioImageId = null;
                    if (model.BioImage != null && model.BioImage.Length > 0)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            await model.BioImage.CopyToAsync(ms);

                            ImageReferenceDetail imageRef = await _imageRepo.AddAsync(new ImageReferenceDetail
                            {
                                Data     = ms.ToArray(),
                                FileName = model.BioImage.FileName,
                                MimeType = model.BioImage.ContentType
                            });

                            if (imageRef != null)
                            {
                                createdBioImageId = imageRef.Id;
                            }
                        }
                    }

                    artist.Name       = model.Name;
                    artist.BioText    = model.BioText;
                    artist.UpdatedUtc = DateTime.UtcNow;
                    artist.Genres     = model.Genres.Where(g => g.IsSelected).Select(g => g.Name).ToList();
                    if (createdBioImageId.HasValue)
                    {
                        artist.BioImageId = createdBioImageId.Value;
                    }
                    await _artistRepo.UpdateAsync(artist.Id, artist);

                    this.SetBootstrapPageAlert("Success", "Artist updated", BootstrapAlertType.success);
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(View(model));
                }
            }
            else
            {
                // todo: show error message
                return(RedirectToAction(nameof(Index)));
            }
        }
예제 #7
0
 public void CreateArtistDetail_Save_Dispose_CheckUnsubscribeFromSetUpdated()
 {
     using (ArtistDetail artistDetail = (ArtistDetail)ModulesManager.Current.OpenModuleObjectDetail(new ArtistDetailObject(Session, JamesCameron.Oid), true)) {
         artistDetail.ArtistEdit.VRObjectEditObject.VideoRentObject.FirstName = "J";
         Assert.IsTrue(artistDetail.Save());
     }
     Assert.IsNull(AllObjects <Artist> .Set.GetUpdatedEvent());
     Assert.IsNull(AllObjects <Movie> .Set.GetUpdatedEvent());
 }
예제 #8
0
        void artist_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string link = ((Hyperlink)sender).TargetName;

            Task.Factory.StartNew(() => Util.NotifyEvent("ArtistDetail:" + link));
            ArtistDetail page = new ArtistDetail(link, EntityType.XXX);

            page.ShowDialog();
        }
        public void MapToDetailRep_HasExpectedBioImageUrl_WithValidInput()
        {
            DbArtist sourceObj = _validDbArtist;

            sourceObj.BioImageId = 1515;
            ArtistMapper mapper = new ArtistMapper();
            ArtistDetail result = mapper.MapToDetailRep(_validDbArtist);

            Assert.Equal("/api/image/1515", result.BioImageUrl);
        }
        public void MapToDetailRep_HasNullBioImageId_WithNullInput()
        {
            DbArtist sourceObj = _validDbArtist;

            sourceObj.BioImageId = null;
            ArtistMapper mapper = new ArtistMapper();
            ArtistDetail result = mapper.MapToDetailRep(_validDbArtist);

            Assert.Null(result.BioImageId);
        }
예제 #11
0
        public async void AddArtist_ReturnsResultWithMatchingProperties()
        {
            Artist       input      = CreateValidCreateModel();
            ArtistDetail createdObj = await this.repo.AddAsync(input);

            Assert.Equal(input.Name, createdObj.Name);
            Assert.Equal(input.PublishedStatus, createdObj.PublishedStatus);
            Assert.Equal(input.BioText, createdObj.BioText);
            Assert.Equal(input.Genres, createdObj.Genres);
        }
예제 #12
0
 public void ChangeName_Save_CheckModuleTitle()
 {
     using (ArtistDetail artistDetail = (ArtistDetail)ModulesManager.Current.OpenModuleObjectDetail(new ArtistDetailObject(Session, JamesCameron.Oid), true)) {
         Assert.AreEqual("James Cameron", artistDetail.Title);
         artistDetail.ArtistEdit.VRObjectEditObject.VideoRentObject.FirstName = "J";
         Assert.AreEqual("James Cameron *", artistDetail.Title);
         Assert.IsTrue(artistDetail.Save());
         Assert.AreEqual("J Cameron", artistDetail.Title);
     }
 }
        void artist_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string link   = ((Hyperlink)sender).TargetName;
            Artist artist = ArtistServices.GetById(link);

            if (artist != null)
            {
                ArtistDetail page = new ArtistDetail(artist, EntityType.Series);
                page.ShowDialog();
            }
        }
예제 #14
0
 public ArtistListItemViewModel Map(ArtistDetail i)
 {
     return(new ArtistListItemViewModel
     {
         Id = i.Id,
         Name = i.Name,
         Created = i.CreatedUtc,
         Updated = i.UpdatedUtc,
         Status = i.PublishedStatus
     });
 }
예제 #15
0
        private static void AddRoleToArtist(ArtistDetail artistDetail, ArtistDTO artist)
        {
            var role = artistDetail.Instrument1;

            var instrument       = new InstrumentDTO(role);
            var artistInstrument = artist.artistInstruments.FirstOrDefault(i => i.Instrument1 == instrument.Instrument1);

            if (artistInstrument == null)
            {
                artistInstrument = instrument;
                artist.artistInstruments.Add(artistInstrument);
            }
        }
예제 #16
0
        private void cmdDetails_Click(object sender, RoutedEventArgs e)
        {
            string name = txtName.Text;

            Task.Factory.StartNew(() => Util.NotifyEvent("ArtistDetail:" + name));
            bool?dialogResults = new ArtistDetail(_artist, _entityType).ShowDialog();

            if (dialogResults == true)
            {
                RoutedEventArgs args = new RoutedEventArgs(CmdRefreshClickEvent);
                RaiseEvent(args);
            }
        }
        public void MapToDetailRep_HasPublishedStatus_WithValidInput(DbPublishedStatus publishedStatusTestCase)
        {
            DbArtist sourceObj = _validDbArtist;

            sourceObj.PublishStatus = publishedStatusTestCase;
            PublishedStatusEnumMapper statusMapper = new PublishedStatusEnumMapper();
            ArtistMapper         mapper            = new ArtistMapper();
            PublishStatus        expetedStatus     = statusMapper.Map(publishedStatusTestCase);
            ArtistDetail         result            = mapper.MapToDetailRep(sourceObj);
            ICollection <string> dbGenres          = _validDbArtist.ArtistGenres.Select(x => x.Genre.Name).ToList();

            Assert.Equal(expetedStatus, result.PublishedStatus);
        }
        public async Task <IActionResult> Delete(int id)
        {
            ArtistDetail artist = await _artistRepo.GetAsync(id);

            if (artist != null)
            {
                artist.PublishedStatus = PublishStatus.DELETED;
                await _artistRepo.UpdateAsync(artist.Id, artist);

                this.SetBootstrapPageAlert("Success", "Artist deleted", BootstrapAlertType.success);
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                this.SetBootstrapPageAlert("Error", "Artist was not deleted", BootstrapAlertType.danger);
                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task <IActionResult> Get(int id)
        {
            try{
                ArtistDetail artist = await _repo.GetAsync(id);

                if (artist != null)
                {
                    return(Ok(artist));
                }
                else
                {
                    return(NotFound(new ApiErrorRep($"Artist with ID {id} was nto found")));
                }
            }catch (RepositoryException e) {
                return(BadRequest(new ApiErrorRep(e.Message)));
            }catch (Exception e) {
                _logger.LogError("GetArtist", e, "Error getting artist");
                return(StatusCode(500, new ApiErrorRep("Unknown error")));
            }
        }
예제 #20
0
        private Mock <IArtistRepository> SetupMockWithValidReturnValuesForArtistInput(Artist artist, int artistId)
        {
            Mock <IArtistRepository> mock = new Mock <IArtistRepository>();

            ArtistDetail validResult = new ArtistDetail {
                Id              = artistId,
                BioText         = artist.BioText,
                CreatedUtc      = DateTime.UtcNow,
                Genres          = artist.Genres,
                Name            = artist.Name,
                UpdatedUtc      = DateTime.UtcNow,
                PublishedStatus = artist.PublishedStatus
            };

            mock.Setup(m => m.UpdateAsync(_existingArtistId, artist)).ReturnsAsync(validResult);
            mock.Setup(m => m.AddAsync(artist)).ReturnsAsync(validResult);
            mock.Setup(m => m.GetAsync(_existingArtistId)).ReturnsAsync(validResult);

            return(mock);
        }
예제 #21
0
        //Helper
        public ArtistDetail GetArtistByID(int id)
        {
            var venuesPlayed = new List <VenueDetail>();
            var venueService = new VenueService();

            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Artists.Single(e => e.ArtistID == id);
                //var listOfShowsPlayed = entity.ArtistShowData.Select(s => new ShowDetail
                // {
                //    ShowID = s.ShowID,
                //    ShowName = s.Show.ShowName,
                //    VenueID = s.Show.VenueID,
                //    Venue = s.Show.Venue,
                //    VenueName = s.Show.Venue.VenueName,
                //    VenueType = s.Show.Venue.VenueType,
                //    Location = s.Show.Venue.Location,
                //    DateOfShow = s.Show.DateOfShow
                //});

                var listOfShowsPlayed = GetShowDetailsArtistHasPlayed(id);
                foreach (var show in listOfShowsPlayed)
                {
                    var venueToAdd = venueService.GetVenueByID(show.VenueID);
                    venuesPlayed.Add(venueToAdd);
                }
                var artist = new ArtistDetail
                {
                    ArtistID     = entity.ArtistID,
                    ArtistName   = entity.ArtistName,
                    Location     = entity.Location,
                    ListOfShows  = listOfShowsPlayed,
                    VenuesPlayed = venuesPlayed
                };
                artist.ArtistCommunity = GetArtistCommunity(artist);
                return(artist);
            };
            // artist.ArtistCommunity = GetArtistCommunity(artist);
        }
        public async Task <IActionResult> Add([FromBody] Artist artist)
        {
            if (ModelState.IsValid)
            {
                try{
                    ArtistDetail newArtist = await _repo.AddAsync(artist);

                    return(CreatedAtRoute(
                               new { controller = "artist", action = nameof(Get), id = newArtist.Id }
                               , newArtist));
                }catch (RepositoryException e) {
                    return(BadRequest(new ApiErrorRep(e.Message)));
                }catch (Exception e) {
                    _logger.LogError("AddArtist", e, "Error adding artist");
                    return(StatusCode(500, new ApiErrorRep("Unknown error")));
                }
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
예제 #23
0
        private void UpdateItem(ThumbItem thumbItem)
        {
            try
            {
                bool?saved = false;
                if (thumbItem != null && thumbItem.EType == EntityType.Artist)
                {
                    Task.Factory.StartNew(() => Util.NotifyEvent("ArtistDetail:" + thumbItem.Name));
                    ArtistDetail artistdetail = new ArtistDetail(thumbItem.Name, thumbItem.EType);
                    saved = artistdetail.ShowDialog();
                }

                if (saved == true)
                {
                    RoutedEventArgs args = new RoutedEventArgs(SaveEventVp);
                    RaiseEvent(args);
                }
            }
            catch (Exception ex)
            {
                CatchException(ex);
            }
        }
예제 #24
0
        public List <ArtistListItem> GetArtistCommunity(ArtistDetail baseArtist) //int id
        {
            var artistCommunity = new List <ArtistListItem>();

            // get artistShowData where artistShowData.ShowID == show.ShowID in artist.ListOfShows

            foreach (var show in baseArtist.ListOfShows)
            {
                foreach (var artist in show.ListOfArtist)
                {
                    if (artist.ArtistID != baseArtist.ArtistID)
                    {
                        var artistListItem = new ArtistListItem()
                        {
                            ArtistID   = artist.ArtistID,
                            ArtistName = artist.ArtistName,
                            Location   = artist.Location
                        };
                        artistCommunity.Add(artistListItem);
                    }
                }
            }
            return(artistCommunity);
        }
예제 #25
0
        public async void GetArtist_ReturnsNullWhenNoArtistExists()
        {
            ArtistDetail result = await this.repo.GetAsync(929292);

            Assert.Null(result);
        }
예제 #26
0
 public ArtistDetailView(ArtistDetail artistDetail)
     : base(artistDetail)
 {
     LastCreatedView = this;
 }
예제 #27
0
        /// <summary>
        /// Get Artist DTO by Artist Id
        /// </summary>
        /// <param name="artistDetailId"></param>
        /// <returns></returns>
        public static ArtistDTO GetArtistDTOByArtistDetailID(int artistDetailId, List <ArtistDTO> artistDTOList)
        {
            var artistDetail = ArtistDetail.GetArtistDetailByID(artistDetailId);

            var artist = artistDTOList.FirstOrDefault(a => a.ArtistFullName == artistDetail.EnsembleName && a.work.WorkTitle == artistDetail.WorkTitle);

            if (artist == null)
            {
                artist = new ArtistDTO
                {
                    ArtistFullName    = artistDetail.EnsembleName ?? "",
                    artistInstruments = new List <InstrumentDTO>(),
                    ConductorCount    = 0,
                    SoloistCount      = 0,
                    EnsembleCount     = 0
                };

                var artistsWork = new WorkDTO
                {
                    WorkTitle        = artistDetail.WorkTitle ?? "",
                    ComposerFullName = artistDetail.ComposerFullName ?? ""
                };

                artist.work = artistsWork;

                String composerLink = String.Concat("&Composer=", artist.work.ComposerFullName, "&Work=", artist.work.WorkTitle);
                String linkBase     = "Search.aspx?searchType=Performance";
                artist.ConductorLink = String.Concat(linkBase, "&Conductor=", artist.ArtistFullName, composerLink);
                artist.SoloistLink   = String.Concat(linkBase, "&Soloist=", artist.ArtistFullName, composerLink);
                artist.OrchestraLink = String.Concat(linkBase, "&Orchestra=", artist.ArtistFullName, composerLink);

                int artistDetailWorkId = artistDetail.WorkId ?? 0;

                if (!Work.WorkShouldBeExcludedById(artistDetailWorkId) && artistDetailWorkId != 0)
                {
                    artistDTOList.Add(artist);
                }
            }

            if (artistDetail.EnsembleType == "Orchestra")
            {
                artist.EnsembleCount++;
                AddRoleToArtist(artistDetail, artist);
            }

            if (artistDetail.EnsembleType == "Conductor")
            {
                artist.ConductorCount++;
                AddRoleToArtist(artistDetail, artist);
            }

            if (artistDetail.EnsembleType == "Soloist")
            {
                artist.SoloistCount++;

                var instrumentID = artistDetail.InstrumentID;

                var instrument       = new InstrumentDTO(instrumentID);
                var artistInstrument = artist.artistInstruments.FirstOrDefault(i => i.Instrument1 == instrument.Instrument1);

                if (artistInstrument == null)
                {
                    artistInstrument = instrument;
                    artist.artistInstruments.Add(artistInstrument);
                }
            }

            return(artist);
        }
예제 #28
0
        private void UpdateItem(ThumbItem thumbItem)
        {
            try
            {
                if (thumbItem == null)
                {
                    return;
                }

                bool?saved = false;

                switch (thumbItem.EType)
                {
                case EntityType.Apps:
                    AppsUpdate objAppsDetails = new AppsUpdate();
                    objAppsDetails.ItemsId = thumbItem.Id;
                    saved = objAppsDetails.ShowDialog();
                    if (saved == true)
                    {
                        Apps apps = new AppServices().Get(thumbItem.Id) as Apps;
                        FileThumbItem(thumbItem, apps);
                    }
                    break;

                case EntityType.Artist:
                    Task.Factory.StartNew(() => Util.NotifyEvent("ArtistDetail:" + thumbItem.Name));
                    ArtistDetail artistDetails = new ArtistDetail(thumbItem.Name, thumbItem.EType);
                    saved = artistDetails.ShowDialog();
                    break;

                case EntityType.Books:
                    BookUpdate objBookDetails = new BookUpdate();
                    objBookDetails.ItemsId = thumbItem.Id;
                    saved = objBookDetails.ShowDialog();
                    if (saved == true)
                    {
                        Books books = new BookServices().Get(thumbItem.Id) as Books;
                        FileThumbItem(thumbItem, books);
                    }
                    break;

                case EntityType.Games:
                    GameUpdate objGameDetails = new GameUpdate();
                    objGameDetails.ItemsId = thumbItem.Id;
                    saved = objGameDetails.ShowDialog();
                    if (saved == true)
                    {
                        Gamez games = new GameServices().Get(thumbItem.Id) as Gamez;
                        FileThumbItem(thumbItem, games);
                    }
                    break;

                case EntityType.Movie:
                    MovieUpdate objMovieDetails = new MovieUpdate();
                    objMovieDetails.ItemsId = thumbItem.Id;
                    saved = objMovieDetails.ShowDialog();
                    if (saved == true)
                    {
                        Movie movie = new MovieServices().Get(thumbItem.Id) as Movie;
                        FileThumbItem(thumbItem, movie);
                    }
                    break;

                case EntityType.Music:
                    MusicUpdate objMusicDetails = new MusicUpdate();
                    objMusicDetails.ItemsId = thumbItem.Id;
                    saved = objMusicDetails.ShowDialog();
                    if (saved == true)
                    {
                        Music music = new MusicServices().Get(thumbItem.Id) as Music;
                        FileThumbItem(thumbItem, music);
                    }
                    break;

                case EntityType.Nds:
                    NdsUpdate objNdsDetails = new NdsUpdate();
                    objNdsDetails.ItemsId = thumbItem.Id;
                    saved = objNdsDetails.ShowDialog();
                    if (saved == true)
                    {
                        Nds nds = new NdsServices().Get(thumbItem.Id) as Nds;
                        FileThumbItem(thumbItem, nds);
                    }
                    break;

                case EntityType.Series:
                    Main main = Util.TryFindParent <Main>(this);
                    main.NewSeasonAdded = false;
                    SerieUpdate objSerieDetails = new SerieUpdate();
                    objSerieDetails.ItemsId = thumbItem.Id;
                    saved = objSerieDetails.ShowDialog();
                    main.NewSeasonAdded = objSerieDetails.NewSeasonAdded;

                    if (objSerieDetails.NewSeasonAdded == true)
                    {
                        saved = true;
                    }

                    if (saved == true)
                    {
                        SeriesSeason serie = new SerieServices().Get(thumbItem.Id) as SeriesSeason;
                        FileThumbItem(thumbItem, serie);
                    }
                    break;

                case EntityType.XXX:
                    XxxUpdate objXxxDetails = new XxxUpdate();
                    objXxxDetails.ItemsId = thumbItem.Id;
                    saved = objXxxDetails.ShowDialog();
                    if (saved == true)
                    {
                        XXX xxx = new XxxServices().Get(thumbItem.Id) as XXX;
                        FileThumbItem(thumbItem, xxx);
                    }
                    break;
                }

                _currentItem = thumbItem;

                if (saved == true)
                {
                    RoutedEventArgs args = new RoutedEventArgs(UpdateEvent);
                    RaiseEvent(args);
                    Cursor = null;
                    ShowVisibleItems(MainStack);
                }
            }
            catch (Exception ex)
            {
                CatchException(ex);
            }
        }