Skip to content

Commit

Permalink
Merge pull request #5 from DevExpress-Examples/ASP.NET-example
Browse files Browse the repository at this point in the history
ASP.NET Example
  • Loading branch information
16adianay committed Jan 30, 2024
2 parents a3bdf32 + eb6c54b commit 2236b43
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 381 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="2.8.0" />
<PackageReference Include="DevExtreme.AspNet.Core" Version="23.1.3" />
</ItemGroup>

<ProjectExtensions>
Expand Down
17 changes: 16 additions & 1 deletion ASP.NET Core/Controllers/SampleDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;

namespace ASP_NET_Core.Controllers {

Expand All @@ -15,7 +16,21 @@ public class SampleDataController : Controller {

[HttpGet]
public object Get(DataSourceLoadOptions loadOptions) {
return DataSourceLoader.Load(SampleData.Orders, loadOptions);
return DataSourceLoader.Load(SampleData.Employees, loadOptions);
}

[HttpPut]
public IActionResult Put(int key, string values)
{

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

JsonConvert.PopulateObject(values, item);

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

return Ok(item);
}

}
Expand Down
Loading

0 comments on commit 2236b43

Please sign in to comment.