-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndex.razor.cs
More file actions
102 lines (95 loc) · 4.01 KB
/
Index.razor.cs
File metadata and controls
102 lines (95 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using DevExpress.Blazor;
using DxBlazorApplication1.Models;
using DxBlazorApplication1.Models.UIModels;
using DxBlazorApplication1.Services.Interfaces;
using Microsoft.AspNetCore.Components;
using System.Diagnostics;
namespace DxBlazorApplication1.Components.Pages {
public partial class Index : ComponentBase {
#region Dependencies
[Inject]
private IAppointmentService<UniversityClass> AptService { get; set; }
[Inject]
private IResourceService<Lecturer> ResService { get; set; }
[Inject]
private ILabelService<LectureType> LblService { get; set; }
[Inject]
private IStatusService<LectureStatus> StsService { get; set; }
#endregion
#region Properties
private DxScheduler Scheduler { get; set; }
private DateTime StartDate { get; set; } = new DateTime(2025, 6, 1);
private DxSchedulerDataStorage Storage { get; set; } = new DxSchedulerDataStorage() {
AppointmentMappings = new DxSchedulerAppointmentMappings() {
Id = "Id",
Type = "EventType",
Start = "StartTime",
End = "EndTime",
Subject = "Subject",
AllDay = "AllDay",
Location = "Location",
Description = "Description",
LabelId = "Label",
StatusId = "Status",
RecurrenceInfo = "RecurrenceInfo",
ResourceId = "LecturerIds",
TimeZoneId = "TimeZoneId",
CustomFieldMappings = new List<DxSchedulerCustomFieldMapping> {
new DxSchedulerCustomFieldMapping { Name = "DegreeLevel", Mapping = "DegreeLevel" }
}
},
ResourceMappings = new DxSchedulerResourceMappings() {
Id = "Id",
Caption = "Name",
Color = "Color",
BackgroundCssClass = "BackgroundCssClass",
TextCssClass = "TextCssClass"
},
AppointmentLabelMappings = new DxSchedulerAppointmentLabelMappings() {
Id = "Id",
Caption = "Name",
Color = "Color",
TextCssClass = "TextCssClass",
BackgroundCssClass = "BackgroundCssClass"
},
AppointmentStatusMappings = new DxSchedulerAppointmentStatusMappings() {
Id = "Id",
Caption = "Name",
Color = "Color",
CssClass = "CssClass",
},
EnableMultipleResources = true,
};
#endregion
#region Life-cycle Methods
protected override async Task OnInitializedAsync() {
Storage.TimeZone = TimeZoneInfo.Utc;
Storage.AppointmentsSource = await AptService.GetAppointmentsAsync();
Storage.ResourcesSource = await ResService.GetResourcesAsync();
Storage.AppointmentLabelsSource = await LblService.GetLabelsAsync();
Storage.AppointmentStatusSource = await StsService.GetStatusesAsync();
}
#endregion
#region Event Handlers
void OnAppointmentFormShowing(SchedulerAppointmentFormEventArgs args) {
args.FormInfo = new CustomAppointmentFormInfo(args.Appointment, Storage, Scheduler);
}
private async Task OnAppointmentInserted(DxSchedulerAppointmentItem e) {
if (e.SourceObject is UniversityClass uc) {
await AptService.InsertAppointmentAsync(uc);
Storage.RefreshData();
}
}
private async Task OnAppointmentUpdated(DxSchedulerAppointmentItem e) {
if (e.SourceObject is UniversityClass uc) {
await AptService.UpdateAppointmentAsync(uc);
Storage.RefreshData();
}
}
private async Task OnAppointmentRemoved(DxSchedulerAppointmentItem e) {
await AptService.DeleteAppointmentAsync((int)e.Id);
Storage.RefreshData();
}
#endregion
}
}