Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP.NET example #6

Merged
merged 2 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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