roadie/Roadie.Api.Library/Data/UserTrack.cs

55 lines
1.3 KiB
C#
Raw Normal View History

2018-11-02 22:20:36 +00:00
using Roadie.Library.Identity;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Roadie.Library.Data
{
[Table("usertrack")]
2019-07-03 16:21:29 +00:00
public class UserTrack : EntityBase
2018-11-02 22:20:36 +00:00
{
2019-11-28 17:38:26 +00:00
[Column("isDisliked")]
public bool? IsDisliked { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[Column("isFavorite")]
public bool? IsFavorite { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[Column("lastPlayed")]
public DateTime? LastPlayed { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[Column("playedCount")]
public int? PlayedCount { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[Column("rating")]
public short Rating { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[ForeignKey(nameof(TrackId))]
[InverseProperty("UserTracks")]
public virtual Track Track { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[Column("trackId")]
[Required]
public int TrackId { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[ForeignKey(nameof(UserId))]
[InverseProperty("UserTracks")]
public virtual User User { get; set; }
2018-11-02 22:20:36 +00:00
2019-11-28 17:38:26 +00:00
[Column("userId")]
[Required]
public int UserId { get; set; }
2018-11-17 02:14:32 +00:00
public UserTrack()
2019-07-03 16:21:29 +00:00
{
}
2018-11-17 02:14:32 +00:00
public UserTrack(DateTime? now = null)
{
PlayedCount = 0;
Rating = 0;
IsDisliked = false;
IsFavorite = false;
LastPlayed = now ?? DateTime.UtcNow;
}
2018-11-02 22:20:36 +00:00
}
}