Skip to content

Commit

Permalink
Merge pull request #4 from JaloliddinDeveloper/users/JaloliddinDevelo…
Browse files Browse the repository at this point in the history
…per/data-add

DATA: Models & Migrate Video metadata
  • Loading branch information
JaloliddinDeveloper authored May 24, 2024
2 parents a160832 + afe3526 commit 32eee81
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 22 deletions.
11 changes: 11 additions & 0 deletions UsefulTime.Api/Brokers/Storages/IStorageBroker.VedioMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//=================================================
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
namespace UsefulTime.Api.Brokers.Storages
{
public partial interface IStorageBroker
{

}
}
10 changes: 10 additions & 0 deletions UsefulTime.Api/Brokers/Storages/IStorageBroker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//=================================================
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
namespace UsefulTime.Api.Brokers.Storages
{
public partial interface IStorageBroker
{ }

}
14 changes: 14 additions & 0 deletions UsefulTime.Api/Brokers/Storages/StorageBroker.VedioMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//=================================================
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
using Microsoft.EntityFrameworkCore;
using UsefulTime.Api.Models.VideoMetadatas;

namespace UsefulTime.Api.Brokers.Storages
{
public partial class StorageBroker
{
public DbSet<VideoMetadata> VideoMetadatas { get; set; }
}
}
27 changes: 27 additions & 0 deletions UsefulTime.Api/Brokers/Storages/StorageBroker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//=================================================
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
using EFxceptions;
using Microsoft.EntityFrameworkCore;

namespace UsefulTime.Api.Brokers.Storages
{
public partial class StorageBroker:EFxceptionsContext,IStorageBroker
{
private readonly IConfiguration configuration;

public StorageBroker(IConfiguration configuration)
{
this.configuration = configuration;
Database.Migrate();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string connectionString =
this.configuration.GetConnectionString("DefaultConnection");

Check warning on line 22 in UsefulTime.Api/Brokers/Storages/StorageBroker.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

optionsBuilder.UseSqlServer(connectionString);
}
}
}

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,39 @@
//=================================================
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
using System;
using Microsoft.EntityFrameworkCore.Migrations;


namespace UsefulTime.Api.Migrations
{

public partial class CreateAllTablesInitialize : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "VideoMetadatas",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
BlobPath = table.Column<string>(type: "nvarchar(max)", nullable: false),
Thubnail = table.Column<string>(type: "nvarchar(max)", nullable: false),
CreatedDate = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
UpdatedDate = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_VideoMetadatas", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "VideoMetadatas");
}
}
}
53 changes: 53 additions & 0 deletions UsefulTime.Api/Migrations/StorageBrokerModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using UsefulTime.Api.Brokers.Storages;

namespace UsefulTime.Api.Migrations
{
[DbContext(typeof(StorageBroker))]
partial class StorageBrokerModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "8.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("UsefulTime.Api.Models.VideoMetadatas.VideoMetadata", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("BlobPath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset>("CreatedDate")
.HasColumnType("datetimeoffset");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Thubnail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset>("UpdatedDate")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.ToTable("VideoMetadatas");
});
}
}
}
17 changes: 17 additions & 0 deletions UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//=================================================
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
namespace UsefulTime.Api.Models.VideoMetadatas
{
public class VideoMetadata
{
public Guid Id { get; set; }
public string Title { get; set; }

Check warning on line 10 in UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Title' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 10 in UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Title' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string Description { get; set; }

Check warning on line 11 in UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Description' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 11 in UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Description' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string BlobPath { get; set; }

Check warning on line 12 in UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'BlobPath' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 12 in UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'BlobPath' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string Thubnail { get; set; }

Check warning on line 13 in UsefulTime.Api/Models/VideoMetadatas/VideoMetadata.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Thubnail' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public DateTimeOffset CreatedDate { get; set; }
public DateTimeOffset UpdatedDate { get; set; }
}
}
44 changes: 27 additions & 17 deletions UsefulTime.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
var builder = WebApplication.CreateBuilder(args);
//=================================================
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
using UsefulTime.Api.Brokers.Storages;

// Add services to the container.
public class Program
{
private static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddControllers();

var app = builder.Build();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddTransient<IStorageBroker, StorageBroker>();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();
app.UseHttpsRedirection();

app.UseAuthorization();
app.UseAuthorization();

app.MapControllers();
app.MapControllers();

app.Run();
app.Run();
}
}
12 changes: 11 additions & 1 deletion UsefulTime.Api/UsefulTime.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EFxceptions" Version="0.4.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="RESTFulSense" Version="3.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions UsefulTime.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=UsefulMSDBCore;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down
14 changes: 10 additions & 4 deletions UsefulTime.Unit.Tests/UsefulTime.Unit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 32eee81

Please sign in to comment.