Skip to content

Commit c12fdc6

Browse files
Update to 25.1.3+
1 parent 1076aad commit c12fdc6

26 files changed

+1404
-28
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 MyApplication.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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Net.Http;
6+
using MyApplication.Models;
7+
using DevExtreme.AspNet.Data;
8+
using DevExtreme.AspNet.Mvc;
9+
using Microsoft.AspNetCore.Mvc;
10+
using Newtonsoft.Json;
11+
12+
namespace MyApplication.Controllers {
13+
14+
[Route("api/[controller]/[action]")]
15+
public class SampleDataController : Controller
16+
{
17+
[HttpGet]
18+
public object GetStudents(DataSourceLoadOptions loadOptions)
19+
{
20+
return DataSourceLoader.Load(SampleData.Students, loadOptions);
21+
}
22+
23+
[HttpPost]
24+
public IActionResult InsertStudent(string values)
25+
{
26+
var newStudent = new Student();
27+
JsonConvert.PopulateObject(values, newStudent);
28+
29+
newStudent.ID = SampleData.Students.Count() + 1;
30+
SampleData.Students.Add(newStudent);
31+
32+
return Ok(newStudent);
33+
}
34+
35+
[HttpPut]
36+
public IActionResult UpdateStudent(int key, string values)
37+
{
38+
var student = SampleData.Students.First(s => s.ID == key);
39+
JsonConvert.PopulateObject(values, student);
40+
41+
return Ok(student);
42+
}
43+
44+
[HttpDelete]
45+
public void DeleteStudent(int key)
46+
{
47+
var student = SampleData.Students.First(s => s.ID == key);
48+
SampleData.Students.Remove(student);
49+
}
50+
}
51+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace MyApplication.Models {
8+
static class SampleData {
9+
public static List<Student> Students = new List<Student>() {
10+
new Student
11+
{
12+
ID = 1,
13+
Name = "John",
14+
Subjects = new List<Subject>() {
15+
new Subject
16+
{
17+
Code = "Math101",
18+
Name = "Math 1",
19+
Section = "Dev1-1"
20+
},
21+
new Subject
22+
{
23+
Code = "Eng101",
24+
Name = "English 1",
25+
Section = "Dev1-2"
26+
}
27+
}
28+
},
29+
new Student
30+
{
31+
ID = 2,
32+
Name = "Olivia",
33+
Subjects = new List<Subject>() {
34+
new Subject
35+
{
36+
Code = "Prog101",
37+
Name = "Programming 1",
38+
Section = "Dev1-2"
39+
},
40+
new Subject
41+
{
42+
Code = "Dbms101",
43+
Name = "Database Management 1",
44+
Section = "Dev1-1"
45+
}
46+
}
47+
},
48+
new Student
49+
{
50+
ID = 3,
51+
Name = "Robert",
52+
Subjects = new List<Subject>() {
53+
new Subject
54+
{
55+
Code = "Math101",
56+
Name = "Math 1",
57+
Section = "Dev1-1"
58+
},
59+
new Subject
60+
{
61+
Code = "Prog101",
62+
Name = "Programming 1",
63+
Section = "Dev1-2"
64+
}
65+
}
66+
},
67+
new Student
68+
{
69+
ID = 4,
70+
Name = "Greta",
71+
Subjects = new List<Subject>() {
72+
new Subject
73+
{
74+
Code = "Dbms101",
75+
Name = "Database Management 1",
76+
Section = "Dev1-2"
77+
},
78+
new Subject
79+
{
80+
Code = "Eng101",
81+
Name = "English 1",
82+
Section = "Dev1-2"
83+
}
84+
}
85+
}
86+
};
87+
}
88+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
8+
namespace MyApplication.Models
9+
{
10+
public class Student
11+
{
12+
public int ID { get; set; }
13+
[Required]
14+
public string Name { get; set; }
15+
16+
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
17+
public List<Subject> Subjects { get; set; }
18+
}
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace MyApplication.Models
8+
{
9+
public class Subject
10+
{
11+
[Required]
12+
public string Code { get; set; }
13+
[Required]
14+
public string Name { get; set; }
15+
[Required]
16+
public string Section { get; set; }
17+
}
18+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
@using MyApplication.Models
2+
3+
<h2>Home</h2>
4+
5+
@(Html.DevExtreme().DataGrid<Student>()
6+
.ShowBorders(true)
7+
.DataSource(d => d.Mvc().Controller("SampleData")
8+
.Key("ID")
9+
.LoadAction("GetStudents")
10+
.InsertAction("InsertStudent")
11+
.UpdateAction("UpdateStudent")
12+
.DeleteAction("DeleteStudent")
13+
)
14+
.Columns(columns => {
15+
columns.AddFor(m => m.Name);
16+
17+
columns.AddFor(m => m.Subjects)
18+
.CellTemplate(new JS("cellTemplate"))
19+
.EditCellTemplate(new TemplateName("subjectEditor"));
20+
})
21+
.Editing(editing => editing
22+
.Mode(GridEditMode.Popup)
23+
.AllowAdding(true)
24+
.AllowDeleting(true)
25+
.AllowUpdating(true)
26+
.Form(form => form.ColCount(1))
27+
.Popup(popup => popup
28+
.ShowTitle(true)
29+
.Title("Student")
30+
.Width(800)
31+
.Height(400)
32+
)
33+
)
34+
)
35+
36+
@using (Html.DevExtreme().NamedTemplate("subjectEditor"))
37+
{
38+
@(Html.DevExtreme().DataGrid<Subject>()
39+
.DataSource(new JS("data.Subjects || []"))
40+
.KeyExpr("Code")
41+
.Columns(columns => {
42+
columns.AddFor(m => m.Code);
43+
columns.AddFor(m => m.Name);
44+
columns.AddFor(m => m.Section);
45+
})
46+
.Editing(editing => editing
47+
.Mode(GridEditMode.Row)
48+
.AllowAdding(true)
49+
.AllowDeleting(true)
50+
.AllowUpdating(true)
51+
)
52+
.OnSaved("(e) => setValue(e.component.option('dataSource'))")
53+
.OnOptionChanged("(e) => onOptionChanged(e, setValue)")
54+
)
55+
}
56+
57+
<script>
58+
function cellTemplate(container, options) {
59+
const noBreakSpace = '\u00A0';
60+
const text = (options.value || []).map((element) => element.Name).join(', ');
61+
container.text(text || noBreakSpace).attr('title', text);
62+
}
63+
64+
function onOptionChanged(e, setValue) {
65+
if (e.fullName === "editing.changes") {
66+
var changes = e.component.option("editing.changes");
67+
var data = e.component.option("dataSource");
68+
data = DevExpress.data.applyChanges(data, changes, { keyExpr: 'Code' });
69+
setValue(data);
70+
}
71+
}
72+
</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>MyApplication</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="/">MyApplication</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>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
body {
2+
}

Angular/src/app/orig_app.component.css

Whitespace-only changes.

0 commit comments

Comments
 (0)