Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29609.76
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataSourceWebApi", "DataSourceWebApi\DataSourceWebApi.csproj", "{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {27F7ABDC-D458-45A5-A739-2636294BC692}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29609.76
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataSourceWebApi", "DataSourceWebApi\DataSourceWebApi.csproj", "{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A97F255-301C-4FDD-AA89-D50EFC9F0BD9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {27F7ABDC-D458-45A5-A739-2636294BC692}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Cors;
using DevExtreme.AspNet.Mvc;
using DevExtreme.AspNet.Data;
using System.IO;
using DataSourceWebApi.Models;
using DataSourceWebApi.Services;
namespace DataSourceWebApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
[EnableCors("AllowAll")]
public class ProductsController : ControllerBase
{
private readonly ExportHelper _eh;
private readonly NWINDContext _context;
public ProductsController(NWINDContext context, ExportHelper eh) {
_context = context;
_eh = eh;
}
// GET: api/Products
[HttpGet]
public object Products(DataSourceLoadOptions loadOptions) {
return DataSourceLoader.Load(_context.Products, loadOptions);
}
[HttpGet]
public async Task<ActionResult> ExportedDocument(DataSourceLoadOptions loadOptions, string format) {
loadOptions.Skip = 0;
loadOptions.Take = 0;
byte[] content = await _eh.ExportResult(DataSourceLoader.Load(_context.Products.ToList(), loadOptions), format);
string fileName = "DataGrid." + format;
string mimeType = "application/octet-stream";
return new FileStreamResult(new MemoryStream(content), mimeType) {
FileDownloadName = fileName
};
}
}
}
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Cors;
using DevExtreme.AspNet.Mvc;
using DevExtreme.AspNet.Data;
using System.IO;
using DataSourceWebApi.Models;
using DataSourceWebApi.Services;

namespace DataSourceWebApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
[EnableCors("AllowAll")]
public class ProductsController : ControllerBase
{
private readonly ExportHelper _eh;
private readonly NWINDContext _context;

public ProductsController(NWINDContext context, ExportHelper eh) {
_context = context;
_eh = eh;
}

// GET: api/Products
[HttpGet]
public object Products(DataSourceLoadOptions loadOptions) {
return DataSourceLoader.Load(_context.Products, loadOptions);
}

[HttpGet]
public async Task<ActionResult> ExportedDocument(DataSourceLoadOptions loadOptions, string format) {
loadOptions.Skip = 0;
loadOptions.Take = 0;
byte[] content = await _eh.ExportResult(DataSourceLoader.Load(_context.Products.ToList(), loadOptions), format);
string fileName = "DataGrid." + format;
string mimeType = "application/octet-stream";
return new FileStreamResult(new MemoryStream(content), mimeType) {
FileDownloadName = fileName
};
}
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace DataSourceWebApi.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger) {
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get() {
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast {
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace DataSourceWebApi.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger) {
_logger = logger;
}

[HttpGet]
public IEnumerable<WeatherForecast> Get() {
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast {
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Reporting.Core" Version="20.2.5" />
<PackageReference Include="DevExtreme.AspNet.Core" Version="20.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
<PackageReference Include="DevExtreme.AspNet.Data" Version="2.7.2" />
</ItemGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties DismissedDevExtremeVersion="20.1.8" />
</VisualStudio>
</ProjectExtensions>
</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Reporting.Core" Version="20.2.5" />
<PackageReference Include="DevExtreme.AspNet.Core" Version="20.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
<PackageReference Include="DevExtreme.AspNet.Data" Version="2.7.2" />
</ItemGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties DismissedDevExtremeVersion="20.1.8" />
</VisualStudio>
</ProjectExtensions>
</Project>
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace DataSourceWebApi.Models
{
public partial class NWINDContext : DbContext
{
public NWINDContext() {
}
public NWINDContext(DbContextOptions<NWINDContext> options)
: base(options) {
}
public virtual DbSet<Products> Products { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
if (!optionsBuilder.IsConfigured) {
optionsBuilder.UseSqlServer("Server=(local);Database=NWIND;User ID=XXX;Password=XXX;");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity<Products>(entity => {
entity.HasKey(e => e.ProductId);
entity.Property(e => e.ProductId).HasColumnName("ProductID");
entity.Property(e => e.CategoryId).HasColumnName("CategoryID");
entity.Property(e => e.Ean13)
.HasColumnName("EAN13")
.HasColumnType("text");
entity.Property(e => e.ProductName)
.IsRequired()
.HasMaxLength(40);
entity.Property(e => e.QuantityPerUnit).HasMaxLength(20);
entity.Property(e => e.SupplierId).HasColumnName("SupplierID");
entity.Property(e => e.UnitPrice).HasColumnType("smallmoney");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
}
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace DataSourceWebApi.Models
{
public partial class NWINDContext : DbContext
{
public NWINDContext() {
}

public NWINDContext(DbContextOptions<NWINDContext> options)
: base(options) {
}

public virtual DbSet<Products> Products { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
if (!optionsBuilder.IsConfigured) {
optionsBuilder.UseSqlServer("Server=(local);Database=NWIND;User ID=XXX;Password=XXX;");
}
}

protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity<Products>(entity => {
entity.HasKey(e => e.ProductId);

entity.Property(e => e.ProductId).HasColumnName("ProductID");

entity.Property(e => e.CategoryId).HasColumnName("CategoryID");

entity.Property(e => e.Ean13)
.HasColumnName("EAN13")
.HasColumnType("text");

entity.Property(e => e.ProductName)
.IsRequired()
.HasMaxLength(40);

entity.Property(e => e.QuantityPerUnit).HasMaxLength(20);

entity.Property(e => e.SupplierId).HasColumnName("SupplierID");

entity.Property(e => e.UnitPrice).HasColumnType("smallmoney");
});

OnModelCreatingPartial(modelBuilder);
}

partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
}
Loading
Loading