コード例 #1
0
        /// <summary>
        /// TO DO.
        /// </summary>
        /// <param name="name">TO DO.</param>
        /// <returns>TO DO.</returns>
        public IActionResult Index(string name)
        {
            try
            {
                Artiste artist = this.artisteRepository.Find(name);
                artist.Titres.OrderBy(t => t.Album);

                // Get all albums names by distinct names
                var albums = new Dictionary <string, string>();
                foreach (var titre in artist.Titres)
                {
                    if (!albums.ContainsKey(titre.Album))
                    {
                        albums.Add(titre.Album, titre.UrlJaquette); // Set album name as key and url image as value
                    }
                }

                ArtistViewModel model = new ArtistViewModel() // model for the view
                {
                    Artist = artist,
                    Albums = albums
                };

                return(this.View(model));
            }
            catch (Exception e)
            {
                return(this.NotFound());
            }
        }
コード例 #2
0
        public async Task <ActionResult> Show(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ArtistViewModel artist = new ArtistViewModel();

            artist.Artist = await db.Artists.FindAsync(id);

            if (artist.Artist == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Title = artist.Artist.FirstName;

            artist.Discography = await db.Discographies
                                 .Include(d => d.Album)
                                 .Include(d => d.Artist)
                                 .Include(d => d.Song)
                                 .Where(a => a.ArtistId == id)
                                 .ToListAsync();

            return(View(artist));
        }
        public async Task <ActionResult> Edit(int id, ArtistViewModel artist)
        {
            artist.Id = id;
            try
            {
                using (var client = new HttpClient())
                {
                    var token = await GetToken();//the method that generate the token

                    client.DefaultRequestHeaders.Add(HEADER_AUTHORIZATION, token);

                    var serializedContent = JsonConvert.SerializeObject(artist);
                    var stringContent     = new StringContent(serializedContent, Encoding.UTF8, JSON_MEDIA_TYPE);

                    HttpResponseMessage response = await client.PutAsync($"{artistsUri}/{id}", stringContent);

                    if (!response.IsSuccessStatusCode)
                    {
                        return(RedirectToAction(nameof(HomeController.Error), "Home"));
                    }

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch
            {
                return(RedirectToAction(nameof(HomeController.Error), "Home"));
            }
        }
コード例 #4
0
        public static ArtistViewModel GetArtistViewModel(string name)
        {
            var artist = new ArtistViewModel();

            using (var db = new SQLiteConnection(Tables.DBPath))
            {
                Artist _artist;
                try
                {
                    _artist = (db.Table <Artist>().Where(
                                   c => c.Name == name)).Single();
                }
                catch (Exception e)
                {
                    return(null);
                }
                artist.Name       = _artist.Name;
                artist.Duration   = _artist.Duration;
                artist.Image      = _artist.Image;
                artist.LastPlay   = _artist.LastPlayed;
                artist.Listens    = _artist.Listens;
                artist.SongCount  = _artist.SongCount;
                artist.AlbumCount = _artist.AlbumCount;
                artist.Meta       = _artist.Meta;
                artist.Rate       = _artist.Rate;
                //9
            }
            return(artist);
        }
コード例 #5
0
ファイル: ArtistFragment.cs プロジェクト: xjpeter/gMusic
 public override void OnViewCreated(Android.Views.View view, Android.OS.Bundle savedInstanceState)
 {
     base.OnViewCreated(view, savedInstanceState);
     if (ListAdapter == null)
     {
         ListAdapter = Model = new ArtistViewModel()
         {
             Context  = App.Context,
             ListView = ListView,
         };
         Model.CellFor += (Artist item) =>
         {
             return(new ArtistCell {
                 Artist = item
             });
         };
         Model.ItemSelected += (sender, e) =>
         {
             App.DoPushFragment(new ArtistDetailsFragment {
                 Artist = e.Data
             });
         };
     }
     else
     {
         Model.Context  = Activity;
         Model.ListView = ListView;
     }
     this.SetListShown(true);
 }
コード例 #6
0
        // GET: ArtistGenerated/Details/5
        public async Task <IActionResult> Details(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ArtistViewModel artist = await _culturalClient.GetAsync <ArtistViewModel>(id ?? 0, Route);

            artist.Location = await _culturalClient.GetAsync <LocationViewModel>(artist.LocationID, "locations");

            if (artist.PhotoName != null)
            {
                var fullPath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads/" + artist.PhotoName);
                if (!System.IO.File.Exists(fullPath))
                {
                    await _s3Client.ReadObjectDataAsync(artist.PhotoName);
                }
                artist.PhotoName = "/uploads/" + artist.PhotoName;
            }
            if (artist == null)
            {
                return(NotFound());
            }

            return(View(artist));
        }
コード例 #7
0
        public async Task <JsonResult> RecognizeAudioFile([FromBody] AudioFileViewModel audioFileViewModel)
        {
            try
            {
                bool            operationStatus = false;
                YoutubeLogic    YLogic          = new YoutubeLogic();
                ArtistViewModel artistViewModel = await YLogic.RecognizeAudioFile(audioFileViewModel);

                var result = "";
                if (artistViewModel == null || string.IsNullOrWhiteSpace(artistViewModel.artist))
                {
                    result = "Sorry, No artist match your video!!";
                }
                else
                {
                    result = await _viewRenderService.RenderToStringAsync("_ArtistResult", artistViewModel);

                    operationStatus = true;
                }
                return(Json(new
                {
                    status = operationStatus,
                    artistViewModel = artistViewModel,
                    partialViewData = Content(result)
                }));
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                return(Json(new { status = false, message = ex.Message }));
            }
        }
コード例 #8
0
        public async Task <IActionResult> Edit(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(NotFound());
            }

            var artist = await _userManager.FindByIdAsync(id);

            if (artist == null)
            {
                return(NotFound());
            }

            var usersRoles = await _userManager.GetRolesAsync(artist);

            var viewModel = new ArtistViewModel()
            {
                Id              = artist.Id,
                UserName        = artist.UserName,
                FirstName       = artist.FirstName,
                LastName        = artist.LastName,
                Email           = artist.Email,
                Bio             = artist.Bio,
                Facebook        = artist.Facebook,
                Instagram       = artist.Instagram,
                AvatarImageData = artist.AvatarImage,
                UserRoles       = usersRoles
            };

            return(View(viewModel));
        }
コード例 #9
0
        public async Task <IActionResult> Edit(long id, [FromForm] ArtistViewModel artist)
        {
            if (id != artist.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (artist.formFile != null)
                {
                    //delete old photo
                    var oldPhoto = artist.PhotoName;
                    await _s3Client.DeleteObjectNonVersionedBucketAsync(oldPhoto);

                    //var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
                    FileUploadHelper objFile  = new FileUploadHelper();
                    string           fileName = objFile.GetFileName(artist.formFile, true);
                    await _s3Client.UploadFileAsync(artist.formFile.OpenReadStream(), fileName);

                    artist.PhotoName = fileName;
                }
                if (artist.Alive)
                {
                    artist.DeathDate = null;
                }

                await _culturalClient.Update <ArtistViewModel>(artist, id, Route);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(artist));
        }
コード例 #10
0
 public ActionResult DeleteArtist(int?id)
 {
     _facade = new DataAccessLayerfacade();
     _model  = new ArtistViewModel();
     _model.GetSelectedArtist = _facade.GetArtistRep().GetArtistById(id);
     return(View(_model));
 }
コード例 #11
0
        public ArtistView()
        {
            InitializeComponent();

            _viewModel       = new ArtistViewModel();
            this.DataContext = _viewModel;
        }
コード例 #12
0
        public async void InsertUserAsync(ArtistViewModel userModel)
        {
            var user = _mapper.Map <Artist>(userModel);

            user.Id = Convert.ToString(ObjectId.GenerateNewId());
            await _context.Artists.InsertOneAsync(user);
        }
コード例 #13
0
        /// <summary>
        ///  Deletes a given artist from the database/site. Only Admin or Higher.
        /// </summary>
        /// <returns></returns>
        public ActionResult RemoveArtist(int artistID)
        {
            ActionResult oResponse = null;

            // Ensure user is Authenticated and is an Admin/SuperUser
            if (Session["Email"] != null && (int)Session["Role"] >= 4)
            {
                try
                {
                    // Removes artist by ID
                    artistDA.RemoveArtistByID(artistID);
                }
                catch (Exception ex)
                {
                    var error = new ArtistViewModel();
                    error.ErrorMessage = "Sorry we are unable to handle your request right now.";

                    using (StreamWriter fileWriter = new StreamWriter(@"C:\Course Content\ForgetTheMilk\RockersUnite\Logger\Log.txt"))
                    {
                        fileWriter.WriteLine("{0}-{1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.Message, true);
                    }
                }
                finally
                {
                    // Always return to ViewAll to confirm delete
                    oResponse = RedirectToAction("ViewAllArtists", "Artist");
                }
            }
            else
            {
                // User doesn't have privileges to delete artists, redirect to home
                oResponse = RedirectToAction("Index", "Home");
            }
            return(oResponse);
        }
コード例 #14
0
        private async Task <IList <ArtistViewModel> > GetUniqueArtistsAsync(IList <string> artists)
        {
            IList <ArtistViewModel> uniqueArtists = new List <ArtistViewModel>();

            await Task.Run(() =>
            {
                foreach (string artist in artists)
                {
                    var newArtist = new ArtistViewModel(artist);

                    if (!uniqueArtists.Contains(newArtist))
                    {
                        uniqueArtists.Add(newArtist);
                    }
                }

                var unknownArtist = new ArtistViewModel(ResourceUtils.GetString("Language_Unknown_Artist"));

                if (!uniqueArtists.Contains(unknownArtist))
                {
                    uniqueArtists.Add(unknownArtist);
                }
            });

            return(uniqueArtists);
        }
コード例 #15
0
        public ActionResult Edit(Guid id)
        {
            var artist    = db.Artist.Find(id);
            var viewModel = new ArtistViewModel().ConvertToArtistViewModel(artist, db);

            return(View(viewModel));
        }
コード例 #16
0
 public ObservableCollection <ArtistViewModel> GetArtists(string Artist)
 {
     tracks = new ObservableCollection <ArtistViewModel>();
     using (var db = new SQLiteConnection(Tables.DBPath))
     {
         TableQuery <Artist> query = db.Table <Artist>().OrderBy(c => c.Name).Where(c => c.Name == Artist);
         foreach (Artist track in query)
         {
             var etrack = new ArtistViewModel()
             {
                 Duration = track.Duration,
                 Name     = track.Name,
                 Image    = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                            @"\Safire\ArtistData\" + track.Name + ".jpg.thumb",
                 AlbumCount = track.AlbumCount,
                 SongCount  = track.SongCount,
                 Listens    = track.Listens,
                 Meta       = track.Meta,
                 Rate       = track.Rate,
                 LastPlay   = track.LastPlayed
             };
             tracks.Add(etrack);
             Results.Artists.Add(etrack);
         }
     }
     return(tracks);
 }
コード例 #17
0
        // GET: Artist
        public ActionResult Create()
        {
            //var viewModel = new ArtistViewModel(db);
            var viewModel = new ArtistViewModel();

            return(View());
        }
コード例 #18
0
        public async Task <IActionResult> UpdateArtist([FromRoute] long artistId, [FromBody] ArtistViewModel artistViewModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(BadRequest(this.ModelState));
            }

            if (artistId != artistViewModel.RecordId)
            {
                return(BadRequest());
            }

            var artist = Mapper.Map <Artist>(artistViewModel);

            this.context.Entry(artist).State = EntityState.Modified;

            try
            {
                await this.context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArtistExists(artistId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #19
0
        public async Task <object> Save(ArtistViewModel model)
        {
            string idString = new string(model.Name.Select(x => char.IsLetterOrDigit(x) ? x : '-').ToArray()).ToLower();
            var    check    = await _context.Artists
                              .Where(x => x.IdString == idString)
                              .Include(x => x.Albums)
                              .FirstOrDefaultAsync();

            if (check != null)
            {
                return new
                       {
                           Succeeded = false,
                           Errors    = new[] { new { Code = "BusyName" } }
                       }
            }
            ;
            Artist artist = new Artist()
            {
                Albums   = new List <Album>(),
                Name     = model.Name,
                IdString = idString,
                Id       = Guid.NewGuid()
            };

            await _context.Artists.AddAsync(artist);

            await _context.SaveChangesAsync();

            return(new
            {
                Succeeded = true,
            });
        }
コード例 #20
0
        public async Task <IActionResult> Put(int id, [FromBody] ArtistViewModel input, CancellationToken ct = default(CancellationToken))
        {
            try
            {
                if (input == null)
                {
                    return(BadRequest());
                }
                if (await _chinookSupervisor.GetArtistByIdAsync(id, ct) == null)
                {
                    return(NotFound());
                }
                var errors = JsonConvert.SerializeObject(ModelState.Values
                                                         .SelectMany(state => state.Errors)
                                                         .Select(error => error.ErrorMessage));
                Debug.WriteLine(errors);

                if (await _chinookSupervisor.UpdateArtistAsync(input, ct))
                {
                    return(Ok(input));
                }

                return(StatusCode(500));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
コード例 #21
0
        public IActionResult Artists(
            int?pageNumber, int?pageSize, string sortCol,
            string sortDir, string searchTerms)
        {
            return(ExecuteExceptionsHandledActionResult(() =>
            {
                OperationResult result = _artistEntityBusiness.ListItems(
                    pageNumber, pageSize, sortCol, sortDir, searchTerms);

                ViewBag.offset = result.ObjectsDictionary["offset"];
                ViewBag.pageIndex = result.ObjectsDictionary["pageIndex"];
                ViewBag.sizeOfPage = result.ObjectsDictionary["sizeOfPage"];
                ViewBag.offsetUpperBound = result.ObjectsDictionary["offsetUpperBound"];
                ViewBag.totalRecords = result.ObjectsDictionary["totalNumberOfRecords"];
                ViewBag.totalNumberOfPages = result.ObjectsDictionary["totalNumberOfPages"];
                ViewBag.searchTerms = result.ObjectsDictionary["searchTerms"];
                ViewBag.sortCol = result.ObjectsDictionary["sortCol"];
                ViewBag.sortDir = result.ObjectsDictionary["sortDir"];

                var model = new ArtistViewModel {
                    ArtistsList = result.ObjectsDictionary["list"] as IEnumerable <Artist>
                };

                return View(model);
            }));
        }
コード例 #22
0
ファイル: ArtistsController.cs プロジェクト: pavelbaglai/LAB6
        public async Task <IActionResult> Create([Bind("ID,StageName,FullName,ImagePath,ImageFile,DebutYear")] ArtistViewModel artistVm,
                                                 Image image)
        {
            string extension = Path.GetExtension(artistVm.ImageFile.FileName);
            string fileName  = artistVm.FullName + extension;
            string path      = Path.Combine(basePath, fileName);

            // find
            using (var fileStream = new FileStream(path, FileMode.Create))
            {
                await image.ImageFile.CopyToAsync(fileStream);
            }
            Artist artist = new Artist
            {
                Stagename = artistVm.StageName,
                Fullname  = artistVm.FullName,
                DebutYear = artistVm.DebutYear,
                ImagePath = BASE_PATH_SAVE + fileName
            };

            if (ModelState.IsValid)
            {
                _context.Add(artist);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(artistVm));
        }
コード例 #23
0
ファイル: ArtistController.cs プロジェクト: napstar/ArtWorkDB
        public JsonResult DoesThisArtistExist()
        {
            ArtistViewModel ViewModle   = new ArtistViewModel();
            var             artistcount = 0;

            try
            {
                var resolveRequest = HttpContext.Request;
                resolveRequest.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
                string jsonString = new System.IO.StreamReader(resolveRequest.InputStream).ReadToEnd();
                //deserialse
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string artistname = serializer.Deserialize <string>(jsonString);
                using (ArtistViewModel presentaion = new ArtistViewModel())
                {
                    artistcount = presentaion.GetData()
                                  .Where(x => x.ArtistName.ToUpper().Equals(artistname.ToUpper())).Count();
                    return(new JsonResult
                    {
                        Data = new { Data = artistcount, Success = true, ErrorMessage = "" },
                        ContentEncoding = System.Text.Encoding.UTF8,
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                return(new JsonResult
                {
                    Data = new { Data = artistcount, Success = false, ErrorMessage = ex.Message },
                    ContentEncoding = System.Text.Encoding.UTF8,
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
コード例 #24
0
        private void ArtistList_ItemClick(object sender, ItemClickEventArgs e)
        {
            ArtistList.PrepareConnectedAnimation(Consts.ArtistPageInAnimation, e.ClickedItem, "ArtistName");

            LibraryPage.Current.Navigate(typeof(ArtistPage), (e.ClickedItem as ArtistViewModel));
            _clickedArtist = e.ClickedItem as ArtistViewModel;
        }
コード例 #25
0
ファイル: EntityUtils.cs プロジェクト: zmni/dopamine-windows
        public static bool FilterArtists(ArtistViewModel artist, string filter)
        {
            // Trim is required here, otherwise the filter might flip on the space at the beginning (and probably at the end)
            string[] pieces = filter.Trim().Split(Convert.ToChar(" "));

            return(pieces.All((s) => artist.ArtistName.ToLower().Contains(s.ToLower())));
        }
コード例 #26
0
ファイル: ArtistController.cs プロジェクト: Hazrae/Billeterie
        public IActionResult Profil(int id)
        {
            ArtistViewModel avm = new ArtistViewModel();

            avm = ConsumeInstance.Get <ArtistViewModel>("Artist/", id);
            return(View(avm));
        }
コード例 #27
0
 public ActionResult CreatOrEdit(ArtistViewModel model)
 {
     if (ModelState.IsValid)
     {
         Artist entity = new Artist
         {
             Id          = model.Id,
             Name        = model.Name,
             Description = model.Description
         };
         if (model.Id != Guid.Empty)
         {
             var vm = new ArtistViewModel();
             _Service.Edit(entity);
             ViewBag.Message = "修改成功";
         }
         else
         {
             entity.Id = Guid.NewGuid();
             _Service.AddAndSave(entity);
             ViewBag.Message = "新增成功";
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
コード例 #28
0
        public async Task <IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                bool isUserExists = await _artistService.IsUserExistsAsync(model.Email);

                if (!isUserExists)
                {
                    if (model.Password == model.ConfirmPassword)
                    {
                        var newUser = new ArtistViewModel()
                        {
                            Email     = model.Email,
                            Password  = model.Password,
                            Name      = "New Artist",
                            Nickname  = "Painter",
                            Avatar    = "https://cdn3.iconfinder.com/data/icons/peoples-id-set/50/7-512.png",
                            Followers = new List <Followers>()
                        };
                        _artistService.InsertUserAsync(newUser);
                    }
                    return(RedirectToAction("Profile", "Account"));
                }
                else
                {
                    ModelState.AddModelError("", "Auth failed");
                }
            }
            return(View(model));
        }
コード例 #29
0
        public ActionResult Save(ArtistViewModel artist, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                // Read the image data into a byte array
                if (upload != null)
                {
                    var imageContent = new byte[upload.ContentLength];
                    upload.InputStream.Read(imageContent, 0, imageContent.Length);
                    artist.Picture = imageContent;
                }

                var artistView = Mapper.Map <ArtistViewModel, Artist>(artist);
                _unitOfWork.Artists.Add(artistView);
                _unitOfWork.Complete();
                //return Json(new { resultado = true, message = "Artist successfully registered!" });
                return(RedirectToAction("FullAccess"));
            }
            else
            {
                IEnumerable <ModelError> erros = ModelState.Values.SelectMany(item => item.Errors);

                //return Json(new { resultado = false, message = erros });
                return(View(artist));
            }
        }
コード例 #30
0
ファイル: EditSong.xaml.cs プロジェクト: yongjan/musicmink
        private void HandleContentDialogPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if ((deleteSong.IsChecked.HasValue && deleteSong.IsChecked.Value) &&
                (deleteSongConfirm.IsChecked.HasValue && deleteSongConfirm.IsChecked.Value))
            {
                LibraryViewModel.Current.DeleteSong(Song);
            }
            else
            {
                Song.Name = editSongName.Text;

                Song.ArtistName = editArtistName.Text;

                string newAlbumName      = editAlbumName.Text;
                string newAlbumAristName = editAlbumAritstName.Text;

                if (newAlbumName != Song.Album.Name || newAlbumAristName != Song.Album.ArtistName)
                {
                    ArtistViewModel albumArtistViewModel = LibraryViewModel.Current.LookupArtistByName(newAlbumAristName);
                    AlbumViewModel  newAlbumViewModel    = LibraryViewModel.Current.LookupAlbumByName(newAlbumName, albumArtistViewModel.ArtistId);

                    Song.UpdateAlbum(newAlbumViewModel);
                }

                uint newTrackNumber;

                if (uint.TryParse(editTrackNumber.Text, out newTrackNumber))
                {
                    Song.TrackNumber = newTrackNumber;
                }
            }
        }
コード例 #31
0
ファイル: ArtistsController.cs プロジェクト: slewis74/Jukebox
 public ArtistsController(
     IMusicProvider musicProvider,
     ArtistsViewModel.Factory artistsViewModelFactory,
     AlbumViewModel.Factory albumViewModelFactory,
     ArtistViewModel.Factory artistViewModelFactory)
 {
     _musicProvider = musicProvider;
     _artistsViewModelFactory = artistsViewModelFactory;
     _albumViewModelFactory = albumViewModelFactory;
     _artistViewModelFactory = artistViewModelFactory;
 }
コード例 #32
0
        public async void LoadAsync(string artistId)
        {
            this.ArtistView = null;
            this.RoleViews.Clear();

            var dataCenter = this.GetManagers();
            var artist = await dataCenter.ArtistManager.FindAsync(artistId);
            if (artist == null) return;
            this.ArtistView = new ArtistViewModel(artist);

            var roles = (await dataCenter.VideoRoleManager.QueryByActorIdAsync(artistId))
                .Select(z => new VideoRoleReadonlyViewModel(z.Item2))
                .ToArray();
            this.RoleViews.AddRange(roles);
        }
コード例 #33
0
        public void HandleSearchResult(IMetadata result)
        {
            try
            {
                if (result == null)
                    return;

                if (result is IArtist)
                {
                    var artistKey = result.Location.ToString();
                    if (!artistResults.ContainsKey(artistKey))
                    {
                        var artistViewModel = new ArtistViewModel(mediaItemController, result as IArtist); //result.Location, result.Name, result.Summary, result.FromDate, result.ToDate, result.Thumbnail, result.ThumbnailData);
                        var resultViewModel = new SearchResultViewModel(artistViewModel);
                        artistResults.Add(artistKey, resultViewModel);
                        AddResult(resultViewModel);
                    }
                }
                else if (result is IAlbum)
                {
                    var albumViewModel = new AlbumViewModel(mediaItemController, result as IAlbum); //result.Location, result.Name, result.Summary, result.Creator, result.CreatorName, result.FromDate, result.Thumbnail, result.ThumbnailData);

                    var artistKey = result.Creator.ToString();
                    var albumKey = result.Location.ToString();
                    if (!artistResults.ContainsKey(artistKey))
                    {
                        if (!albumResults.ContainsKey(albumKey))
                        {
                            var resultViewModel = new SearchResultViewModel(albumViewModel);
                            AddResult(resultViewModel);
                            albumResults.Add(albumKey, resultViewModel);
                        }
                    }
                    else
                    {
                        if (!albumResults.ContainsKey(albumKey))
                        {
                            var existing = artistResults[artistKey].Albums.Where(x => x.Id.ToString() == albumViewModel.Id.ToString()).FirstOrDefault();
                            if (existing == null)
                            {
                                AddAlbum(artistResults[artistKey], albumViewModel);
                            }
                        }
                    }
                }
                else if (result is ITrack)
                {
                    var trackViewModel = new TrackViewModel(mediaItemController, result as ITrack); //result.Location, result.Name, result.Summary, result.Number, result.Duration, result.FromDate, result.Creator, result.CreatorName, result.Catalog, result.CatalogName, result.Target, result.TargetType, result.Thumbnail, result.ThumbnailData);

                    var albumKey = result.Catalog.ToString();
                    var trackKey = result.Location.ToString();
                    if (!albumResults.ContainsKey(albumKey))
                    {
                        if (!trackResults.ContainsKey(trackKey))
                        {
                            var resultViewModel = new SearchResultViewModel(trackViewModel);
                            trackResults.Add(trackKey, resultViewModel);
                            AddResult(resultViewModel);
                        }
                    }
                    else
                    {
                        if (!trackResults.ContainsKey(trackKey))
                        {
                            //var existing = albumResults[albumKey].Tracks.Where(x => x.Album.ToString() == trackViewModel.Album.ToString()).FirstOrDefault();
                            //if (existing == null)
                            //{
                            AddTrack(albumResults[albumKey], trackViewModel);
                            //}
                        }
                    }
                }
                else if (result is IClip)
                {
                    var clipViewModel = new ClipViewModel(mediaItemController, result as IClip); //result.Location, result.Name, result.Summary, result.Number, result.Duration, result.Height, result.Width, result.FromDate, result.Creator, result.CreatorName, result.Catalog, result.CatalogName, result.Target, result.TargetType, result.Thumbnail, result.ThumbnailData);

                    var albumKey = result.Catalog.ToString();
                    var clipKey = result.Location.ToString();
                    if (!albumResults.ContainsKey(albumKey))
                    {
                        if (!clipResults.ContainsKey(clipKey))
                        {
                            var resultViewModel = new SearchResultViewModel(clipViewModel);
                            clipResults.Add(clipKey, resultViewModel);
                            AddResult(resultViewModel);
                        }
                    }
                    else
                    {
                        if (!clipResults.ContainsKey(clipKey))
                        {
                            //var existing = albumResults[albumKey].Tracks.Where(x => x.Album.ToString() == trackViewModel.Album.ToString()).FirstOrDefault();
                            //if (existing == null)
                            //{
                            AddClip(albumResults[albumKey], clipViewModel);
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("  HandleSearchResults", ex);
            }
        }
コード例 #34
0
		private void ResetArtist() {
			CurrArtist = new ArtistViewModel(new Artist() {
				CategoryId = Categories.FirstOrDefault().Id,
				CountryId = Categories.FirstOrDefault().Id
			});
		}
コード例 #35
0
        internal void RemoveArtistIfNeeded(ArtistViewModel artistViewModel)
        {
            if (artistViewModel.Songs.Count == 0 && artistViewModel.Albums.Count == 0)
            {
                ArtistCollection.Remove(artistViewModel, artistViewModel.SortName);
                ArtistLookupMap.Remove(artistViewModel.ArtistId);

                artistViewModel.IsBeingDeleted = true;

                LibraryModel.Current.DeleteArtist(artistViewModel.ArtistId);
            }
        }
コード例 #36
0
        private ArtistViewModel LookupArtist(ArtistModel artist)
        {
            if (artist == null) return null;

            if (ArtistLookupMap.ContainsKey(artist.ArtistId))
            {
                return ArtistLookupMap[artist.ArtistId];
            }
            else
            {
                ArtistViewModel newArtistViewModel = new ArtistViewModel(artist);

                ArtistLookupMap.Add(newArtistViewModel.ArtistId, newArtistViewModel);
                ArtistCollection.Add(newArtistViewModel, newArtistViewModel.SortName);

                return newArtistViewModel;
            }
        }