Single synchronizer for calendar and mail.

This commit is contained in:
Burak Kaan Köse
2024-11-30 12:47:24 +01:00
parent 2bc5be2105
commit 14e10c038c
25 changed files with 179 additions and 78 deletions

View File

@@ -6,7 +6,7 @@ namespace Wino.Core.Domain.Models.Calendar
{
public class CalendarItem : ICalendarItem
{
public string Name { get; set; }
public string Title { get; set; }
public CalendarItem(DateTime startTime, DateTime endTime)
{
StartTime = startTime;
@@ -14,8 +14,8 @@ namespace Wino.Core.Domain.Models.Calendar
Period = new TimeRange(startTime, endTime);
}
public DateTime StartTime { get; }
public DateTime EndTime { get; }
public DateTimeOffset StartTime { get; }
public DateTimeOffset EndTime { get; }
public Guid Id { get; } = Guid.NewGuid();

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Accounts;
using Wino.Core.Domain.Models.MailItem;
@@ -18,16 +19,32 @@ namespace Wino.Core.Domain.Models.Synchronization
[JsonIgnore]
public IEnumerable<IMailItem> DownloadedMessages { get; set; } = [];
/// <summary>
/// Gets the new downloaded events from synchronization.
/// Server will create notifications for these events.
/// It's ignored in serialization. Client should not react to this.
/// </summary>
[JsonIgnore]
public IEnumerable<ICalendarItem> DownloadedEvents { get; set; } = [];
public ProfileInformation ProfileInformation { get; set; }
public SynchronizationCompletedState CompletedState { get; set; }
public static SynchronizationResult Empty => new() { CompletedState = SynchronizationCompletedState.Success };
public static SynchronizationResult Completed(IEnumerable<IMailItem> downloadedMessages, ProfileInformation profileInformation = null)
// Mail synchronization
public static SynchronizationResult Completed(IEnumerable<IMailItem> downloadedMessages)
=> new()
{
DownloadedMessages = downloadedMessages,
CompletedState = SynchronizationCompletedState.Success
};
// Profile synchronization
public static SynchronizationResult Completed(ProfileInformation profileInformation)
=> new()
{
ProfileInformation = profileInformation,
CompletedState = SynchronizationCompletedState.Success
};