166 lines
5.6 KiB
C#
166 lines
5.6 KiB
C#
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);
|
|
}
|
|
/// <summary>
|
|
/// Movie ID on TMDB.
|
|
/// </summary>
|
|
public int ID { get; set; }
|
|
/// <summary>
|
|
/// Title of the movie.
|
|
/// </summary>
|
|
public string Title { get; set; }
|
|
/// <summary>
|
|
/// Tagline of the movie.
|
|
/// </summary>
|
|
public string Tagline { get; set; }
|
|
/// <summary>
|
|
/// Summary of the movie plot.
|
|
/// </summary>
|
|
public string Overview { get; set; }
|
|
/// <summary>
|
|
/// Path to a wallpaper of the movie.
|
|
/// </summary>
|
|
public string BackdropPath { get; set; }
|
|
/// <summary>
|
|
/// Path to a poster of the movie.
|
|
/// </summary>
|
|
public string PosterPath { get; set; }
|
|
/// <summary>
|
|
/// Movie ID on IMDB.
|
|
/// </summary>
|
|
public string ImdbID { get; set; }
|
|
/// <summary>
|
|
/// Whether or not the movie is age restricted.
|
|
/// Pattern: ^tt[0-9]{7}
|
|
/// </summary>
|
|
public bool? Adult { get; set; }
|
|
/// <summary>
|
|
/// Production budget of the movie.
|
|
/// </summary>
|
|
public long? Budget { get; set; }
|
|
/// <summary>
|
|
/// Comma Separated list of genres.
|
|
/// </summary>
|
|
public string Genres { get; set; }
|
|
/// <summary>
|
|
/// Current popularity. Has to be refreshed!
|
|
/// </summary>
|
|
public double? Popularity { get; set; }
|
|
/// <summary>
|
|
/// Release date of the movie.
|
|
/// </summary>
|
|
public DateTime? ReleaseDate { get; set; }
|
|
/// <summary>
|
|
/// Revenue of the movie.
|
|
/// </summary>
|
|
public long? Revenue { get; set; }
|
|
/// <summary>
|
|
/// Runtime of the movie in minutes.
|
|
/// </summary>
|
|
public int? Runtime { get; set; }
|
|
/// <summary>
|
|
/// Current movie status: Rumored, Planned, In Production, Post Production, Released, Canceled.
|
|
/// </summary>
|
|
public string Status { get; set; }
|
|
|
|
public override bool Equals(object obj) {
|
|
return base.Equals(obj);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ID is unique to a movie object thus it can be used as a hash.
|
|
/// </summary>
|
|
/// <returns>Movie ID as a unique id.</returns>
|
|
public override int GetHashCode() => ID;
|
|
/// <summary>
|
|
/// String containing the movie ID as well as the title and the release year.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override string ToString() => $"{ID}: {Title}{(ReleaseDate.HasValue ? $" ({ReleaseDate.Value.Year})" : "")}";
|
|
}
|
|
} |