Skip to content

Commit ee1a675

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

36 files changed

+2192
-31
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 DevExtreme.AspNet.Data;
6+
using DevExtreme.AspNet.Mvc;
7+
using DevExtremeAspNetCoreApp1.Models;
8+
using Microsoft.AspNetCore.Http;
9+
using Microsoft.AspNetCore.Mvc;
10+
11+
namespace DevExtremeAspNetCoreApp1.Controllers
12+
{
13+
[Route("api/[controller]")]
14+
[ApiController]
15+
public class DataGridCitiesByStateController : ControllerBase
16+
{
17+
[HttpGet]
18+
public object Get(DataSourceLoadOptions loadOptions)
19+
{
20+
return DataSourceLoader.Load(SampleData.CitiesByState, loadOptions);
21+
}
22+
}
23+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using DevExtreme.AspNet.Data;
7+
using DevExtreme.AspNet.Mvc;
8+
using DevExtremeAspNetCoreApp1.Models;
9+
using Microsoft.AspNetCore.Http;
10+
using Microsoft.AspNetCore.Mvc;
11+
using Newtonsoft.Json;
12+
13+
namespace DevExtremeAspNetCoreApp1.Controllers
14+
{
15+
[Route("api/[controller]/[action]")]
16+
public class DataGridEmployeesByStateController : Controller
17+
{
18+
[HttpGet]
19+
public object Get(DataSourceLoadOptions loadOptions)
20+
{
21+
return DataSourceLoader.Load(SampleData.DataGridEmployeesByState, loadOptions);
22+
}
23+
24+
[HttpPost]
25+
public IActionResult Post(string values)
26+
{
27+
var newEmployee = new EmployeeByState();
28+
JsonConvert.PopulateObject(values, newEmployee);
29+
30+
if (!TryValidateModel(newEmployee))
31+
return BadRequest("Failed to insert item");
32+
33+
SampleData.DataGridEmployeesByState.Append(newEmployee);
34+
35+
return Ok();
36+
}
37+
38+
[HttpPut]
39+
public IActionResult Put(int key, string values)
40+
{
41+
var employee = SampleData.DataGridEmployeesByState.First(a => a.ID == key);
42+
43+
PopulateModel(JsonConvert.DeserializeObject<EmployeeByState>(values), employee);
44+
45+
46+
if (!TryValidateModel(employee))
47+
return BadRequest("Failed to update item");
48+
49+
50+
return Ok();
51+
}
52+
53+
[HttpDelete]
54+
public void Delete(int key)
55+
{
56+
var employee = SampleData.DataGridEmployeesByState.First(a => a.ID == key);
57+
SampleData.DataGridEmployeesByState.Remove(employee);
58+
}
59+
60+
private void PopulateModel(EmployeeByState values, EmployeeByState currEmployee)
61+
{
62+
if (!(values.StateID is null))
63+
currEmployee.StateID = values.StateID;
64+
65+
if (!(values.CityID is null))
66+
currEmployee.CityID = values.CityID;
67+
}
68+
}
69+
}
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 DevExtreme.AspNet.Data;
6+
using DevExtreme.AspNet.Mvc;
7+
using DevExtremeAspNetCoreApp1.Models;
8+
using Microsoft.AspNetCore.Http;
9+
using Microsoft.AspNetCore.Mvc;
10+
11+
namespace DevExtremeAspNetCoreApp1.Controllers
12+
{
13+
[Route("api/[controller]")]
14+
[ApiController]
15+
public class DataGridStatesWithCitiesController : ControllerBase
16+
{
17+
18+
[HttpGet]
19+
public object Get(DataSourceLoadOptions loadOptions)
20+
{
21+
return DataSourceLoader.Load(SampleData.StatesWithCities, loadOptions);
22+
}
23+
24+
}
25+
}
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.Mvc;
6+
7+
namespace DevExtremeAspNetCoreApp1.Controllers
8+
{
9+
public class HomeController : Controller
10+
{
11+
public IActionResult Index()
12+
{
13+
return View();
14+
}
15+
16+
public IActionResult About() {
17+
return View();
18+
}
19+
20+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
21+
public IActionResult Error() {
22+
return View();
23+
}
24+
}
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace DevExtremeAspNetCoreApp1.Models
7+
{
8+
public class CityByState
9+
{
10+
public string Name { get; set; }
11+
public int ID { get; set; }
12+
public int StateID { get; set; }
13+
}
14+
}
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.ComponentModel.DataAnnotations;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace DevExtremeAspNetCoreApp1.Models
8+
{
9+
public class EmployeeByState
10+
{
11+
public int ID { get; set; }
12+
public string FirstName { get; set; }
13+
public string LastName { get; set; }
14+
public string Position { get; set; }
15+
public string Prefix { get; set; }
16+
17+
[Display(Name = "State")]
18+
public List<int> StateID { get; set; }
19+
20+
[Display(Name = "City")]
21+
public List<int> CityID { get; set; }
22+
}
23+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace DevExtremeAspNetCoreApp1.Models {
8+
static class SampleData {
9+
public static List<EmployeeByState> DataGridEmployeesByState = new List<EmployeeByState> {
10+
new EmployeeByState {
11+
ID = 1,
12+
FirstName = "John",
13+
LastName = "Heart",
14+
Prefix = "Mr.",
15+
Position = "CTO",
16+
StateID = new List<int> {1 },
17+
CityID = new List<int> {1 }
18+
}
19+
};
20+
21+
public static readonly List<State> StatesWithCities = new List<State> {
22+
new State {
23+
ID = 1,
24+
Name = "Alabama"
25+
},
26+
new State {
27+
ID = 2,
28+
Name = "Alaska"
29+
},
30+
new State {
31+
ID = 3,
32+
Name = "Arizona"
33+
},
34+
new State {
35+
ID = 4,
36+
Name = "Arkansas"
37+
},
38+
new State {
39+
ID = 5,
40+
Name = "California"
41+
}
42+
};
43+
44+
public static List<CityByState> CitiesByState = new List<CityByState> {
45+
new CityByState {
46+
ID = 1,
47+
Name = "Tuscaloosa",
48+
StateID = 1
49+
},
50+
new CityByState {
51+
ID = 2,
52+
Name = "Hoover",
53+
StateID = 1
54+
},
55+
new CityByState {
56+
ID = 3,
57+
Name = "Dothan",
58+
StateID = 1
59+
},
60+
new CityByState {
61+
ID = 4,
62+
Name = "Decatur",
63+
StateID = 1
64+
},
65+
new CityByState {
66+
ID = 5,
67+
Name = "Anchorage",
68+
StateID = 2
69+
},
70+
new CityByState {
71+
ID = 6,
72+
Name = "Fairbanks",
73+
StateID = 2
74+
},
75+
new CityByState {
76+
ID = 7,
77+
Name = "Juneau",
78+
StateID = 2
79+
},
80+
new CityByState {
81+
ID = 8,
82+
Name = "Avondale",
83+
StateID = 3
84+
},
85+
new CityByState {
86+
ID = 9,
87+
Name = "Buckeye",
88+
StateID = 3
89+
},
90+
new CityByState {
91+
ID = 10,
92+
Name = "Carefree",
93+
StateID = 3
94+
},
95+
new CityByState {
96+
ID = 11,
97+
Name = "Springdale",
98+
StateID = 4
99+
},
100+
new CityByState {
101+
ID = 12,
102+
Name = "Rogers",
103+
StateID = 4
104+
},
105+
new CityByState {
106+
ID = 13,
107+
Name = "Sherwood",
108+
StateID = 4
109+
},
110+
new CityByState {
111+
ID = 14,
112+
Name = "Jacksonville",
113+
StateID = 4
114+
},
115+
new CityByState {
116+
ID = 15,
117+
Name = "Cabot",
118+
StateID = 4
119+
},
120+
new CityByState {
121+
ID = 16,
122+
Name = "Adelanto",
123+
StateID = 5
124+
},
125+
new CityByState {
126+
ID = 17,
127+
Name = "Glendale",
128+
StateID = 5
129+
},
130+
new CityByState {
131+
ID = 18,
132+
Name = "Moorpark",
133+
StateID = 5
134+
},
135+
new CityByState {
136+
ID = 19,
137+
Name = "Needles",
138+
StateID = 5
139+
},
140+
new CityByState {
141+
ID = 20,
142+
Name = "Ontario",
143+
StateID = 5
144+
}
145+
};
146+
}
147+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace DevExtremeAspNetCoreApp1.Models {
8+
public class SampleOrder {
9+
public int OrderID { get; set; }
10+
public DateTime OrderDate { get; set; }
11+
public string CustomerID { get; set; }
12+
public string CustomerName { get; set; }
13+
public string ShipCountry { get; set; }
14+
public string ShipCity { get; set; }
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace DevExtremeAspNetCoreApp1.Models
7+
{
8+
public class State
9+
{
10+
public int ID { get; set; }
11+
public string Name { get; set; }
12+
}
13+
}

0 commit comments

Comments
 (0)