76 lines
1.9 KiB
C#
76 lines
1.9 KiB
C#
using EgwCoreLib.Razor.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace GPW.CORE.Smart.Components.Compo
|
|
{
|
|
public partial class TestWeekCal
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public DateTime DtReq { get; set; } = DateTime.Today;
|
|
|
|
[Parameter]
|
|
public int NumDays { get; set; } = 1;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected List<DateTime> ListDate = new List<DateTime>();
|
|
|
|
[Parameter]
|
|
public List<CalendarEvent> eventList { get; set; } = new List<CalendarEvent>();
|
|
|
|
protected List<CalendarEvent> eventListPerWeek { get; set; } = new List<CalendarEvent>();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task ChangePeriod(int numStep)
|
|
{
|
|
ListDate = new List<DateTime>();
|
|
await Task.Delay(1);
|
|
DtReq = DtReq.AddDays(NumDays * numStep);
|
|
await reloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await reloadData();
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await reloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
protected Random rnd = new Random();
|
|
|
|
private async Task reloadData()
|
|
{
|
|
ListDate = new List<DateTime>();
|
|
int nWeek = DtReq.DayOfWeek - DayOfWeek.Monday;
|
|
if (NumDays < 5 || NumDays > 7)
|
|
{
|
|
nWeek = 0;
|
|
}
|
|
for (int i = 0; i < NumDays; i++)
|
|
{
|
|
ListDate.Add(DtReq.AddDays(i - nWeek));
|
|
}
|
|
eventListPerWeek = eventList.Where(x => ListDate.Contains(x.Inizio)).ToList();
|
|
|
|
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |