mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
918 B
22 lines
918 B
using ErsatzTV.Core.Domain; |
|
|
|
namespace ErsatzTV.Application.MediaItems |
|
{ |
|
internal static class Mapper |
|
{ |
|
internal static MediaItemViewModel ProjectToViewModel(MediaItem mediaItem) => |
|
new(mediaItem.Id, mediaItem.LibraryPathId); |
|
|
|
public static NamedMediaItemViewModel ProjectToViewModel(Show show) => |
|
new(show.Id, show.ShowMetadata.HeadOrNone().Map(sm => $"{sm?.Title} ({sm?.Year})").IfNone("???")); |
|
|
|
public static NamedMediaItemViewModel ProjectToViewModel(Season season) => |
|
new(season.Id, $"{ShowTitle(season)} ({SeasonDescription(season)})"); |
|
|
|
private static string ShowTitle(Season season) => |
|
season.Show.ShowMetadata.HeadOrNone().Map(sm => sm.Title).IfNone("???"); |
|
|
|
private static string SeasonDescription(Season season) => |
|
season.SeasonNumber == 0 ? "Specials" : $"Season {season.SeasonNumber}"; |
|
} |
|
}
|
|
|