Skip to content

Commit 90b8c53

Browse files
Update to 25.1.3+
1 parent ceeac84 commit 90b8c53

26 files changed

+1421
-26
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using ASP_NET_Core.Models;
7+
8+
namespace ASP_NET_Core.Controllers
9+
{
10+
public class SchedulerController : Controller
11+
{
12+
public IActionResult Index()
13+
{
14+
return View(AppointmentData.Appointments);
15+
}
16+
17+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
18+
public IActionResult Error() {
19+
return View();
20+
}
21+
}
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Newtonsoft.Json;
7+
8+
namespace ASP_NET_Core.Models {
9+
public class Appoinment {
10+
public int Id { get; set; }
11+
public string Text { get; set; }
12+
public DateTime StartDate { get; set; }
13+
public DateTime EndDate { get; set; }
14+
}
15+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ASP_NET_Core.Models
8+
{
9+
static class AppointmentData
10+
{
11+
public static List<Appoinment> Appointments = new List<Appoinment>()
12+
{
13+
new Appoinment
14+
{
15+
Id = 1,
16+
Text = "Website Re-Design Plan",
17+
StartDate = new DateTime(2021, 5, 5, 9, 30, 0),
18+
EndDate = new DateTime(2021, 5, 5, 11, 30, 0)
19+
},
20+
new Appoinment
21+
{
22+
Id = 2,
23+
Text = "Install New Router in Dev Room",
24+
StartDate = new DateTime(2021, 5, 6, 13, 0, 0),
25+
EndDate = new DateTime(2021, 5, 6, 14, 0, 0)
26+
},
27+
new Appoinment
28+
{
29+
Id = 3,
30+
Text = "Approve Personal Computer Upgrade Plan",
31+
StartDate = new DateTime(2021, 5, 3, 10, 0, 0),
32+
EndDate = new DateTime(2021, 5, 3, 11, 0, 0)
33+
},
34+
new Appoinment
35+
{
36+
Id = 4,
37+
Text = "Final Budget Review",
38+
StartDate = new DateTime(2021, 5, 5, 13, 30, 0),
39+
EndDate = new DateTime(2021, 5, 5, 15, 0, 0)
40+
},
41+
new Appoinment
42+
{
43+
Id = 5,
44+
Text = "New Brochures",
45+
StartDate = new DateTime(2021, 5, 6, 15, 0, 0),
46+
EndDate = new DateTime(2021, 5, 6, 16, 15, 0, 0)
47+
},
48+
new Appoinment
49+
{
50+
Id = 6,
51+
Text = "Install New Database",
52+
StartDate = new DateTime(2021, 5, 3, 9, 45, 0),
53+
EndDate = new DateTime(2021, 5, 3, 12, 0, 0)
54+
},
55+
new Appoinment
56+
{
57+
Id = 7,
58+
Text = "Approve New Online Marketing Strategy",
59+
StartDate = new DateTime(2021, 5, 3, 14, 30, 0),
60+
EndDate = new DateTime(2021, 5, 3, 16, 30, 0)
61+
},
62+
new Appoinment
63+
{
64+
Id = 8,
65+
Text = "Upgrade Personal Computers",
66+
StartDate = new DateTime(2021, 5, 6, 15, 30, 0),
67+
EndDate = new DateTime(2021, 5, 6, 16, 45, 0)
68+
},
69+
new Appoinment
70+
{
71+
Id = 9,
72+
Text = "Prepare 2021 Marketing Plan",
73+
StartDate = new DateTime(2021, 5, 3, 13, 0, 0),
74+
EndDate = new DateTime(2021, 5, 3, 15, 0, 0)
75+
},
76+
new Appoinment
77+
{
78+
Id = 10,
79+
Text = "Brochure Design Review",
80+
StartDate = new DateTime(2021, 5, 1, 15, 30, 0),
81+
EndDate = new DateTime(2021, 5, 2, 0, 0, 0)
82+
},
83+
new Appoinment
84+
{
85+
Id = 11,
86+
Text = "Create Icons for Website",
87+
StartDate = new DateTime(2021, 5, 5, 10, 0, 0),
88+
EndDate = new DateTime(2021, 5, 5, 11, 0, 0)
89+
},
90+
new Appoinment
91+
{
92+
Id = 12,
93+
Text = "Upgrade Server Hardware",
94+
StartDate = new DateTime(2021, 5, 5, 16, 30, 0),
95+
EndDate = new DateTime(2021, 5, 5, 18, 0, 0)
96+
},
97+
new Appoinment
98+
{
99+
Id = 13,
100+
Text = "Launch New Website",
101+
StartDate = new DateTime(2021, 5, 5, 14, 30, 0),
102+
EndDate = new DateTime(2021, 5, 5, 16, 10, 0)
103+
}
104+
};
105+
}
106+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
@model IEnumerable<ASP_NET_Core.Models.Appoinment>
2+
3+
@(Html.DevExtreme().Scheduler()
4+
.ID("scheduler")
5+
.DataSource(Model)
6+
.TextExpr("Text")
7+
.StartDateExpr("StartDate")
8+
.EndDateExpr("EndDate")
9+
.Views(views =>
10+
{
11+
views.Add()
12+
.Type(SchedulerViewType.TimelineDay)
13+
.IntervalCount(3);
14+
})
15+
.CurrentView(SchedulerViewType.TimelineDay)
16+
.CurrentDate(new DateTime(2021, 5, 3))
17+
.StartDayHour(9)
18+
.EndDayHour(19)
19+
.CellDuration(60)
20+
.Height(600)
21+
.DataCellTemplate(new JS("renderCellTemplate"))
22+
.OnAppointmentFormOpening("onAppointmentFormOpening")
23+
.OnAppointmentAdding("onAppointmentChanging")
24+
.OnAppointmentUpdating("onAppointmentChanging")
25+
)
26+
27+
<script>
28+
var dinnerTime = { start: 12, end: 13 };
29+
30+
var holiday = {
31+
date: new Date(2021, 4, 4),
32+
name: 'Star Wars Day'
33+
};
34+
35+
function renderCellTemplate(itemData, itemIndex, itemElement) {
36+
var startDate = itemData.startDate;
37+
var endDate = itemData.endDate;
38+
39+
var isHolidayCell = isHoliday(startDate, endDate);
40+
var isDinnerCell = isDinner(startDate, endDate);
41+
42+
var element = $(`<div>${getCellText(itemData)}</div>`);
43+
44+
if (isHolidayCell) {
45+
element.addClass('holiday');
46+
}
47+
48+
if (isDinnerCell) {
49+
element.addClass('dinner');
50+
}
51+
52+
return itemElement.append(element);
53+
}
54+
55+
function getCellText(itemData) {
56+
const startDate = itemData.startDate;
57+
const endDate = itemData.endDate;
58+
59+
const isHoliday = this.isHoliday(startDate, endDate);
60+
const isDinner = this.isDinner(startDate, endDate);
61+
62+
if (isHoliday) {
63+
return holiday.name;
64+
} else if (isDinner) {
65+
return "Dinner Time";
66+
}
67+
68+
return itemData.text;
69+
}
70+
71+
function isHoliday(startDate, endDate) {
72+
return holiday.date.toLocaleDateString() === startDate.toLocaleDateString() &&
73+
holiday.date.toLocaleDateString() === endDate.toLocaleDateString();
74+
}
75+
76+
function hasIntersection(startA, endA, startB, endB) {
77+
if ((startA <= startB && endB <= endA) ||
78+
(startB <= startA && endA <= endB)) {
79+
return true;
80+
}
81+
82+
return (startA < startB && startB < endA) ||
83+
(startA < endB && endB < endA);
84+
}
85+
86+
function isDinner(startDate, endDate) {
87+
var todayDinnerStart = new Date(startDate).setHours(dinnerTime.start, 0, 0, 0);
88+
var todayDinnerEnd = new Date(endDate).setHours(dinnerTime.end, 0, 0, 0);
89+
90+
return hasIntersection(
91+
todayDinnerStart, todayDinnerEnd,
92+
startDate.getTime(), endDate.getTime()
93+
);
94+
}
95+
96+
function onAppointmentChanging(e) {
97+
var startDate = e.appointmentData
98+
? new Date(e.appointmentData.StartDate)
99+
: new Date(e.newData.StartDate);
100+
101+
var endDate = e.appointmentData
102+
? new Date(e.appointmentData.EndDate)
103+
: new Date(e.newData.EndDate);
104+
105+
if (!isValidAppointmentDate(startDate, endDate)) {
106+
e.cancel = true;
107+
notifyDisableDate();
108+
}
109+
}
110+
111+
function onAppointmentFormOpening(e) {
112+
var startDate = new Date(e.appointmentData.startDate);
113+
var endDate = new Date(e.appointmentData.endDate);
114+
115+
if (!isValidAppointmentDate(startDate, endDate)) {
116+
e.cancel = true;
117+
notifyDisableDate();
118+
}
119+
applyDisableDatesToDateEditors(e.form);
120+
}
121+
122+
function isValidAppointmentDate(startDate, endDate) {
123+
return !isHoliday(startDate, endDate) && !isDinner(startDate, endDate);
124+
}
125+
126+
function applyDisableDatesToDateEditors(form) {
127+
var holidaysDate = holiday.date;
128+
129+
var startDateEditor = form.getEditor('StartDate');
130+
startDateEditor.option('disabledDates', [holidaysDate]);
131+
132+
var endDateEditor = form.getEditor('EndDate');
133+
endDateEditor.option('disabledDates', [holidaysDate]);
134+
}
135+
136+
function notifyDisableDate() {
137+
DevExpress.ui.notify("This date is disabled", "warning", 500);
138+
}
139+
</script>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta charset="utf-8">
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
8+
<meta name="description" content="">
9+
<meta name="author" content="">
10+
11+
<title>ASP_NET_Core</title>
12+
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
13+
14+
@* Uncomment to use the HtmlEditor control *@
15+
@* <script src="https://unpkg.com/devextreme-quill/dist/dx-quill.min.js"></script> *@
16+
17+
<link rel="stylesheet" href="~/css/vendor.css" asp-append-version="true" />
18+
<link rel="stylesheet" href="~/css/Site.css" />
19+
<script src="~/js/vendor.js" asp-append-version="true"></script>
20+
</head>
21+
22+
<body class="dx-viewport">
23+
<div class="demo-container">
24+
@RenderBody()
25+
</div>
26+
</body>
27+
28+
</html>

ASP.NET Core/orig_Program.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace ASP_NET_Core
11+
{
12+
public class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
CreateHostBuilder(args).Build().Run();
17+
}
18+
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder => {
22+
webBuilder.UseStartup<Startup>();
23+
});
24+
}
25+
}

ASP.NET Core/orig_Startup.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.Extensions.Configuration;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Hosting;
10+
11+
namespace ASP_NET_Core
12+
{
13+
public class Startup
14+
{
15+
public Startup(IConfiguration configuration)
16+
{
17+
Configuration = configuration;
18+
}
19+
20+
public IConfiguration Configuration { get; }
21+
22+
// This method gets called by the runtime. Use this method to add services to the container.
23+
public void ConfigureServices(IServiceCollection services)
24+
{
25+
// Add framework services.
26+
services
27+
.AddControllersWithViews()
28+
.AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
29+
}
30+
31+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
32+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
33+
{
34+
if (env.IsDevelopment())
35+
{
36+
app.UseDeveloperExceptionPage();
37+
}
38+
else
39+
{
40+
app.UseExceptionHandler("/Home/Error");
41+
}
42+
app.UseStaticFiles();
43+
44+
app.UseRouting();
45+
46+
app.UseAuthorization();
47+
48+
app.UseEndpoints(endpoints => {
49+
endpoints.MapControllerRoute(
50+
name: "default",
51+
pattern: "{controller=Scheduler}/{action=Index}/{id?}");
52+
});
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)