Skip to content

Commit 4d6f1ad

Browse files
Update to 25.1.3+
1 parent 1076aad commit 4d6f1ad

25 files changed

+1191
-26
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace T957230.Controllers
8+
{
9+
public class HomeController : Controller
10+
{
11+
public IActionResult Index()
12+
{
13+
return View();
14+
}
15+
16+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
17+
public IActionResult Error() {
18+
return View();
19+
}
20+
}
21+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Net.Http;
6+
using T957230.Models;
7+
using DevExtreme.AspNet.Data;
8+
using DevExtreme.AspNet.Mvc;
9+
using Microsoft.AspNetCore.Mvc;
10+
using Newtonsoft.Json;
11+
using System.IO;
12+
using System.Text;
13+
using Microsoft.AspNetCore.Http;
14+
15+
namespace T957230.Controllers {
16+
17+
[Route("api/[controller]/[action]")]
18+
public class SampleDataController : Controller {
19+
20+
[HttpGet]
21+
public object GetEmployees(DataSourceLoadOptions loadOptions) {
22+
return DataSourceLoader.Load(SampleData.Employees, loadOptions);
23+
}
24+
25+
[HttpPost]
26+
public IActionResult InsertEmployee(string values) {
27+
var newEmployee = new Employee();
28+
JsonConvert.PopulateObject(values, newEmployee);
29+
30+
SampleData.Employees.Add(newEmployee);
31+
32+
return Ok(newEmployee);
33+
}
34+
35+
[HttpPut]
36+
public IActionResult UpdateEmployee(int key, string values) {
37+
var employee = SampleData.Employees.First(e => e.ID == key);
38+
JsonConvert.PopulateObject(values, employee);
39+
40+
return Ok(employee);
41+
}
42+
43+
[HttpGet]
44+
public object GetLookupData(DataSourceLoadOptions loadOptions)
45+
{
46+
return DataSourceLoader.Load(SampleData.Customers, loadOptions);
47+
}
48+
}
49+
}
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.Threading.Tasks;
5+
6+
namespace T957230.Models
7+
{
8+
public class Customer
9+
{
10+
public int CustomerID { get; set; }
11+
public string CustomerName { get; set; }
12+
public string Address { get; set; }
13+
public string Phone { get; set; }
14+
}
15+
}
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.Threading.Tasks;
5+
6+
namespace T957230.Models
7+
{
8+
public class Employee
9+
{
10+
public int ID { get; set; }
11+
public int CustomerID { get; set; }
12+
public string Address { get; set; }
13+
public string Phone { get; set; }
14+
}
15+
}
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace T957230.Models {
8+
static class SampleData {
9+
public static List<Employee> Employees = new List<Employee>() {
10+
new Employee {
11+
ID = 1,
12+
CustomerID = 1,
13+
Address = "Markušica",
14+
Phone = "+385 674 958 1641"
15+
},
16+
new Employee {
17+
ID = 2,
18+
CustomerID = 2,
19+
Address = "Itaberaí",
20+
Phone = "+55 491 329 4084"
21+
},
22+
new Employee {
23+
ID = 3,
24+
CustomerID = 3,
25+
Address = "Volgograd",
26+
Phone = "+7 745 619 7799"
27+
},
28+
new Employee {
29+
ID = 4,
30+
CustomerID = 4,
31+
Address = "Shuiyin",
32+
Phone = "+86 774 746 9874"
33+
},
34+
new Employee {
35+
ID = 5,
36+
CustomerID = 5,
37+
Address = "Baturaden",
38+
Phone = "+62 113 149 9397"
39+
},
40+
new Employee {
41+
ID = 6,
42+
CustomerID = 6,
43+
Address = "New York City",
44+
Phone = "+1 917 528 7751"
45+
},
46+
new Employee {
47+
ID = 7,
48+
CustomerID = 7,
49+
Address = "Adolfo Lopez Mateos",
50+
Phone = "+52 626 244 6757"
51+
},
52+
new Employee {
53+
ID = 8,
54+
CustomerID = 8,
55+
Address = "Nong Khae",
56+
Phone = "+66 326 375 8694"
57+
},
58+
new Employee {
59+
ID = 9,
60+
CustomerID = 9,
61+
Address = "Znamenskoye",
62+
Phone = "+7 926 141 2517"
63+
},
64+
new Employee {
65+
ID = 10,
66+
CustomerID = 10,
67+
Address = "Patpata Segundo",
68+
Phone = "+63 428 750 7737"
69+
},
70+
new Employee {
71+
ID = 11,
72+
CustomerID = 11,
73+
Address = "Fontanka",
74+
Phone = "+380 557 509 4191"
75+
},
76+
new Employee {
77+
ID = 12,
78+
CustomerID = 12,
79+
Address = "Novosil’",
80+
Phone = "+7 493 632 2768"
81+
},
82+
new Employee {
83+
ID = 13,
84+
CustomerID = 13,
85+
Address = "Ubinskoye",
86+
Phone = "+7 954 353 8930"
87+
},
88+
new Employee {
89+
ID = 14,
90+
CustomerID = 14,
91+
Address = "Protvino",
92+
Phone = "+7 386 362 2407"
93+
},
94+
new Employee {
95+
ID = 15,
96+
CustomerID = 15,
97+
Address = "Santa Fé do Sul",
98+
Phone = "+55 867 691 7097"
99+
}
100+
};
101+
102+
public static List<Customer> Customers = new List<Customer>() {
103+
new Customer {
104+
CustomerID = 1,
105+
CustomerName = "Kaela Phonix",
106+
Address = "Markušica",
107+
Phone = "+385 674 958 1641"
108+
},
109+
new Customer {
110+
CustomerID = 2,
111+
CustomerName = "Dotty Hearnden",
112+
Address = "Itaberaí",
113+
Phone = "+55 491 329 4084"
114+
},
115+
new Customer {
116+
CustomerID = 3,
117+
CustomerName = "Alasdair Greenin",
118+
Address = "Volgograd",
119+
Phone = "+7 657 495 7659"
120+
},
121+
new Customer {
122+
CustomerID = 4,
123+
CustomerName = "Stoddard Laidlaw",
124+
Address = "Shuiyin",
125+
Phone = "+86 774 746 9874"
126+
},
127+
new Customer {
128+
CustomerID = 5,
129+
CustomerName = "Damiano Gencke",
130+
Address = "Baturaden",
131+
Phone = "+62 113 149 9397"
132+
},
133+
new Customer {
134+
CustomerID = 6,
135+
CustomerName = "Aura Bavidge",
136+
Address = "New York City",
137+
Phone = "+1 917 528 7751"
138+
},
139+
new Customer {
140+
CustomerID = 7,
141+
CustomerName = "Emmanuel Chedgey",
142+
Address = "Adolfo Lopez Mateos",
143+
Phone = "+52 626 244 6757"
144+
},
145+
new Customer {
146+
CustomerID = 8,
147+
CustomerName = "Clerkclaude Pargeter",
148+
Address = "Nong Khae",
149+
Phone = "+66 326 375 8694"
150+
},
151+
new Customer {
152+
CustomerID = 9,
153+
CustomerName = "Onfroi Cinnamond",
154+
Address = "Znamenskoye",
155+
Phone = "+7 926 141 2517"
156+
},
157+
new Customer {
158+
CustomerID = 10,
159+
CustomerName = "Madlin Kopke",
160+
Address = "Patpata Segundo",
161+
Phone = "+63 428 750 7737"
162+
},
163+
new Customer {
164+
CustomerID = 11,
165+
CustomerName = "Mortie Feary",
166+
Address = "Fontanka",
167+
Phone = "+380 557 509 4191"
168+
},
169+
new Customer {
170+
CustomerID = 12,
171+
CustomerName = "Colet Haitlie",
172+
Address = "Novosil’",
173+
Phone = "+7 493 632 2768"
174+
},
175+
new Customer {
176+
CustomerID = 13,
177+
CustomerName = "Pippy Carnell",
178+
Address = "Ubinskoye",
179+
Phone = "+7 954 353 8930"
180+
},
181+
new Customer {
182+
CustomerID = 14,
183+
CustomerName = "Arvie Midden",
184+
Address = "Protvino",
185+
Phone = "+7 386 362 2407"
186+
},
187+
new Customer {
188+
CustomerID = 15,
189+
CustomerName = "Brook Kamena",
190+
Address = "Santa Fé do Sul",
191+
Phone = "+55 867 691 7097"
192+
}
193+
};
194+
}
195+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@using T957230.Models
2+
3+
<h2>Home</h2>
4+
5+
@(Html.DevExtreme().DataGrid<Employee>()
6+
.ShowBorders(true)
7+
.DataSource(d => d.Mvc().Controller("SampleData")
8+
.LoadAction("GetEmployees")
9+
.InsertAction("InsertEmployee")
10+
.UpdateAction("UpdateEmployee")
11+
.Key("ID")
12+
)
13+
.Editing(e => e
14+
.Mode(GridEditMode.Row)
15+
.AllowAdding(true)
16+
.AllowUpdating(true)
17+
)
18+
.Columns(columns => {
19+
columns.AddFor(m => m.CustomerID)
20+
.Caption("Name")
21+
.SetCellValue("setCustomerIDValue")
22+
.Lookup(lookup => lookup
23+
.DataSource(d => d.Mvc().Controller("SampleData").LoadAction("GetLookupData").Key("CustomerID"))
24+
.ValueExpr("CustomerID")
25+
.DisplayExpr("CustomerName")
26+
);
27+
28+
columns.AddFor(m => m.Address);
29+
30+
columns.AddFor(m => m.Phone);
31+
})
32+
.OnEditorPreparing("onEditorPreparing")
33+
)
34+
35+
<script>
36+
function setCustomerIDValue(rowData, value) {
37+
rowData.CustomerID = value.CustomerID;
38+
rowData.Address = value.Address;
39+
rowData.Phone = value.Phone;
40+
}
41+
42+
function onEditorPreparing(e) {
43+
if (e.parentType === "dataRow" && e.dataField === "CustomerID") {
44+
e.editorOptions.onValueChanged = function (args) {
45+
const selectedItem = args.component.option("selectedItem");
46+
e.setValue(selectedItem);
47+
}
48+
}
49+
}
50+
</script>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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>T957230</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 style="padding-top: 5rem;">
23+
24+
<nav class="navbar navbar-dark bg-dark fixed-top navbar-expand-md">
25+
<a class="navbar-brand" href="/">T957230</a>
26+
27+
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
28+
<span class="navbar-toggler-icon"></span>
29+
</button>
30+
31+
<div id="navbar" class="collapse navbar-collapse">
32+
<ul class="navbar-nav mr-auto">
33+
<li class="active nav-item"><a href="#" class="nav-link">Home</a></li>
34+
<li class="nav-item"><a href="#about" class="nav-link">About</a></li>
35+
<li class="nav-item"><a href="#contact" class="nav-link">Contact</a></li>
36+
</ul>
37+
</div>
38+
</nav>
39+
40+
<main role="main" class="container">
41+
@RenderBody()
42+
</main>
43+
</body>
44+
45+
</html>

0 commit comments

Comments
 (0)