Skip to content

Commit 55a6ff9

Browse files
Fix: ASP.NET Core implementation, lint, and build to v25.1.3
1 parent 0d2ff57 commit 55a6ff9

22 files changed

+5079
-5714
lines changed

ASP.NET Core/ASP.NET Core.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
</Target>
2121

2222
<ItemGroup>
23-
<PackageReference Include="DevExtreme.AspNet.Core" Version="25.1.*" />
23+
<PackageReference Include="DevExtreme.AspNet.Core" Version="25.1.3" />
24+
<PackageReference Include="DevExtreme.AspNet.Data" Version="5.1.0" />
2425
</ItemGroup>
2526

2627
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using DevExtreme.AspNet.Data;
2+
using DevExtreme.AspNet.Mvc;
3+
using Microsoft.AspNetCore.Mvc;
4+
using ASP_NET_Core.Models;
5+
6+
namespace ASP_NET_Core.Controllers;
7+
8+
public class CustomersController : Controller {
9+
[HttpGet]
10+
public object GetCustomers(DataSourceLoadOptions loadOptions) {
11+
return DataSourceLoader.Load(CustomersData.Customers, loadOptions);
12+
}
13+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.Linq;
2+
using DevExtreme.AspNet.Data;
3+
using DevExtreme.AspNet.Mvc;
4+
using Microsoft.AspNetCore.Mvc;
5+
using ASP_NET_Core.Models;
6+
using System.Text.Json;
7+
8+
namespace ASP_NET_Core.Controllers {
9+
public class EmployeesController: Controller {
10+
[HttpGet]
11+
public object GetEmployees(DataSourceLoadOptions loadOptions) {
12+
return DataSourceLoader.Load(EmployeesData.Employees, loadOptions);
13+
}
14+
15+
[HttpPost]
16+
public IActionResult InsertEmployee(string values) {
17+
var newItem = JsonSerializer.Deserialize<Employee>(values);
18+
if(newItem == null) return BadRequest();
19+
20+
var nextId = EmployeesData.Employees.Any() ? EmployeesData.Employees.Max(e => e.ID) + 1 : 1;
21+
newItem.ID = nextId;
22+
EmployeesData.Employees.Add(newItem);
23+
24+
return Ok(new { ID = newItem.ID });
25+
}
26+
27+
[HttpPut]
28+
public IActionResult UpdateEmployee(int key, string values) {
29+
var item = EmployeesData.Employees.FirstOrDefault(e => e.ID == key);
30+
if(item == null) return NotFound();
31+
32+
var updated = JsonSerializer.Deserialize<Employee>(values);
33+
if(updated == null) return BadRequest();
34+
35+
item.CustomerID = updated.CustomerID;
36+
item.Address = updated.Address;
37+
item.Phone = updated.Phone;
38+
39+
return Ok();
40+
}
41+
42+
[HttpDelete]
43+
public IActionResult DeleteEmployee(int key) {
44+
var item = EmployeesData.Employees.FirstOrDefault(e => e.ID == key);
45+
if(item == null) return NotFound();
46+
47+
EmployeesData.Employees.Remove(item);
48+
return Ok();
49+
}
50+
51+
[HttpGet]
52+
public object GetCustomers(DataSourceLoadOptions loadOptions) {
53+
return DataSourceLoader.Load(CustomersData.Customers, loadOptions);
54+
}
55+
}
56+
}

ASP.NET Core/Controllers/SampleDataController.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

ASP.NET Core/Models/Customer.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace ASP_NET_Core.Models;
4+
public class Customer {
5+
public int CustomerID { get; set; }
6+
public string CustomerName { get; set; }
7+
public string Address { get; set; }
8+
public string Phone { get; set; }
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
3+
namespace ASP_NET_Core.Models;
4+
public static class CustomersData {
5+
public static List<Customer> Customers = new List<Customer> {
6+
new Customer { CustomerID = 1, CustomerName = "Kaela Phonix", Address = "Markušica", Phone = "+385 674 958 1641" },
7+
new Customer { CustomerID = 2, CustomerName = "Dotty Hearnden", Address = "Itaberaí", Phone = "+55 491 329 4084" },
8+
new Customer { CustomerID = 3, CustomerName = "Alasdair Greenin", Address = "Volgograd", Phone = "+7 657 495 7659" },
9+
new Customer { CustomerID = 4, CustomerName = "Stoddard Laidlaw", Address = "Shuiyin", Phone = "+86 774 746 9874" },
10+
new Customer { CustomerID = 5, CustomerName = "Damiano Gencke", Address = "Baturaden", Phone = "+62 113 149 9397" },
11+
new Customer { CustomerID = 6, CustomerName = "Aura Bavidge", Address = "New York City", Phone = "+1 917 528 7751" },
12+
new Customer { CustomerID = 7, CustomerName = "Emmanuel Chedgey", Address = "Adolfo Lopez Mateos", Phone = "+52 626 244 6757" },
13+
new Customer { CustomerID = 8, CustomerName = "Clerkclaude Pargeter", Address = "Nong Khae", Phone = "+66 326 375 8694" },
14+
new Customer { CustomerID = 9, CustomerName = "Onfroi Cinnamond", Address = "Znamenskoye", Phone = "+7 926 141 2517" },
15+
new Customer { CustomerID = 10, CustomerName = "Madlin Kopke", Address = "Patpata Segundo", Phone = "+63 428 750 7737" },
16+
new Customer { CustomerID = 11, CustomerName = "Mortie Feary", Address = "Fontanka", Phone = "+380 557 509 4191" },
17+
new Customer { CustomerID = 12, CustomerName = "Colet Haitlie", Address = "Novosil'", Phone = "+7 493 632 2768" },
18+
new Customer { CustomerID = 13, CustomerName = "Pippy Carnell", Address = "Ubinskoye", Phone = "+7 954 353 8930" },
19+
new Customer { CustomerID = 14, CustomerName = "Arvie Midden", Address = "Protvino", Phone = "+7 386 362 2407" },
20+
new Customer { CustomerID = 15, CustomerName = "Brook Kamena", Address = "Santa Fé do Sul", Phone = "+55 867 691 7097" }
21+
};
22+
}

ASP.NET Core/Models/Employee.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace ASP_NET_Core.Models;
4+
public class Employee {
5+
public int ID { get; set; }
6+
public int CustomerID { get; set; }
7+
public string Address { get; set; }
8+
public string Phone { get; set; }
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
3+
namespace ASP_NET_Core.Models;
4+
public static class EmployeesData {
5+
public static List<Employee> Employees = new List<Employee> {
6+
new Employee { ID = 1, CustomerID = 1, Address = "Markušica", Phone = "+385 674 958 1641" },
7+
new Employee { ID = 2, CustomerID = 2, Address = "Itaberaí", Phone = "+55 491 329 4084" },
8+
new Employee { ID = 3, CustomerID = 3, Address = "Volgograd", Phone = "+7 745 619 7799" },
9+
new Employee { ID = 4, CustomerID = 4, Address = "Shuiyin", Phone = "+86 774 746 9874" },
10+
new Employee { ID = 5, CustomerID = 5, Address = "Baturaden", Phone = "+62 113 149 9397" },
11+
new Employee { ID = 6, CustomerID = 6, Address = "New York City", Phone = "+1 917 528 7751" },
12+
new Employee { ID = 7, CustomerID = 7, Address = "Adolfo Lopez Mateos", Phone = "+52 626 244 6757" },
13+
new Employee { ID = 8, CustomerID = 8, Address = "Nong Khae", Phone = "+66 326 375 8694" },
14+
new Employee { ID = 9, CustomerID = 9, Address = "Znamenskoye", Phone = "+7 926 141 2517" },
15+
new Employee { ID = 10, CustomerID = 10, Address = "Patpata Segundo", Phone = "+63 428 750 7737" },
16+
new Employee { ID = 11, CustomerID = 11, Address = "Fontanka", Phone = "+380 557 509 4191" },
17+
new Employee { ID = 12, CustomerID = 12, Address = "Novosil'", Phone = "+7 493 632 2768" },
18+
new Employee { ID = 13, CustomerID = 13, Address = "Ubinskoye", Phone = "+7 954 353 8930" },
19+
new Employee { ID = 14, CustomerID = 14, Address = "Protvino", Phone = "+7 386 362 2407" },
20+
new Employee { ID = 15, CustomerID = 15, Address = "Santa Fé do Sul", Phone = "+55 867 691 7097" }
21+
};
22+
}

0 commit comments

Comments
 (0)