|
using System;
using System.Collections.ObjectModel;
using System.Linq;
using MediaAssistant.DAL.Constants;
using Newtonsoft.Json.Linq;
namespace MediaAssistant.DAL
{
public partial class Movie : IId
{
private int _index;
public int Index
{
get
{
return _index;
}
set
{
_index = value;
OnPropertyChanged("Index");
}
}
public bool IsLocal()
{
return FullPath != null;
}
public Movie()
{
Genres=new ObservableCollection<LibraryItem>();
Directors=new ObservableCollection<LibraryItem>();
Writers=new ObservableCollection<LibraryItem>();
Stars=new ObservableCollection<LibraryItem>();
}
private ObservableCollection<LibraryItem> _genres;
public ObservableCollection<LibraryItem> Genres
{
get { return _genres; }
set
{
_genres = value;
OnPropertyChanged("Genres");
}
}
private ObservableCollection<LibraryItem> _directors;
public ObservableCollection<LibraryItem> Directors
{
get { return _directors; }
set
{
_directors = value;
OnPropertyChanged("Directors");
}
}
private ObservableCollection<LibraryItem> _writers;
public ObservableCollection<LibraryItem> Writers
{
get { return _writers; }
set
{
_writers = value;
OnPropertyChanged("Writers");
}
}
private ObservableCollection<LibraryItem> _stars;
public ObservableCollection<LibraryItem> Stars
{
get { return _stars; }
set
{
_stars = value;
OnPropertyChanged("Stars");
}
}
private bool _isNew;
public bool IsNew
{
get
{
return _isNew;
}
set
{
_isNew = value;
OnPropertyChanged("IsNew");
}
}
private bool _isStarred;
public bool IsStarred
{
get { return _isStarred; }
set
{
_isStarred = value;
OnPropertyChanged("IsStarred");
}
}
private bool _watched;
public bool Watched
{
get { return _watched; }
set
{
_watched = value;
if (value)
IsInWishList = false;
OnPropertyChanged("Watched");
}
}
private bool _isInWishList;
public bool IsInWishList
{
get { return _isInWishList; }
set
{
_isInWishList = value;
OnPropertyChanged("IsInWishList");
}
}
public void UpdateLibraryInformation()
{
AddLibraryItems(Genres, LibraryItemType.MovieGenre);
AddLibraryItems(Writers, LibraryItemType.Writer);
AddLibraryItems(Directors, LibraryItemType.Director);
AddLibraryItems(Stars, LibraryItemType.Actor);
}
private void AddLibraryItems(ObservableCollection<LibraryItem> collection, string libraryItemType)
{
collection.Clear();
foreach (var libraryItem in LibraryItems.Where(l=>l.Type==libraryItemType))
{
collection.Add(libraryItem);
}
}
private bool _isVisible;
public bool IsVisible
{
get { return _isVisible; }
set
{
_isVisible = value;
OnPropertyChanged("IsVisible");
}
}
public override string ToString()
{
return Title;
}
public void UpdateMovie(JObject jsonObject)
{
Title = (string)jsonObject.SelectToken("Title");
int year;
if (Int32.TryParse((string)jsonObject.SelectToken("Year"), out year))
{
Year = year;
}
Rated = (string)jsonObject.SelectToken("Rated");
DateTime released;
if (DateTime.TryParse((string)jsonObject.SelectToken("Released"), out released))
{
Released = released;
}
Plot = (string)jsonObject.SelectToken("Plot");
Poster = (string)jsonObject.SelectToken("Poster");
Runtime = (string)jsonObject.SelectToken("Runtime");
double rating;
if (double.TryParse((string)jsonObject.SelectToken("Rating"), out rating))
{
Rating = rating;
}
int votes;
if (int.TryParse((string)jsonObject.SelectToken("Votes"), out votes))
{
Votes = votes;
}
IMDBId = (string)jsonObject.SelectToken("ID");
}
public bool CanShow(bool showDrivesMoviesOnly)
{
return showDrivesMoviesOnly == false || IsLocal();
}
public ProfileMovie GetProfileMovie(Profile selectedProfile)
{
return this == null ? null : ProfileMovies.FirstOrDefault(pm => pm.ProfileId == selectedProfile.Id);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.