Add orchestration enrollment samples

This commit is contained in:
fiodarsazanavets
2026-02-07 12:16:49 +00:00
parent e8d6decd1a
commit 21f54adbcc
158 changed files with 121203 additions and 1 deletions
@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace OnlineShop.ApiService.Model;
public class Product
{
[Key]
public int Id { get; set; }
[MaxLength(100)]
public string Title { get; set; } = string.Empty;
[MaxLength(2100)]
public string Summary { get; set; } = string.Empty;
public decimal Price { get; set; }
public DateTime DateAdded { get; set; }
}
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\OnlineShop.ServiceDefaults\OnlineShop.ServiceDefaults.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.2" />
</ItemGroup>
</Project>
@@ -0,0 +1,6 @@
@ApiService_HostAddress = http://localhost:5579
GET {{ApiService_HostAddress}}/weatherforecast/
Accept: application/json
###
@@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;
using OnlineShop.ApiService.Model;
namespace OnlineShop.ApiService;
public class ProductsDbContext : DbContext
{
public ProductsDbContext(
DbContextOptions<ProductsDbContext> options) : base(options)
{
}
public DbSet<Product> Products { get; set; }
}
@@ -0,0 +1,125 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using OnlineShop.ApiService;
using OnlineShop.ApiService.Model;
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Services.AddProblemDetails();
builder.Services.AddOpenApi();
builder.Services.AddDbContext<ProductsDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("sqldb")));
var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var context = scope
.ServiceProvider
.GetRequiredService<ProductsDbContext>();
context.Database.EnsureCreated();
if (!context.Products.Any())
{
var products = new List<Product>
{
new Product
{
Title = "Wireless Optical Mouse",
Summary = "Ergonomic wireless optical mouse with adjustable DPI and long battery life, suitable for everyday office and home use.",
Price = 24.99m,
DateAdded = new DateTime(2025, 1, 5)
},
new Product
{
Title = "Mechanical Gaming Keyboard",
Summary = "RGB backlit mechanical keyboard with blue switches, anti-ghosting keys, and durable aluminum frame.",
Price = 129.99m,
DateAdded = new DateTime(2025, 1, 6)
},
new Product
{
Title = "27-inch 4K Monitor",
Summary = "27-inch UHD 4K monitor with IPS panel, 3840x2160 resolution, HDR support, and ultra-thin bezels.",
Price = 399.00m,
DateAdded = new DateTime(2025, 1, 7)
},
new Product
{
Title = "USB-C Docking Station",
Summary = "Multi-port USB-C docking station with HDMI, DisplayPort, Ethernet, USB 3.0 ports, and 100W power delivery.",
Price = 179.50m,
DateAdded = new DateTime(2025, 1, 8)
},
new Product
{
Title = "External SSD 1TB",
Summary = "Portable 1TB external SSD with USB 3.2 Gen 2 support, delivering fast read/write speeds in a compact design.",
Price = 149.99m,
DateAdded = new DateTime(2025, 1, 9)
},
new Product
{
Title = "Noise-Cancelling Headphones",
Summary = "Over-ear wireless headphones with active noise cancellation, high-fidelity sound, and 30-hour battery life.",
Price = 249.00m,
DateAdded = new DateTime(2025, 1, 10)
},
new Product
{
Title = "Webcam Full HD 1080p",
Summary = "Full HD 1080p webcam with built-in microphone, autofocus, and low-light correction for video conferencing.",
Price = 69.99m,
DateAdded = new DateTime(2025, 1, 11)
},
new Product
{
Title = "Gaming Laptop Backpack",
Summary = "Water-resistant backpack designed for gaming laptops up to 17 inches, featuring padded compartments and USB charging port.",
Price = 59.95m,
DateAdded = new DateTime(2025, 1, 12)
},
new Product
{
Title = "Wi-Fi 6 Router",
Summary = "Dual-band Wi-Fi 6 router offering high-speed wireless connectivity, improved range, and support for multiple devices.",
Price = 199.00m,
DateAdded = new DateTime(2025, 1, 13)
},
new Product
{
Title = "Portable Laser Printer",
Summary = "Compact monochrome laser printer suitable for small offices, offering fast printing speeds and wireless connectivity.",
Price = 289.99m,
DateAdded = new DateTime(2025, 1, 14)
}
};
context.Products.AddRange(products);
context.SaveChanges();
}
}
app.UseExceptionHandler();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.MapGet("/", () => "API service is running.");
app.MapGet("/products",
([FromServices] ProductsDbContext context) =>
{
return context.Products.ToArray();
});
app.MapDefaultEndpoints();
app.Run();
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5579",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7465;http://localhost:5579",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}