Skip to content

Commit 08fe338

Browse files
add new project
1 parent 02a34d5 commit 08fe338

18 files changed

+5494
-0
lines changed

ASP.NET Core/ASP.NET Core.csproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<Target Name="DebugEnsureNodeEnv" BeforeTargets="BeforeBuild" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
8+
<!-- Ensure Node.js is installed -->
9+
<Exec Command="node --version" ContinueOnError="true">
10+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
11+
</Exec>
12+
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
13+
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
14+
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
15+
</Target>
16+
<Target Name="RunGulp" BeforeTargets="BeforeBuild" Condition=" '$(Configuration)' == 'Debug' And Exists('$(SpaRoot)node_modules') ">
17+
<Exec WorkingDirectory="$(ProjectDir)" Command="node_modules\.bin\gulp add-resources" ContinueOnError="false">
18+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
19+
</Exec>
20+
</Target>
21+
22+
<ItemGroup>
23+
<PackageReference Include="DevExtreme.AspNet.Core" Version="25.1.3" />
24+
</ItemGroup>
25+
26+
</Project>

ASP.NET Core/ASP.NET Core.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30330.147
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASP.NET Core", "ASP.NET Core.csproj", "{435CB7A8-3168-4BD2-815F-E54F708AF968}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{435CB7A8-3168-4BD2-815F-E54F708AF968}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{435CB7A8-3168-4BD2-815F-E54F708AF968}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{435CB7A8-3168-4BD2-815F-E54F708AF968}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{435CB7A8-3168-4BD2-815F-E54F708AF968}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {08AFB133-D1F6-4FE9-A66A-586B96B002D0}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace ASP_NET_Core.Controllers
8+
{
9+
public class HomeController : Controller
10+
{
11+
public IActionResult Index()
12+
{
13+
return View();
14+
}
15+
16+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
17+
public IActionResult Error() {
18+
return View();
19+
}
20+
}
21+
}

ASP.NET Core/Models/Address.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace ASP_NET_Core.Models
7+
{
8+
public class Address
9+
{
10+
public int? StateID { get; set; }
11+
public int? CityID { get; set; }
12+
13+
public static readonly Address Empty = new Address();
14+
}
15+
}

ASP.NET Core/Models/City.cs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ASP_NET_Core.Models {
8+
public class City
9+
{
10+
public int ID { get; set; }
11+
public int StateID { get; set; }
12+
public string Name { get; set; }
13+
14+
public static City[] Cities = [
15+
new City() {
16+
ID = 1,
17+
Name = "Tuscaloosa",
18+
StateID = 1
19+
}, new City() {
20+
ID = 2,
21+
Name = "Hoover",
22+
StateID = 1
23+
}, new City() {
24+
ID = 3,
25+
Name = "Dothan",
26+
StateID = 1
27+
}, new City() {
28+
ID = 4,
29+
Name = "Decatur",
30+
StateID = 1
31+
}, new City() {
32+
ID = 5,
33+
Name = "Anchorage",
34+
StateID = 2
35+
}, new City() {
36+
ID = 6,
37+
Name = "Fairbanks",
38+
StateID = 2
39+
}, new City() {
40+
ID = 7,
41+
Name = "Juneau",
42+
StateID = 2
43+
}, new City() {
44+
ID = 8,
45+
Name = "Avondale",
46+
StateID = 3
47+
}, new City() {
48+
ID = 9,
49+
Name = "Buckeye",
50+
StateID = 3
51+
}, new City() {
52+
ID = 10,
53+
Name = "Carefree",
54+
StateID = 3
55+
}, new City() {
56+
ID = 11,
57+
Name = "Springdale",
58+
StateID = 4
59+
}, new City() {
60+
ID = 12,
61+
Name = "Rogers",
62+
StateID = 4
63+
}, new City() {
64+
ID = 13,
65+
Name = "Sherwood",
66+
StateID = 4
67+
}, new City() {
68+
ID = 14,
69+
Name = "Jacksonville",
70+
StateID = 4
71+
}, new City() {
72+
ID = 15,
73+
Name = "Cabot",
74+
StateID = 4
75+
}, new City() {
76+
ID = 16,
77+
Name = "Adelanto",
78+
StateID = 5
79+
}, new City() {
80+
ID = 17,
81+
Name = "Glendale",
82+
StateID = 5
83+
}, new City() {
84+
ID = 18,
85+
Name = "Moorpark",
86+
StateID = 5
87+
}, new City() {
88+
ID = 19,
89+
Name = "Needles",
90+
StateID = 5
91+
}, new City() {
92+
ID = 20,
93+
Name = "Ontario",
94+
StateID = 5
95+
}
96+
];
97+
}
98+
}

ASP.NET Core/Models/State.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ASP_NET_Core.Models {
8+
public class State
9+
{
10+
public int ID { get; set; }
11+
public string Name { get; set; }
12+
13+
public static State[] States = [
14+
new State() {
15+
ID = 1,
16+
Name = "Alabama"
17+
},
18+
new State() {
19+
ID = 2,
20+
Name = "Alaska"
21+
},
22+
new State() {
23+
ID = 3,
24+
Name = "Arizona"
25+
},
26+
new State() {
27+
ID = 4,
28+
Name = "Arkansas"
29+
},
30+
new State() {
31+
ID = 5,
32+
Name = "California"
33+
}
34+
];
35+
}
36+
}

