Encapsulation of grouped account selection events and collective events.
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Core.Domain.Collections
|
||||
{
|
||||
// TODO: Could be read-only collection in the MVVM package.
|
||||
public class CalendarEventCollection : ObservableRangeCollection<ICalendarItem>
|
||||
{
|
||||
public ObservableCollection<ICalendarItem> AllDayEvents { get; } = new ObservableCollection<ICalendarItem>();
|
||||
public new void Add(ICalendarItem calendarItem)
|
||||
{
|
||||
if (calendarItem is not ICalendarItemViewModel)
|
||||
throw new ArgumentException("CalendarItem must be of type ICalendarItemViewModel", nameof(calendarItem));
|
||||
|
||||
base.Add(calendarItem);
|
||||
|
||||
if (calendarItem.Period.Duration.TotalMinutes == 1440)
|
||||
@@ -18,6 +23,9 @@ namespace Wino.Core.Domain.Collections
|
||||
|
||||
public new void Remove(ICalendarItem calendarItem)
|
||||
{
|
||||
if (calendarItem is not ICalendarItemViewModel)
|
||||
throw new ArgumentException("CalendarItem must be of type ICalendarItemViewModel", nameof(calendarItem));
|
||||
|
||||
base.Remove(calendarItem);
|
||||
|
||||
if (calendarItem.Period.Duration.TotalMinutes == 1440)
|
||||
|
||||
@@ -24,5 +24,8 @@ namespace Wino.Core.Domain.Entities.Calendar
|
||||
|
||||
[Ignore]
|
||||
public TimeRange Period => new TimeRange(StartTime.Date, StartTime.Date.AddMinutes(DurationInMinutes));
|
||||
|
||||
[Ignore]
|
||||
public IAccountCalendar AssignedCalendar { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,6 @@ namespace Wino.Core.Domain.Interfaces
|
||||
Guid AccountId { get; set; }
|
||||
string RemoteCalendarId { get; set; }
|
||||
bool IsExtended { get; set; }
|
||||
Guid Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,6 @@ namespace Wino.Core.Domain.Interfaces
|
||||
DateTimeOffset StartTime { get; }
|
||||
int DurationInMinutes { get; }
|
||||
TimeRange Period { get; }
|
||||
IAccountCalendar AssignedCalendar { get; }
|
||||
}
|
||||
}
|
||||
|
||||
7
Wino.Core.Domain/Interfaces/ICalendarItemViewModel.cs
Normal file
7
Wino.Core.Domain/Interfaces/ICalendarItemViewModel.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Wino.Core.Domain.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Temporarily to enforce CalendarItemViewModel. Used in CalendarEventCollection.
|
||||
/// </summary>
|
||||
public interface ICalendarItemViewModel { }
|
||||
}
|
||||
@@ -14,6 +14,6 @@ namespace Wino.Core.Domain.Interfaces
|
||||
Task InsertAccountCalendarAsync(AccountCalendar accountCalendar);
|
||||
Task UpdateAccountCalendarAsync(AccountCalendar accountCalendar);
|
||||
Task CreateNewCalendarItemAsync(CalendarItem calendarItem, List<CalendarEventAttendee> attendees);
|
||||
Task<List<ICalendarItem>> GetCalendarEventsAsync(Guid calendarId, DateTime rangeStart, DateTime rangeEnd);
|
||||
Task<List<CalendarItem>> GetCalendarEventsAsync(IAccountCalendar calendar, DateTime rangeStart, DateTime rangeEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Wino.Core.Domain.Models.Calendar
|
||||
{
|
||||
public TimeRange Period { get; }
|
||||
public CalendarEventCollection EventsCollection { get; } = new CalendarEventCollection();
|
||||
|
||||
public CalendarDayModel(DateTime representingDate, CalendarRenderOptions calendarRenderOptions)
|
||||
{
|
||||
RepresentingDate = representingDate;
|
||||
|
||||
Reference in New Issue
Block a user