Skip to content

Commit

Permalink
Copy Models from VocaDbWeb to VocaDbWeb.Core
Browse files Browse the repository at this point in the history
  • Loading branch information
ycanardeau committed Dec 20, 2020
1 parent 590d575 commit 29bf06b
Show file tree
Hide file tree
Showing 174 changed files with 4,407 additions and 0 deletions.
24 changes: 24 additions & 0 deletions VocaDbWeb.Core/Models/Admin/CommentViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#nullable disable

using System;
using VocaDb.Model.DataContracts;

namespace VocaDb.Web.Models.Admin
{
[Obsolete]
public class CommentViewModel
{
public CommentViewModel(CommentContract comment, string targetName, string targetUrl)
{
Comment = comment;
TargetName = targetName;
TargetUrl = targetUrl;
}

public CommentContract Comment { get; set; }

public string TargetName { get; set; }

public string TargetUrl { get; set; }
}
}
27 changes: 27 additions & 0 deletions VocaDbWeb.Core/Models/Admin/PVsByAuthor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#nullable disable

using System.Collections.Generic;
using System.Linq;
using VocaDb.Model;
using VocaDb.Model.DataContracts.Songs;

namespace VocaDb.Web.Models.Admin
{
public class PVsByAuthor
{
public PVsByAuthor() { }

public PVsByAuthor(string author, IEnumerable<PVForSongContract> pvs)
{
ParamIs.NotNull(() => author);
ParamIs.NotNull(() => pvs);

Author = author;
PVs = pvs.ToArray();
}

public string Author { get; set; }

public PVForSongContract[] PVs { get; set; }
}
}
42 changes: 42 additions & 0 deletions VocaDbWeb.Core/Models/Admin/ViewAuditLogModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#nullable disable

using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using VocaDb.Model;
using VocaDb.Model.Service;
using VocaDb.Web.Helpers;

namespace VocaDb.Web.Models.Admin
{
[JsonObject(MemberSerialization.OptIn)]
public class ViewAuditLogModel
{
public ViewAuditLogModel()
{
GroupId = AuditLogUserGroupFilter.NoFilter;

UserGroups = new[] {
new KeyValuePair<AuditLogUserGroupFilter, string>(AuditLogUserGroupFilter.NoFilter, "No group filter")
}.Concat(Translate.UserGroups.Values.Select(u => new KeyValuePair<AuditLogUserGroupFilter, string>(EnumVal<AuditLogUserGroupFilter>.Parse(u.ToString()), Translate.UserGroups[u])))
.ToArray();
}

[JsonProperty]
public string ExcludeUsers { get; set; }

[JsonProperty]
public string Filter { get; set; }

[JsonProperty]
public AuditLogUserGroupFilter GroupId { get; set; }

[JsonProperty]
public bool OnlyNewUsers { get; set; }

public KeyValuePair<AuditLogUserGroupFilter, string>[] UserGroups { get; set; }

[JsonProperty]
public string UserName { get; set; }
}
}
19 changes: 19 additions & 0 deletions VocaDbWeb.Core/Models/Admin/ViewSysLog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#nullable disable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace VocaDb.Web.Models.Admin
{
public class ViewSysLog
{
public ViewSysLog(string logContents)
{
LogContents = logContents;
}

public string LogContents { get; set; }
}
}
37 changes: 37 additions & 0 deletions VocaDbWeb.Core/Models/Album/Index.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#nullable disable

using VocaDb.Model;
using VocaDb.Model.Domain.Albums;
using VocaDb.Model.Service;

namespace VocaDb.Web.Models.Album
{
/// <summary>
/// Parameter collection given to index action.
/// </summary>
public class IndexRouteParams
{
public IndexRouteParams() { }

public IndexRouteParams(IndexRouteParams source, int? page)
{
ParamIs.NotNull(() => source);

discType = (source.discType != DiscType.Unknown ? source.discType : null);
draftsOnly = (source.draftsOnly == true ? source.draftsOnly : null);
filter = source.filter;
matchMode = source.matchMode;
sort = source.sort;
view = source.view;
this.page = page;
}

public DiscType? discType { get; set; }
public bool? draftsOnly { get; set; }
public string filter { get; set; }
public NameMatchMode? matchMode { get; set; }
public int? page { get; set; }
public AlbumSortRule? sort { get; set; }
public EntryViewMode? view { get; set; }
}
}
53 changes: 53 additions & 0 deletions VocaDbWeb.Core/Models/Album/Versions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable disable

using System.Linq;
using VocaDb.Model.DataContracts.Albums;
using VocaDb.Model;
using VocaDb.Web.Models.Shared;
using VocaDb.Model.Domain.Albums;
using VocaDb.Web.Helpers;

namespace VocaDb.Web.Models.Album
{
public class Versions
{
public static ArchivedObjectVersion CreateForAlbum(ArchivedAlbumVersionContract album)
{
return new ArchivedObjectVersion(album, GetReasonName(album.Reason, album.Notes),
GetChangeString(album.ChangedFields), album.Reason != AlbumArchiveReason.PropertiesUpdated || album.ChangedFields != AlbumEditableFields.Nothing);
}

public static string GetChangeString(AlbumEditableFields fields)
{
if (fields == AlbumEditableFields.Nothing)
return string.Empty;

var fieldNames = EnumVal<AlbumEditableFields>.Values.Where(f =>
f != AlbumEditableFields.Nothing && fields.HasFlag(f)).Select(Translate.AlbumEditableField);

return string.Join(", ", fieldNames);
}

private static string GetReasonName(AlbumArchiveReason reason, string notes)
{
if (reason == AlbumArchiveReason.Unknown)
return notes;

return Translate.AlbumArchiveReason(reason);
}

public Versions() { }

public Versions(AlbumWithArchivedVersionsContract contract)
{
ParamIs.NotNull(() => contract);

Album = contract;
ArchivedVersions = contract.ArchivedVersions.Select(CreateForAlbum).ToArray();
}

public AlbumContract Album { get; set; }

public ArchivedObjectVersion[] ArchivedVersions { get; set; }
}
}
Loading

0 comments on commit 29bf06b

Please sign in to comment.