Files
Wino-Mail/Wino.Core.Domain/Models/Synchronization/MailSynchronizationResult.cs
T

53 lines
1.8 KiB
C#
Raw Normal View History

2025-11-14 12:12:13 +01:00
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
2025-10-03 15:46:38 +02:00
using Wino.Core.Domain.Entities.Mail;
2024-04-18 01:44:37 +02:00
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.Accounts;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
namespace Wino.Core.Domain.Models.Synchronization;
public class MailSynchronizationResult
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
public MailSynchronizationResult() { }
/// <summary>
/// Gets the new downloaded messages from synchronization.
/// Server will create notifications for these messages.
/// It's ignored in serialization. Client should not react to this.
/// </summary>
[JsonIgnore]
2025-10-03 15:46:38 +02:00
public IEnumerable<MailCopy> DownloadedMessages { get; set; } = [];
2025-02-16 11:54:23 +01:00
public ProfileInformation ProfileInformation { get; set; }
public SynchronizationCompletedState CompletedState { get; set; }
2025-11-14 12:12:13 +01:00
public Exception Exception { get; set; }
2025-02-16 11:54:23 +01:00
public static MailSynchronizationResult Empty => new() { CompletedState = SynchronizationCompletedState.Success };
// Mail synchronization
2025-10-03 15:46:38 +02:00
public static MailSynchronizationResult Completed(IEnumerable<MailCopy> downloadedMessages)
2025-02-16 11:54:23 +01:00
=> new()
{
DownloadedMessages = downloadedMessages,
CompletedState = SynchronizationCompletedState.Success
};
// Profile synchronization
public static MailSynchronizationResult Completed(ProfileInformation profileInformation)
=> new()
{
ProfileInformation = profileInformation,
CompletedState = SynchronizationCompletedState.Success
};
public static MailSynchronizationResult Canceled => new() { CompletedState = SynchronizationCompletedState.Canceled };
2025-11-14 12:12:13 +01:00
public static MailSynchronizationResult Failed(Exception exception) => new()
{
CompletedState = SynchronizationCompletedState.Failed,
Exception = exception
};
2024-04-18 01:44:37 +02:00
}