Single synchronizer for calendar and mail.
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using Itenso.TimePeriod;
|
||||
using SQLite;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Core.Domain.Entities.Calendar
|
||||
{
|
||||
public class CalendarItem
|
||||
public class CalendarItem : ICalendarItem
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
@@ -20,5 +22,8 @@ namespace Wino.Core.Domain.Entities.Calendar
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
public Guid CalendarId { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public TimeRange Period => new TimeRange(StartTime.Date, EndTime.Date);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ namespace Wino.Core.Domain.Interfaces
|
||||
{
|
||||
public interface ICalendarItem
|
||||
{
|
||||
string Name { get; }
|
||||
string Title { get; }
|
||||
Guid Id { get; }
|
||||
DateTime StartTime { get; }
|
||||
DateTime EndTime { get; }
|
||||
DateTimeOffset StartTime { get; }
|
||||
DateTimeOffset EndTime { get; }
|
||||
TimeRange Period { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user