Skip to content

Commit

Permalink
Merge pull request #6 from DevExpress-Examples/ASP-example
Browse files Browse the repository at this point in the history
ASP.NET example
  • Loading branch information
16adianay authored Dec 25, 2023
2 parents 46347a0 + a7348af commit 552ef19
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 389 deletions.
4 changes: 2 additions & 2 deletions ASP.NET Core/ASP.NET Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</Exec>
</Target>
<ItemGroup>
<PackageReference Include="DevExtreme.AspNet.Data" Version="2.*" />
<PackageReference Include="DevExtreme.AspNet.Core" Version="23.1.*" />
<PackageReference Include="DevExtreme.AspNet.Data" Version="3.0.0" />
<PackageReference Include="DevExtreme.AspNet.Core" Version="23.2.3" />
</ItemGroup>

<ProjectExtensions>
Expand Down
22 changes: 19 additions & 3 deletions ASP.NET Core/Controllers/SampleDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,36 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.CompilerServices;
using ASP_NET_Core.Models;
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace ASP_NET_Core.Controllers {

[Route("api/[controller]")]
[Route("api/[controller]/[action]")]
public class SampleDataController : Controller {

[HttpGet]
public object Get(DataSourceLoadOptions loadOptions) {
return DataSourceLoader.Load(SampleData.Orders, loadOptions);
return DataSourceLoader.Load(SampleData.Customers, loadOptions);
}
[HttpPut]
public IActionResult Put(int key, string values)
{

var item = SampleData.Customers.First(e => e.ID == key);

JsonConvert.PopulateObject(values, item);

if (!TryValidateModel(item))
return BadRequest(ModelState);

return Ok(item);
}
}
}
Loading

0 comments on commit 552ef19

Please sign in to comment.