using System.ComponentModel.DataAnnotations.Schema;
namespace OliverBooth.Data.Web;
///
/// Represents a tutorial article.
///
internal sealed class TutorialArticle : IEquatable, ITutorialArticle
{
///
public string Body { get; private set; } = string.Empty;
///
public bool EnableComments { get; internal set; }
///
public string? Excerpt { get; private set; }
///
public int Folder { get; private set; }
///
[NotMapped]
public bool HasOtherParts => NextPart is not null || PreviousPart is not null;
///
public int Id { get; private set; }
///
public int? NextPart { get; private set; }
///
public Uri? PreviewImageUrl { get; private set; }
///
public int? PreviousPart { get; private set; }
///
public DateTimeOffset Published { get; private set; }
///
public string Slug { get; private set; } = string.Empty;
///
public string Title { get; private set; } = string.Empty;
///
public DateTimeOffset? Updated { get; private set; }
///
public Visibility Visibility { get; private set; }
///
/// Returns a value indicating whether two instances of are equal.
///
/// The first instance of to compare.
/// The second instance of to compare.
///
/// if and are equal; otherwise,
/// .
///
public static bool operator ==(TutorialArticle? left, TutorialArticle? right) => Equals(left, right);
///
/// Returns a value indicating whether two instances of are not equal.
///
/// The first instance of to compare.
/// The second instance of to compare.
///
/// if and are not equal; otherwise,
/// .
///
public static bool operator !=(TutorialArticle? left, TutorialArticle? right) => !(left == right);
///
/// Returns a value indicating whether this instance of is equal to another
/// instance.
///
/// An instance to compare with this instance.
///
/// if is equal to this instance; otherwise,
/// .
///
public bool Equals(TutorialArticle? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Id.Equals(other.Id);
}
///
/// Returns a value indicating whether this instance is equal to a specified object.
///
/// An object to compare with this instance.
///
/// if is an instance of and
/// equals the value of this instance; otherwise, .
///
public override bool Equals(object? obj)
{
return ReferenceEquals(this, obj) || obj is TutorialArticle other && Equals(other);
}
///
/// Gets the hash code for this instance.
///
/// The hash code.
public override int GetHashCode()
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
return Id;
}
}