Fixing on calendar event added, and testing method.
This commit is contained in:
@@ -383,7 +383,7 @@ namespace Wino.Calendar.ViewModels
|
|||||||
base.OnCalendarEventAdded(calendarItem);
|
base.OnCalendarEventAdded(calendarItem);
|
||||||
|
|
||||||
// test
|
// test
|
||||||
var calendar = await _calendarService.GetAccountCalendarAsync(Guid.Parse("9ead7613-dacb-4163-8d33-2e32e65008a1"));
|
var calendar = await _calendarService.GetAccountCalendarAsync(Guid.Parse("40aa0bf0-9ea7-40d8-b426-9c78281723c9"));
|
||||||
|
|
||||||
calendarItem.AssignedCalendar = calendar;
|
calendarItem.AssignedCalendar = calendar;
|
||||||
// Check if event falls into the current date range.
|
// Check if event falls into the current date range.
|
||||||
@@ -393,19 +393,19 @@ namespace Wino.Calendar.ViewModels
|
|||||||
if (loadedDateRange == null) return;
|
if (loadedDateRange == null) return;
|
||||||
|
|
||||||
// Check whether this event falls into any of the loaded date ranges.
|
// Check whether this event falls into any of the loaded date ranges.
|
||||||
|
var allDaysForEvent = DayRanges.SelectMany(a => a.CalendarDays).Where(a => a.Period.OverlapsWith(calendarItem.Period));
|
||||||
|
|
||||||
//if (calendarItem.Period.Start >= loadedDateRange.StartDate && calendarItem.Period.Start.Date <= loadedDateRange.EndDate)
|
foreach (var calendarDay in allDaysForEvent)
|
||||||
//{
|
{
|
||||||
// // Find the day representation for the event.
|
var calendarItemViewModel = new CalendarItemViewModel(calendarItem);
|
||||||
// var dayModel = DayRanges.SelectMany(a => a.CalendarDays).FirstOrDefault(a => a.RepresentingDate.Date == calendarItem.Period.Start.Date);
|
|
||||||
// if (dayModel == null) return;
|
|
||||||
|
|
||||||
// var calendarItemViewModel = new CalendarItemViewModel(calendarItem);
|
await ExecuteUIThread(() =>
|
||||||
// await ExecuteUIThread(() =>
|
{
|
||||||
// {
|
calendarDay.EventsCollection.AddCalendarItem(calendarItemViewModel);
|
||||||
// dayModel.EventsCollection.AddCalendarItem(calendarItemViewModel);
|
});
|
||||||
// });
|
}
|
||||||
//}
|
|
||||||
|
FilterActiveCalendars(DayRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task InitializeCalendarEventsForDayRangeAsync(DayRangeRenderModel dayRangeRenderModel)
|
private async Task InitializeCalendarEventsForDayRangeAsync(DayRangeRenderModel dayRangeRenderModel)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Itenso.TimePeriod;
|
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
using Wino.Calendar.Args;
|
using Wino.Calendar.Args;
|
||||||
using Wino.Calendar.Views.Abstract;
|
using Wino.Calendar.Views.Abstract;
|
||||||
|
using Wino.Core.Domain.Entities.Calendar;
|
||||||
using Wino.Core.Domain.Enums;
|
using Wino.Core.Domain.Enums;
|
||||||
using Wino.Core.Domain.Models.Calendar;
|
using Wino.Core.Domain.Models.Calendar;
|
||||||
using Wino.Messaging.Client.Calendar;
|
using Wino.Messaging.Client.Calendar;
|
||||||
@@ -17,7 +17,7 @@ namespace Wino.Calendar.Views
|
|||||||
IRecipient<GoNextDateRequestedMessage>,
|
IRecipient<GoNextDateRequestedMessage>,
|
||||||
IRecipient<GoPreviousDateRequestedMessage>
|
IRecipient<GoPreviousDateRequestedMessage>
|
||||||
{
|
{
|
||||||
private DateTimeOffset? selectedDateTime;
|
private DateTime? selectedDateTime;
|
||||||
public CalendarPage()
|
public CalendarPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -53,11 +53,6 @@ namespace Wino.Calendar.Views
|
|||||||
{
|
{
|
||||||
// Selected date is in Local kind.
|
// Selected date is in Local kind.
|
||||||
selectedDateTime = e.ClickedDate;
|
selectedDateTime = e.ClickedDate;
|
||||||
var utc = DateTime.SpecifyKind(e.ClickedDate, DateTimeKind.Utc);
|
|
||||||
var unspecified = DateTime.SpecifyKind(e.ClickedDate, DateTimeKind.Unspecified);
|
|
||||||
|
|
||||||
var putc = new TimeRange(utc, utc.AddMinutes(30));
|
|
||||||
var punspecified = new TimeRange(unspecified, unspecified.AddMinutes(30));
|
|
||||||
|
|
||||||
// TODO: Popup is not positioned well on daily view.
|
// TODO: Popup is not positioned well on daily view.
|
||||||
TeachingTipPositionerGrid.Width = e.CellSize.Width;
|
TeachingTipPositionerGrid.Width = e.CellSize.Width;
|
||||||
@@ -66,19 +61,19 @@ namespace Wino.Calendar.Views
|
|||||||
Canvas.SetLeft(TeachingTipPositionerGrid, e.PositionerPoint.X);
|
Canvas.SetLeft(TeachingTipPositionerGrid, e.PositionerPoint.X);
|
||||||
Canvas.SetTop(TeachingTipPositionerGrid, e.PositionerPoint.Y);
|
Canvas.SetTop(TeachingTipPositionerGrid, e.PositionerPoint.Y);
|
||||||
|
|
||||||
//var testCalendarItem = new CalendarItem
|
var testCalendarItem = new CalendarItem
|
||||||
//{
|
{
|
||||||
// CalendarId = Guid.Parse("9ead7613-dacb-4163-8d33-2e32e65008a1"),
|
CalendarId = Guid.Parse("9ead7613-dacb-4163-8d33-2e32e65008a1"),
|
||||||
// StartTime = selectedDateTime.Value, // All events are saved in UTC.
|
StartDate = selectedDateTime.Value,
|
||||||
// DurationInMinutes = 30,
|
DurationInSeconds = TimeSpan.FromMinutes(30).TotalSeconds,
|
||||||
// CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
// Description = "Test Description",
|
Description = "Test Description",
|
||||||
// Location = "Poland",
|
Location = "Poland",
|
||||||
// Title = "Test event",
|
Title = "Test event",
|
||||||
// Id = Guid.NewGuid()
|
Id = Guid.NewGuid()
|
||||||
//};
|
};
|
||||||
|
|
||||||
//WeakReferenceMessenger.Default.Send(new CalendarEventAdded(testCalendarItem));
|
WeakReferenceMessenger.Default.Send(new CalendarEventAdded(testCalendarItem));
|
||||||
|
|
||||||
NewEventTip.IsOpen = true;
|
NewEventTip.IsOpen = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user