Design Prot Merge #1
@@ -5,14 +5,20 @@ namespace Musify.Application.Tracks.Responses
|
||||
public record TrackApplicationResponse(
|
||||
Guid Id,
|
||||
string Title,
|
||||
int Duration,
|
||||
int ListensCount,
|
||||
DateTime CreatedAt,
|
||||
DateTime UpdatedAt)
|
||||
{
|
||||
public static TrackApplicationResponse FromEntity(Track track)
|
||||
{
|
||||
var count = track.ListeningHistories.Count(x => x.TrackId == track.Id);
|
||||
|
||||
return new TrackApplicationResponse(
|
||||
track.Id,
|
||||
track.Title,
|
||||
track.Duration,
|
||||
count,
|
||||
track.CreatedAt,
|
||||
track.UpdatedAt);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using Musify.Domain.Abstractions;
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
@@ -21,6 +20,9 @@ namespace Musify.Domain.Entities
|
||||
[MaxLength(50)]
|
||||
public required string NormalizedTitle { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Duration { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public required string OriginalPictureName { get; set; }
|
||||
@@ -65,6 +67,8 @@ namespace Musify.Domain.Entities
|
||||
|
||||
public ICollection<PlayListHasTrack> PlayListTracks { get; set; } = new List<PlayListHasTrack>();
|
||||
|
||||
public ICollection<ListeningHistory> ListeningHistories { get; set; } = new List<ListeningHistory>();
|
||||
|
||||
[NotMapped]
|
||||
[MemberNotNullWhen(true, nameof(SmallPictureName)) ]
|
||||
[MemberNotNullWhen(true, nameof(MediumPictureName)) ]
|
||||
|
||||
@@ -37,5 +37,7 @@ namespace Musify.Domain.Entities
|
||||
public ICollection<UserHasTrack> UserTracks { get; set; } = new List<UserHasTrack>();
|
||||
|
||||
public ICollection<PlayList> PlayLists { get; set; } = new List<PlayList>();
|
||||
|
||||
public ICollection<ListeningHistory> ListeningHistories { get; set; } = new List<ListeningHistory>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user