-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96a5142
commit cc6425c
Showing
24 changed files
with
928 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
VocaDbModel/DataContracts/SongLists/SongListForEditForApiContract.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
using Newtonsoft.Json.Converters; | ||
using VocaDb.Model.DataContracts.Songs; | ||
using VocaDb.Model.Domain; | ||
using VocaDb.Model.Domain.Images; | ||
using VocaDb.Model.Domain.Security; | ||
using VocaDb.Model.Domain.Songs; | ||
|
||
namespace VocaDb.Model.DataContracts.SongLists; | ||
|
||
[DataContract(Namespace = Schemas.VocaDb)] | ||
public sealed record SongListForEditForApiContract | ||
{ | ||
[DataMember] | ||
public bool Deleted { get; init; } | ||
|
||
[DataMember] | ||
public string Description { get; init; } | ||
|
||
[DataMember] | ||
public DateTime? EventDate { get; init; } | ||
|
||
[DataMember] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public SongListFeaturedCategory FeaturedCategory { get; init; } | ||
|
||
[DataMember] | ||
public int Id { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public EntryThumbForApiContract? MainPicture { get; init; } | ||
|
||
[DataMember] | ||
public string Name { get; init; } | ||
|
||
[DataMember] | ||
public SongInListEditContract[] SongLinks { get; set; } | ||
|
||
[DataMember] | ||
public EntryStatus Status { get; init; } | ||
|
||
[DataMember] | ||
public string UpdateNotes { get; init; } | ||
|
||
public SongListForEditForApiContract() | ||
{ | ||
Description = string.Empty; | ||
Name = string.Empty; | ||
SongLinks = Array.Empty<SongInListEditContract>(); | ||
UpdateNotes = string.Empty; | ||
} | ||
|
||
public SongListForEditForApiContract( | ||
SongList songList, | ||
IUserPermissionContext permissionContext, | ||
IAggregatedEntryImageUrlFactory imagePersister | ||
) | ||
{ | ||
Deleted = songList.Deleted; | ||
Description = songList.Description; | ||
EventDate = songList.EventDate; | ||
FeaturedCategory = songList.FeaturedCategory; | ||
Id = songList.Id; | ||
MainPicture = songList.Thumb is not null | ||
? new EntryThumbForApiContract(songList.Thumb, imagePersister) | ||
: null; | ||
Name = songList.Name; | ||
SongLinks = songList.SongLinks | ||
.OrderBy(s => s.Order) | ||
.Select(s => new SongInListEditContract(s, permissionContext.LanguagePreference)) | ||
.ToArray(); | ||
Status = songList.Status; | ||
UpdateNotes = string.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.