feat: add feedback backend foundation
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using Socialize.Api.Modules.Feedback.Data;
|
||||
|
||||
namespace Socialize.Api.Modules.Feedback.Contracts;
|
||||
|
||||
public record FeedbackContextDto(
|
||||
Guid? WorkspaceId,
|
||||
string? WorkspaceName,
|
||||
Guid? ClientId,
|
||||
string? ClientName,
|
||||
Guid? ProjectId,
|
||||
string? ProjectName,
|
||||
Guid? ContentItemId,
|
||||
string? ContentItemTitle);
|
||||
|
||||
public record FeedbackMetadataDto(
|
||||
string SubmittedPath,
|
||||
string? BrowserUserAgent,
|
||||
int? ViewportWidth,
|
||||
int? ViewportHeight,
|
||||
string? AppVersion);
|
||||
|
||||
public record FeedbackReportDto(
|
||||
Guid Id,
|
||||
string Type,
|
||||
string Status,
|
||||
string Description,
|
||||
Guid ReporterUserId,
|
||||
string ReporterDisplayName,
|
||||
string ReporterEmail,
|
||||
FeedbackMetadataDto Metadata,
|
||||
FeedbackContextDto Context,
|
||||
IReadOnlyCollection<string> Tags,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset LastActivityAt,
|
||||
DateTimeOffset? CancelledAt,
|
||||
string? CancellationReason);
|
||||
|
||||
public static class FeedbackDtoMapper
|
||||
{
|
||||
public static FeedbackReportDto ToDto(this FeedbackReport report)
|
||||
{
|
||||
return new FeedbackReportDto(
|
||||
report.Id,
|
||||
ToDisplayString(report.Type),
|
||||
ToDisplayString(report.Status),
|
||||
report.Description,
|
||||
report.ReporterUserId,
|
||||
report.ReporterDisplayName,
|
||||
report.ReporterEmail,
|
||||
new FeedbackMetadataDto(
|
||||
report.SubmittedPath,
|
||||
report.BrowserUserAgent,
|
||||
report.ViewportWidth,
|
||||
report.ViewportHeight,
|
||||
report.AppVersion),
|
||||
new FeedbackContextDto(
|
||||
report.WorkspaceId,
|
||||
report.WorkspaceName,
|
||||
report.ClientId,
|
||||
report.ClientName,
|
||||
report.ProjectId,
|
||||
report.ProjectName,
|
||||
report.ContentItemId,
|
||||
report.ContentItemTitle),
|
||||
report.Tags.OrderBy(tag => tag.Name).Select(tag => tag.Name).ToArray(),
|
||||
report.CreatedAt,
|
||||
report.LastActivityAt,
|
||||
report.CancelledAt,
|
||||
report.CancellationReason);
|
||||
}
|
||||
|
||||
private static string ToDisplayString(FeedbackType type)
|
||||
{
|
||||
return type.ToString();
|
||||
}
|
||||
|
||||
private static string ToDisplayString(FeedbackStatus status)
|
||||
{
|
||||
return status == FeedbackStatus.WontDo ? "Won't Do" : status.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user