private Guid? BindProfile(Guid userId, string userName)
        {
            TourService service = new TourService(Ioc.GetInstance<ITourRepository>());
            ProfileService profileService = new ProfileService(Ioc.GetInstance<IProfileRepository>());

            var profile = profileService.GetProfileByUserId(userId);

            if (profile == null)
            {
                phNoProfileError.Visible = true;
                return null;
            }

            //Show Profile

            //SongService songService = new SongService(Ioc.GetInstance<ISongRepository>());
            //ShowService showService = new ShowService(Ioc.GetInstance<IShowRepository>());

            //if (profile.FavoriteStudioSong != null)
            //{
            //    var favoriteStudioSong = songService.GetSong(profile.FavoriteStudioSong.Value);
            //    lblFavoriteStudioSong.Text = string.Format("{0} - {1}", favoriteStudioSong.SongName, favoriteStudioSong.Album);
            //}

            //if (profile.FavoriteLiveShow != null)
            //{
            //    var favoriteLiveShow = showService.GetShow(profile.FavoriteLiveShow.Value);
            //    lblFavoriteLiveShow.Text = string.Format("{0} - {1}, {2}", favoriteLiveShow.ShowDate.Value.ToString("MM/dd/yyyy"), favoriteLiveShow.VenueName, favoriteLiveShow.State);
            //}

            //if (profile.FavoriteTour != null)
            //{
            //    var favoriteTour = service.GetTour(profile.FavoriteTour.Value);
            //    lblFavoriteTour.Text = string.Format("{0} {1}-{2}", favoriteTour.TourName, favoriteTour.StartDate.Value.ToString("MM/dd/yyyy"), favoriteTour.EndDate.Value.ToString("MM/dd/yyyy"));
            //}

            if (profile.FavoriteAlbum != null)
            {
                var albumService = new AlbumService(Ioc.GetInstance<IAlbumRepository>());
                var album = albumService.GetAlbum(profile.FavoriteAlbum.Value);
                lblFavoriteAlbum.Text = album.AlbumName;
            }

            lblName.Text = profile.Name;
            lblEmail.Text = profile.Email;
            lblFavorite3Year.Text = profile.Favorite3Year != null ? profile.Favorite3Year.Value.ToString() : string.Empty;
            lblFavoriteYear.Text = profile.FavoriteYear != null ? profile.FavoriteYear.Value.ToString() : string.Empty;
            lblFavoriteRun.Text = !string.IsNullOrEmpty(profile.FavoriteRun) ? profile.FavoriteRun.ToString() : string.Empty;
            lblFavoriteSeason.Text = !string.IsNullOrEmpty(profile.FavoriteSeason) ? profile.FavoriteSeason.ToString() : string.Empty;
            lblUserName.Text = userName;

            return userId;
        }
Esempio n. 2
0
        public void BindProfile()
        {
            var profile = profileService.GetProfileByUserId(userId);

            if (profile != null)
            {
                //Show Profile

                //SongService songService = new SongService(Ioc.GetInstance<ISongRepository>());
                //ShowService showService = new ShowService(Ioc.GetInstance<IShowRepository>());

                //if (profile.FavoriteStudioSong != null)
                //{
                //    var favoriteStudioSong = songService.GetSong(profile.FavoriteStudioSong.Value);
                //    lblFavoriteStudioSong.Text = string.Format("{0} - {1}", favoriteStudioSong.SongName, favoriteStudioSong.Album);
                //}

                //if (profile.FavoriteLiveShow != null)
                //{
                //    var favoriteLiveShow = showService.GetShow(profile.FavoriteLiveShow.Value);
                //    if (favoriteLiveShow != null)
                //    {
                //        lblFavoriteLiveShow.Text = string.Format("{0} - {1}, {2}", favoriteLiveShow.ShowDate.Value.ToString("MM/dd/yyyy"), favoriteLiveShow.VenueName, favoriteLiveShow.State);
                //    }
                //}

                //if (profile.FavoriteTour != null)
                //{
                //    var favoriteTour = service.GetTour(profile.FavoriteTour.Value);
                //    lblFavoriteTour.Text = string.Format("{0} {1}-{2}", favoriteTour.TourName, favoriteTour.StartDate.Value.ToString("MM/dd/yyyy"), favoriteTour.EndDate.Value.ToString("MM/dd/yyyy"));
                //}

                if (profile.FavoriteAlbum != null)
                {
                    var albumService = new AlbumService(Ioc.GetInstance<IAlbumRepository>());
                    var album = albumService.GetAlbum(profile.FavoriteAlbum.Value);
                    lblFavoriteAlbum.Text = album.AlbumName;
                }

                lblName.Text = profile.Name;
                lblEmail.Text = profile.Email;
                lblFavorite3Year.Text = profile.Favorite3Year != null ? profile.Favorite3Year.Value.ToString() : string.Empty;
                lblFavoriteYear.Text = profile.FavoriteYear != null ? profile.FavoriteYear.Value.ToString() : string.Empty;
                lblFavoriteRun.Text = !string.IsNullOrEmpty(profile.FavoriteRun) ? profile.FavoriteRun.ToString() : string.Empty;
                lblFavoriteSeason.Text = !string.IsNullOrEmpty(profile.FavoriteSeason) ? profile.FavoriteSeason.ToString() : string.Empty;
            }
            else
            {
                //Create profile
                var newProfile = new Profile
                {
                    CreatedDate = DateTime.Now,
                    ProfileId = Guid.NewGuid(),
                    UserId = userId
                };

                bool success;

                profileService.SaveCommit(newProfile, out success);
            }
        }