using Microsoft.Data.Sqlite;
using System;
using System.Diagnostics;
using System.Globalization;
namespace SQLiteTest {
internal class Movie {
public Movie() {
}
public Movie(ref SqliteDataReader query) {
ID = query.GetInt32(query.GetOrdinal("ID")); // Non null objects
Title = query.GetString(query.GetOrdinal("Title"));
Overview = query.GetString(query.GetOrdinal("Overview"));
int index = query.GetOrdinal("Tagline");
if (query.IsDBNull(index))
Debug.WriteLine("No Tagline found!");
else
Tagline = query.GetString(index);
index = query.GetOrdinal("BackdropPath");
if (query.IsDBNull(index))
Debug.WriteLine("No BackdropPath found!");
else
BackdropPath = query.GetString(index);
index = query.GetOrdinal("PosterPath");
if (query.IsDBNull(index))
Debug.WriteLine("No PosterPath found!");
else
PosterPath = query.GetString(index);
index = query.GetOrdinal("ImdbID");
if (query.IsDBNull(index))
Debug.WriteLine("No ImdbID found!");
else
ImdbID = query.GetString(index);
index = query.GetOrdinal("Adult");
if (query.IsDBNull(index))
Debug.WriteLine("No Adult found!");
else
Adult = query.GetBoolean(index);
index = query.GetOrdinal("Budget");
if (query.IsDBNull(index))
Debug.WriteLine("No Budget found!");
else
Budget = query.GetInt64(index);
index = query.GetOrdinal("Genres");
if (query.IsDBNull(index))
Debug.WriteLine("No Genres found!");
else
Genres = query.GetString(index); // TODO: This!
index = query.GetOrdinal("Popularity");
if (query.IsDBNull(index))
Debug.WriteLine("No Popularity found!");
else
Popularity = query.GetDouble(index);
index = query.GetOrdinal("ReleaseDate");
if (query.IsDBNull(index))
Debug.WriteLine("No ReleaseDate found!");
else {
string ReleaseDatestring = query.GetString(index);
}
index = query.GetOrdinal("Revenue");
if (query.IsDBNull(index))
Debug.WriteLine("No Revenue found!");
else
Revenue = query.GetInt64(index);
index = query.GetOrdinal("Runtime");
if (query.IsDBNull(index))
Debug.WriteLine("No Runtime found!");
else
Runtime = query.GetInt32(index);
index = query.GetOrdinal("Status");
if (query.IsDBNull(index))
Debug.WriteLine("No Status found!");
else
Status = query.GetString(index);
}
///
/// Movie ID on TMDB.
///
public int ID { get; set; }
///
/// Title of the movie.
///
public string Title { get; set; }
///
/// Tagline of the movie.
///
public string Tagline { get; set; }
///
/// Summary of the movie plot.
///
public string Overview { get; set; }
///
/// Path to a wallpaper of the movie.
///
public string BackdropPath { get; set; }
///
/// Path to a poster of the movie.
///
public string PosterPath { get; set; }
///
/// Movie ID on IMDB.
///
public string ImdbID { get; set; }
///
/// Whether or not the movie is age restricted.
/// Pattern: ^tt[0-9]{7}
///
public bool? Adult { get; set; }
///
/// Production budget of the movie.
///
public long? Budget { get; set; }
///
/// Comma Separated list of genres.
///
public string Genres { get; set; }
///
/// Current popularity. Has to be refreshed!
///
public double? Popularity { get; set; }
///
/// Release date of the movie.
///
public DateTime? ReleaseDate { get; set; }
///
/// Revenue of the movie.
///
public long? Revenue { get; set; }
///
/// Runtime of the movie in minutes.
///
public int? Runtime { get; set; }
///
/// Current movie status: Rumored, Planned, In Production, Post Production, Released, Canceled.
///
public string Status { get; set; }
public override bool Equals(object obj) {
return base.Equals(obj);
}
///
/// ID is unique to a movie object thus it can be used as a hash.
///
/// Movie ID as a unique id.
public override int GetHashCode() => ID;
///
/// String containing the movie ID as well as the title and the release year.
///
///
public override string ToString() => $"{ID}: {Title}{(ReleaseDate.HasValue ? $" ({ReleaseDate.Value.Year})" : "")}";
}
}