Skip to content

Commit b2a1126

Browse files
Update to 25.1.3+
1 parent 1ada52a commit b2a1126

19 files changed

+1241
-29
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using ASP_NET_Core.Models;
6+
using Microsoft.AspNetCore.Mvc;
7+
8+
namespace ASP_NET_Core.Controllers
9+
{
10+
public class HomeController : Controller
11+
{
12+
public IActionResult Index()
13+
{
14+
return View(SampleData.Appointments);
15+
}
16+
17+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
18+
public IActionResult Error()
19+
{
20+
return View();
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace ASP.NET_Core.Models
7+
{
8+
public class SampleAppointment
9+
{
10+
public int ID { get; set; }
11+
public int Price { get; set; }
12+
public DateTime StartDate { get; set; }
13+
public DateTime EndDate { get; set; }
14+
public string Text { get; set; }
15+
public string Director { get; set; }
16+
public int Year { get; set; }
17+
public string Image { get; set; }
18+
public int Duration { get; set; }
19+
public string SeatRow { get; set; }
20+
public int SeatNumber { get; set; }
21+
22+
}
23+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using ASP.NET_Core.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ASP_NET_Core.Models {
9+
static class SampleData {
10+
public static List<SampleAppointment> Appointments = new List<SampleAppointment>() {
11+
new SampleAppointment
12+
{
13+
ID = 1,
14+
Price = 10,
15+
StartDate = new DateTime(2015, 4, 25, 9, 10, 0),
16+
EndDate = new DateTime(2015, 4, 25, 11, 1, 0),
17+
Text = "His Girl Friday",
18+
Director = "Howard Hawks",
19+
Year = 1940,
20+
Image = "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/movies/HisGirlFriday.jpg",
21+
Duration = 92
22+
},
23+
new SampleAppointment
24+
{
25+
ID = 2,
26+
Price = 5,
27+
StartDate = new DateTime(2015, 4, 25, 11, 30, 0),
28+
EndDate = new DateTime(2015, 4, 25, 13, 2, 0),
29+
Text = "Royal Wedding",
30+
Director = "Stanley Donen",
31+
Year = 1951,
32+
Image = "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/movies/RoyalWedding.jpg",
33+
Duration = 93
34+
},
35+
new SampleAppointment
36+
{
37+
ID = 3,
38+
Price = 15,
39+
StartDate = new DateTime(2015, 4, 25, 13, 20, 0),
40+
EndDate = new DateTime(2015, 4, 25, 15, 21, 0),
41+
Text = "A Star Is Born",
42+
Director = "William A. Wellman",
43+
Year = 1937,
44+
Image = "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/movies/AStartIsBorn.jpg",
45+
Duration = 111
46+
}
47+
};
48+
}
49+
}
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
@model IEnumerable<ASP.NET_Core.Models.SampleAppointment>
2+
3+
<style>
4+
.long-title h3 {
5+
font-family: 'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana;
6+
font-weight: 200;
7+
font-size: 28px;
8+
text-align: center;
9+
margin-bottom: 20px;
10+
}
11+
</style>
12+
13+
<div class="long-title">
14+
<h3>DXCinema Upcoming Movies</h3>
15+
</div>
16+
17+
@(Html.DevExtreme().Scheduler()
18+
.ID("scheduler")
19+
.DataSource(Model)
20+
.StartDateExpr("StartDate")
21+
.EndDateExpr("EndDate")
22+
.TextExpr("Text")
23+
.Views(new[] {
24+
SchedulerViewType.Day,
25+
SchedulerViewType.TimelineDay
26+
})
27+
.CurrentView(SchedulerViewType.Day)
28+
.CurrentDate(new DateTime(2015, 4, 25))
29+
.FirstDayOfWeek(0)
30+
.StartDayHour(9)
31+
.EndDayHour(23)
32+
.ShowAllDayPanel(false)
33+
.Height(600)
34+
.OnAppointmentFormOpening("onAppointmentFormOpening"));
35+
36+
@(Html.DevExtreme().Popup()
37+
.ID("popup")
38+
.Width(500)
39+
.Height("80vh")
40+
.CloseOnOutsideClick(true)
41+
.Visible(new JS("isCustomPopupVisible"))
42+
.Title(new JS("editAppointmentData.Text"))
43+
.OnHiding("onHiding")
44+
.ContentTemplate(new TemplateName("popup-template"))
45+
.ToolbarItems(t =>
46+
{
47+
t.Add()
48+
.Toolbar(Toolbar.Bottom)
49+
.Location(ToolbarItemLocation.After).
50+
Widget(w => w.Button()
51+
.Text("OK")
52+
.OnClick("setAppointment"));
53+
}));
54+
55+
56+
@using (Html.DevExtreme().NamedTemplate("popup-template"))
57+
{
58+
@(Html.DevExtreme().ScrollView()
59+
.Width("100%")
60+
.Height("100%")
61+
.Content(@<text>
62+
<img id="popup-image" src="" class="dx-field-label" />
63+
<div class="dx-field-label">
64+
<p>
65+
<b id="popup-text"></b>
66+
</p>
67+
<p id="popup-year"></p>
68+
<p id="popup-duration"></p>
69+
</div>
70+
71+
<div class="dx-field-label">
72+
<b id="popup-date"></b>
73+
</div>
74+
75+
<div class="dx-field-label"><b>Price ($): </b></div>
76+
<div id="popup-price" class="dx-field-label">
77+
</div>
78+
79+
@(Html.DevExtreme().SelectBox()
80+
.ID("rowView")
81+
.ElementAttr(new JS("elementAttr"))
82+
.DataSource(new JS("rows"))
83+
.Width(400)
84+
.Placeholder("Pick a row")
85+
.Value(new JS("editAppointmentData.SeatRow"))
86+
.OnValueChanged("onValueChangedRow")
87+
)
88+
89+
@(Html.DevExtreme().SelectBox()
90+
.ID("numberView")
91+
.ElementAttr(new JS("elementAttr"))
92+
.DataSource(new JS("seats"))
93+
.Width(400)
94+
.Placeholder("Pick a seat")
95+
.Value(new JS("editAppointmentData.SeatNumber"))
96+
.OnValueChanged("onValueChangedNumber")
97+
)
98+
</text>)
99+
)
100+
}
101+
102+
103+
<script>
104+
var editAppointmentData = {};
105+
var oldAppointment = {};
106+
var isCustomPopupVisible = false;
107+
var customPopupTitle = "";
108+
109+
var elementAttr = {
110+
class: "dx-field-label"
111+
};
112+
113+
var rows = ['A', 'B', 'C', 'D'];
114+
var seats = [1, 2, 3, 4, 5];
115+
116+
function onAppointmentFormOpening(e) {
117+
e.cancel = true;
118+
editAppointmentData = { ...e.appointmentData };
119+
oldAppointment = e.appointmentData;
120+
if (editAppointmentData.ID) {
121+
isCustomPopupVisible = true;
122+
customPopupTitle = editAppointmentData.Text
123+
124+
let customPopupOptions = {
125+
visible: isCustomPopupVisible,
126+
title: customPopupTitle
127+
};
128+
129+
$("#popup").dxPopup("instance").option(customPopupOptions);
130+
131+
$("#popup-text").text(editAppointmentData.Text);
132+
$("#popup-year").text(`Year: ${editAppointmentData.Year}`);
133+
$("#popup-duration").text(`Duration: ${editAppointmentData.Duration} minutes`);
134+
135+
136+
$("#popup-date").text(`${DevExpress.localization.formatDate(new Date(editAppointmentData.StartDate), "shortTime")} - ${DevExpress.localization.formatDate(new Date(editAppointmentData.EndDate), "shortTime")}`);
137+
$("#popup-image").attr("src", editAppointmentData.Image);
138+
$("#popup-price").text(calculatePrice(editAppointmentData.SeatRow, editAppointmentData.SeatNumber, editAppointmentData.price))
139+
140+
$("#rowView").dxSelectBox("instance").option("value", editAppointmentData.SeatRow);
141+
$("#numberView").dxSelectBox("instance").option("value", editAppointmentData.SeatNumber);
142+
143+
}
144+
}
145+
146+
function setAppointment() {
147+
if (editAppointmentData.SeatRow && editAppointmentData.SeatNumber) {
148+
let scheduler = $("#scheduler").dxScheduler("instance");
149+
scheduler.updateAppointment(
150+
oldAppointment,
151+
editAppointmentData
152+
);
153+
DevExpress.ui.notify(`Selected seat ${editAppointmentData.SeatRow}${editAppointmentData.SeatNumber} for ${editAppointmentData.Text}. Enjoy!`);
154+
}
155+
$("#popup").dxPopup("instance").hide();
156+
}
157+
158+
function onHiding(e) {
159+
editAppointmentData = {};
160+
oldAppointment = {};
161+
}
162+
163+
function calculatePrice(SeatRow, SeatNumber, price) {
164+
return SeatRow && SeatNumber ? "$" + setSeatPrice(price, SeatRow) : "Pick a seat for pricing";
165+
}
166+
167+
function setSeatPrice(price, SeatRow) {
168+
let rowPrice;
169+
switch (SeatRow) {
170+
case 'A':
171+
rowPrice = 1;
172+
break;
173+
case 'B':
174+
rowPrice = 2;
175+
break;
176+
case 'C':
177+
rowPrice = 3;
178+
break;
179+
case 'D':
180+
rowPrice = 4;
181+
break;
182+
default:
183+
break;
184+
}
185+
return price * rowPrice;
186+
}
187+
188+
function onValueChangedRow(e) {
189+
editAppointmentData.SeatRow = e.value;
190+
if (editAppointmentData.SeatRow && editAppointmentData.SeatNumber) {
191+
let priceText = calculatePrice(editAppointmentData.SeatRow, editAppointmentData.SeatNumber, editAppointmentData.Price)
192+
$("#popup-price").text(priceText);
193+
}
194+
}
195+
196+
function onValueChangedNumber(e) {
197+
editAppointmentData.SeatNumber = e.value;
198+
if (editAppointmentData.SeatRow && editAppointmentData.SeatNumber) {
199+
let priceText = calculatePrice(editAppointmentData.SeatRow, editAppointmentData.SeatNumber, editAppointmentData.Price)
200+
$("#popup-price").text(priceText);
201+
}
202+
}
203+
204+
</script>
205+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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>
23+
24+
25+
<main role="main">
26+
@RenderBody()
27+
</main>
28+
</body>
29+
30+
</html>

0 commit comments

Comments
 (0)