ASP.NET Core/Program.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.Extensions.Hosting;
4+
5+
namespace ASP_NET_Core {
6+
public class Program {
7+
public static void Main(string[] args) {
8+
var builder = WebApplication.CreateBuilder(args);
9+
10+
// Add services to the container.
11+
builder.Services
12+
.AddControllersWithViews()
13+
.AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
14+
15+
var app = builder.Build();
16+
17+
// Configure the HTTP request pipeline.
18+
if (app.Environment.IsDevelopment()) {
19+
app.UseDeveloperExceptionPage();
20+
} else {
21+
app.UseExceptionHandler("/Home/Error");
22+
}
23+
24+
app.UseStaticFiles();
25+
26+
app.UseRouting();
27+
28+
app.UseAuthorization();
29+
30+
app.MapControllerRoute(
31+
name: "default",
32+
pattern: "{controller=Home}/{action=Index}/{id?}"
33+
);
34+
35+
app.Run();
36+
}
37+
}
38+
}

ASP.NET Core/Readme.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# ASP.NET Core DevExtreme Example
2+
3+
## Installation
4+
5+
Download the example and use Visual Studio 2022 (or later) or Visual Studio Code to open the project. This project targets .NET 8.0.
6+
7+
## Client-side resources and bundling
8+
9+
This project uses [NPM](https://www.npmjs.com/) and [Gulp.js](https://gulpjs.com/) to install client-side libraries. The project restores NPM packages before the first build. Then, Gulp bundles required scripts and CSS files into the resulting package during the first and every next build.
10+
11+
The project includes:
12+
- DevExtreme 24.2.3
13+
- DevExtreme.AspNet.Core 24.2.*
14+
- DevExtreme.AspNet.Data 5.*
15+
- jQuery 3.7.1
16+
- Bootstrap 5.3.3
17+
18+
The resulted bundles will be located in the `wwwroot` folder:
19+
* `css/vendor.css` - a file with all CSS styles.
20+
* `css/icons` and `css/fonts` - folders that contain fonts and icons for DevExtreme themes.
21+
* `js/vendor.js` - a file that contains all scripts.
22+
23+
The default bundle includes jQuery, Bootstrap, and DevExtreme.
24+
25+
### Add more 3rd-party libraries for additional features/components
26+
27+
The main logic is located in the the `gulpfile.js` file at the root application level. The file contains two tasks:
28+
29+
* the `add-resources` task
30+
31+
* copies JavaScript files located in the `scripts` array and adds them to `vendor.js`. The script bundle is moved to `wwwroot\js`.
32+
* copies CSS styles located in the `styles` array and merges them into the `vendor.css` bundle. Then, this bundle is moved to `wwwroot\css`
33+
* copies DevExtreme `fonts` and `icons` folders from NPM to `wwwroot\css`
34+
35+
* the `clean` task removes all previously created files (`vendor.js` and `vendor.css`) and folders (`icons` and `fonts`)
36+
37+
If you need to include more features, you can uncomment one of the following sections:
38+
39+
* Gantt - scripts and styles for [dxGantt](https://js.devexpress.com/DevExtreme/Guide/UI_Components/Gantt/Getting_Started_with_Gantt/).
40+
* Diagram - scripts and styles for [dxDiagram](https://js.devexpress.com/DevExtreme/Guide/UI_Components/Diagram/Getting_Started_with_Diagram/).
41+
* Export - scripts and styles for the exporting feature: [Export Data to Excel](https://js.devexpress.com/DevExtreme/Guide/UI_Components/DataGrid/Getting_Started_with_DataGrid/#Export_Data).
42+
* HtmlEditor - scripts and styles for [dxHtmlEditor](https://js.devexpress.com/DevExtreme/Guide/UI_Components/HtmlEditor/Overview/).
43+
* Full Bundle - scripts and styles for all above mentioned features/components.
44+
45+
## Code
46+
47+
Take a look at the following files of this example to see the required code:
48+
49+
**Controllers:**
50+
- `Controllers/HomeController.cs` - Main controller with Index action
51+
- `Controllers/SampleDataController.cs` - API controller for sample data
52+
53+
**Models:**
54+
- `Models/SampleData.cs` - Sample data model
55+
- `Models/SampleOrder.cs` - Sample order model
56+
57+
**Views:**
58+
- `Views/Home/Index.cshtml` - Main page with DevExtreme components
59+
- `Views/Shared/_Layout.cshtml` - Layout template
60+
- `Views/_ViewImports.cshtml` - Global imports
61+
- `Views/_ViewStart.cshtml` - View start configuration
62+
63+
**Configuration:**
64+
- `Program.cs` - Application entry point
65+
- `Startup.cs` - Service configuration
66+
- `gulpfile.js` - Build automation
67+
- `package.json` - NPM dependencies
68+
- `ASP.NET Core.csproj` - Project file
69+
70+
## Development server
71+
72+
Use the Visual Studio `Run (F5)` command or `dotnet run` command to run the project. The application will be available at `https://localhost:5001` (HTTPS) or `http://localhost:5000` (HTTP).
73+
74+
## Further help
75+
76+
You can learn more about the ASP.NET Core components' syntax in our documentation: [Concepts](https://docs.devexpress.com/AspNetCore/400574/devextreme-based-controls/concepts/razor-syntax)
77+
The client-side API is based on jQuery [jQuery documentation](https://api.jquery.com/) and described in the following topics:
78+
* [Get and Set Properties](https://js.devexpress.com/DevExtreme/Guide/jQuery_Components/Component_Configuration_Syntax/#Get_and_Set_Properties)
79+
* [Call Methods](https://js.devexpress.com/DevExtreme/Guide/jQuery_Components/Component_Configuration_Syntax/#Call_Methods)
80+
* [Get a UI Component Instance](https://js.devexpress.com/DevExtreme/Guide/jQuery_Components/Component_Configuration_Syntax/#Get_a_UI_Component_Instance)
81+
82+
To get more help on DevExtreme submit an issue in the [Support Center](https://supportcenter.devexpress.com/ticket/create)
83+
84+

0 commit comments

Comments
 (0)