Skip to content

Commit da7bcc7

Browse files
Merge pull request #7 from DevExpress-Examples/fix-25.1.3
Fix CI in v25.1.3
2 parents b84712e + 249791b commit da7bcc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+28616
-64744
lines changed

ASP.NET Core/Controllers/SampleDataController.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,45 @@
77
using DevExtreme.AspNet.Data;
88
using DevExtreme.AspNet.Mvc;
99
using Microsoft.AspNetCore.Mvc;
10+
using System.Text.Json;
11+
using ASP_NET_Core.Utils;
1012

1113
namespace ASP_NET_Core.Controllers;
1214

13-
[Route("api/[controller]")]
15+
[Route("api/[controller]/[action]")]
1416
public class SampleDataController: Controller {
15-
1617
[HttpGet]
1718
public object Get(DataSourceLoadOptions loadOptions) {
18-
return DataSourceLoader.Load(SampleData.Orders, loadOptions);
19+
return DataSourceLoader.Load(SampleData.Sales, loadOptions);
20+
}
21+
22+
[HttpPost]
23+
public ActionResult InsertSale(string values) {
24+
var newSale = JsonSerializer.Deserialize<Sale>(values);
25+
newSale.OrderId = SampleData.Sales.Max(a => a.OrderId) + 1;
26+
SampleData.Sales.Add(newSale);
27+
28+
return Ok(true);
29+
}
30+
31+
[HttpPut]
32+
public ActionResult UpdateSale(int key, string values) {
33+
var sale = SampleData.Sales.Find(s => s.OrderId == key);
34+
if(sale != null) {
35+
sale.PopulateFromJson(values);
36+
}
37+
38+
return Ok(true);
1939
}
2040

41+
[HttpDelete]
42+
public ActionResult DeleteSale(int key) {
43+
Sale? sale = SampleData.Sales.Find(s => s.OrderId == key);
44+
45+
if(sale != null) {
46+
SampleData.Sales.Remove(sale);
47+
}
48+
49+
return Ok(true);
50+
}
2151
}

ASP.NET Core/Models/Sale.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace ASP_NET_Core.Models;
4+
5+
public class Sale
6+
{
7+
public int OrderId { get; set; }
8+
public string Region { get; set; } = string.Empty;
9+
public string Country { get; set; } = string.Empty;
10+
public string City { get; set; } = string.Empty;
11+
public int Amount { get; set; }
12+
public DateTime Date { get; set; }
13+
}

0 commit comments

Comments
 (0)