Skip to content

Commit

Permalink
update files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohirjon-Odilov committed Mar 5, 2024
1 parent d9af4c2 commit 2ac5f99
Show file tree
Hide file tree
Showing 11 changed files with 375 additions and 3 deletions.
36 changes: 36 additions & 0 deletions Exam.StockManagement.API/Data/ProductSeedData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Exam.StockManagement.Domain.Entities.Models;
using Exam.StockManagement.Infrastructure.Persistance;

namespace Exam.StockManagement.API.Data
{
public static class ProductSeedData
{
public static async Task InitiliazeDataAsync(this IServiceProvider serviceProvider)
{
var db = serviceProvider.GetRequiredService<StockManagementDbContext>();
if (!db.Products.Any())
{
List<Product> transports = [
new Product
{
ProductName = "Asus TUF Gaming A17",
ProductDescription = "AMD Ryzen™ 7 6800H",
ProductPrice = 1200,
ProductPicture = @"\images\51ZOFgc-4yL._AC_UF894,1000_QL80_.jpg",
CreatedAt = DateTime.UtcNow,
},
new Product
{
ProductName = "Lenovo Legion 5 Pro",
ProductDescription = "16ith6 i7-11800H 16/512GB SSD RTX3050-4GB 16",
ProductPrice = 20,
ProductPicture = @"\images\",
CreatedAt = DateTime.UtcNow,
}
];
db.Products.AddRange(transports);
await db.SaveChangesAsync();
}
}
}
}
1 change: 1 addition & 0 deletions Exam.StockManagement.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static void Main(string[] args)
app.UseSwaggerUI();
}

AsyncServiceScope scope = app.Services.CreateAsyncScope();
app.UseStaticFiles();

app.UseHttpsRedirection();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Exam.StockManagement.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class update1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ProductName",
table: "Products",
type: "character varying(100)",
maxLength: 100,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(30)",
oldMaxLength: 30);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ProductName",
table: "Products",
type: "character varying(30)",
maxLength: 30,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(100)",
oldMaxLength: 100);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Exam.StockManagement.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class less : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{

}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{

}
}
}
Loading

0 comments on commit 2ac5f99

Please sign in to comment.