LANCommander.PlaynitePlugin/LANCommander/Data/Models/PlaySession.cs
Pat Hartl 95b8d50f22 Add ability to view/remove play sessions
Should allow users the ability to remove play sessions for a game that might be messing up overall stats for playtimes.
2024-06-25 01:24:28 -05:00

38 lines
1 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace LANCommander.Data.Models
{
[Table("PlaySessions")]
public class PlaySession : BaseModel
{
public Guid? GameId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("PlaySessions")]
public virtual Game? Game { get; set; }
public Guid UserId { get; set; }
[ForeignKey(nameof(UserId))]
[InverseProperty("PlaySessions")]
public virtual User? User { get; set; }
[Display(Name = "Start")]
public DateTime? Start { get; set; }
[Display(Name = "End")]
public DateTime? End { get; set; }
public virtual TimeSpan? Duration
{
get
{
if (!Start.HasValue) return null;
if (!End.HasValue) return null;
return End.Value.Subtract(Start.Value);
}
}
}
}