#28 and #29 and some messing with migrations ;)

This commit is contained in:
Hamid Reza Mohammadi 2020-11-06 11:49:07 +03:30
parent 391f4e756d
commit 9eaad8e40d
24 changed files with 397 additions and 10703 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,61 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class AudioFiles : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AudioFiles",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OwnerId = table.Column<Guid>(nullable: false),
GanjoorAudioId = table.Column<int>(nullable: false),
GanjoorPostId = table.Column<int>(nullable: false),
AudioOrder = table.Column<int>(nullable: false),
FileNameWithoutExtension = table.Column<string>(nullable: true),
SoundFilesFolder = table.Column<string>(nullable: true),
AudioTitle = table.Column<string>(nullable: true),
AudioArtist = table.Column<string>(nullable: true),
AudioArtistUrl = table.Column<string>(nullable: true),
AudioSrc = table.Column<string>(nullable: true),
AudioSrcUrl = table.Column<string>(nullable: true),
LegacyAudioGuid = table.Column<Guid>(nullable: false),
Mp3FileCheckSum = table.Column<string>(nullable: true),
Mp3SizeInBytes = table.Column<int>(nullable: false),
OggSizeInBytes = table.Column<int>(nullable: false),
UploadDate = table.Column<DateTime>(nullable: false),
ReviewDate = table.Column<DateTime>(nullable: false),
LocalMp3FilePath = table.Column<string>(nullable: true),
LocalXmlFilePath = table.Column<string>(nullable: true),
AudioSyncStatus = table.Column<int>(nullable: false),
ReviewStatus = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AudioFiles", x => x.Id);
table.ForeignKey(
name: "FK_AudioFiles_AspNetUsers_OwnerId",
column: x => x.OwnerId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_OwnerId",
table: "AudioFiles",
column: "OwnerId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AudioFiles");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class UploadNarration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "UploadSessions",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
SessionType = table.Column<int>(nullable: false),
UserId = table.Column<Guid>(nullable: true),
UseId = table.Column<Guid>(nullable: false),
UploadStartTime = table.Column<DateTime>(nullable: false),
UploadEndTime = table.Column<DateTime>(nullable: false),
ProcessStartTime = table.Column<DateTime>(nullable: false),
ProcessEndTime = table.Column<DateTime>(nullable: false),
ProcessProgress = table.Column<int>(nullable: false),
Status = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadSessions", x => x.Id);
table.ForeignKey(
name: "FK_UploadSessions_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserNarrationProfiles",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
UserId = table.Column<Guid>(nullable: false),
FileSuffixWithoutDash = table.Column<string>(nullable: true),
ArtistName = table.Column<string>(nullable: true),
ArtistUrl = table.Column<string>(nullable: true),
AudioSrc = table.Column<string>(nullable: true),
AudioSrcUrl = table.Column<string>(nullable: true),
IsDefault = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserNarrationProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserNarrationProfiles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UploadSessionFile",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ContentDisposition = table.Column<string>(nullable: true),
ContentType = table.Column<string>(nullable: true),
FileName = table.Column<string>(nullable: true),
Length = table.Column<long>(nullable: false),
Name = table.Column<string>(nullable: true),
FilePath = table.Column<string>(nullable: true),
MP3FileCheckSum = table.Column<string>(nullable: true),
ProcessResult = table.Column<bool>(nullable: false),
ProcessResultMsg = table.Column<string>(nullable: true),
UploadSessionId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadSessionFile", x => x.Id);
table.ForeignKey(
name: "FK_UploadSessionFile_UploadSessions_UploadSessionId",
column: x => x.UploadSessionId,
principalTable: "UploadSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_UploadSessionFile_UploadSessionId",
table: "UploadSessionFile",
column: "UploadSessionId");
migrationBuilder.CreateIndex(
name: "IX_UploadSessions_UserId",
table: "UploadSessions",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserNarrationProfiles_UserId",
table: "UserNarrationProfiles",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UploadSessionFile");
migrationBuilder.DropTable(
name: "UserNarrationProfiles");
migrationBuilder.DropTable(
name: "UploadSessions");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class UploadedFiles : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_UploadSessionFile_UploadSessions_UploadSessionId",
table: "UploadSessionFile");
migrationBuilder.DropPrimaryKey(
name: "PK_UploadSessionFile",
table: "UploadSessionFile");
migrationBuilder.RenameTable(
name: "UploadSessionFile",
newName: "UploadedFiles");
migrationBuilder.RenameIndex(
name: "IX_UploadSessionFile_UploadSessionId",
table: "UploadedFiles",
newName: "IX_UploadedFiles_UploadSessionId");
migrationBuilder.AlterColumn<Guid>(
name: "UploadSessionId",
table: "UploadedFiles",
nullable: false,
oldClrType: typeof(Guid),
oldType: "uniqueidentifier",
oldNullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_UploadedFiles",
table: "UploadedFiles",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UploadedFiles_UploadSessions_UploadSessionId",
table: "UploadedFiles",
column: "UploadSessionId",
principalTable: "UploadSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_UploadedFiles_UploadSessions_UploadSessionId",
table: "UploadedFiles");
migrationBuilder.DropPrimaryKey(
name: "PK_UploadedFiles",
table: "UploadedFiles");
migrationBuilder.RenameTable(
name: "UploadedFiles",
newName: "UploadSessionFile");
migrationBuilder.RenameIndex(
name: "IX_UploadedFiles_UploadSessionId",
table: "UploadSessionFile",
newName: "IX_UploadSessionFile_UploadSessionId");
migrationBuilder.AlterColumn<Guid>(
name: "UploadSessionId",
table: "UploadSessionFile",
type: "uniqueidentifier",
nullable: true,
oldClrType: typeof(Guid));
migrationBuilder.AddPrimaryKey(
name: "PK_UploadSessionFile",
table: "UploadSessionFile",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UploadSessionFile_UploadSessions_UploadSessionId",
table: "UploadSessionFile",
column: "UploadSessionId",
principalTable: "UploadSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class ReviewFields : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ReviewMsg",
table: "AudioFiles",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "ReviewerId",
table: "AudioFiles",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_ReviewerId",
table: "AudioFiles",
column: "ReviewerId");
migrationBuilder.AddForeignKey(
name: "FK_AudioFiles_AspNetUsers_ReviewerId",
table: "AudioFiles",
column: "ReviewerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AudioFiles_AspNetUsers_ReviewerId",
table: "AudioFiles");
migrationBuilder.DropIndex(
name: "IX_AudioFiles_ReviewerId",
table: "AudioFiles");
migrationBuilder.DropColumn(
name: "ReviewMsg",
table: "AudioFiles");
migrationBuilder.DropColumn(
name: "ReviewerId",
table: "AudioFiles");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,128 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorStructures : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "GanjoorPoets",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorPoets", x => x.Id);
});
migrationBuilder.CreateTable(
name: "GanjoorCategories",
columns: table => new
{
Id = table.Column<int>(nullable: false),
PoetId = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true),
ParentId = table.Column<int>(nullable: true),
UrlSlug = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorCategories", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorCategories_GanjoorCategories_ParentId",
column: x => x.ParentId,
principalTable: "GanjoorCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_GanjoorCategories_GanjoorPoets_PoetId",
column: x => x.PoetId,
principalTable: "GanjoorPoets",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GanjoorPoems",
columns: table => new
{
Id = table.Column<int>(nullable: false),
CatId = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true),
FullTitle = table.Column<string>(nullable: true),
UrlSlug = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorPoems", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorPoems_GanjoorCategories_CatId",
column: x => x.CatId,
principalTable: "GanjoorCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GanjoorVerses",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PoemId = table.Column<int>(nullable: false),
VOrder = table.Column<int>(nullable: false),
VersePosition = table.Column<int>(nullable: false),
Text = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorVerses", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorVerses_GanjoorPoems_PoemId",
column: x => x.PoemId,
principalTable: "GanjoorPoems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_GanjoorCategories_ParentId",
table: "GanjoorCategories",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorCategories_PoetId",
table: "GanjoorCategories",
column: "PoetId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoems_CatId",
table: "GanjoorPoems",
column: "CatId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorVerses_PoemId",
table: "GanjoorVerses",
column: "PoemId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GanjoorVerses");
migrationBuilder.DropTable(
name: "GanjoorPoems");
migrationBuilder.DropTable(
name: "GanjoorCategories");
migrationBuilder.DropTable(
name: "GanjoorPoets");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorCachingFields : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "FullUrl",
table: "GanjoorPoems",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "FullUrl",
table: "GanjoorCategories",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "FullUrl",
table: "GanjoorPoems");
migrationBuilder.DropColumn(
name: "FullUrl",
table: "GanjoorCategories");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorIndices : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "FullUrl",
table: "GanjoorPoems",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "FullUrl",
table: "GanjoorCategories",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoems_FullUrl",
table: "GanjoorPoems",
column: "FullUrl");
migrationBuilder.CreateIndex(
name: "IX_GanjoorCategories_FullUrl",
table: "GanjoorCategories",
column: "FullUrl");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_GanjoorPoems_FullUrl",
table: "GanjoorPoems");
migrationBuilder.DropIndex(
name: "IX_GanjoorCategories_FullUrl",
table: "GanjoorCategories");
migrationBuilder.AlterColumn<string>(
name: "FullUrl",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "FullUrl",
table: "GanjoorCategories",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
}
}
}

View File

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorPostIdIndex : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_GanjoorPostId",
table: "AudioFiles",
column: "GanjoorPostId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_AudioFiles_GanjoorPostId",
table: "AudioFiles");
}
}
}

View File

@ -10,8 +10,8 @@ using RMuseum.DbContext;
namespace RMuseum.Migrations
{
[DbContext(typeof(RMuseumDbContext))]
[Migration("20201025094846_GanjoorPostIdIndex")]
partial class GanjoorPostIdIndex
[Migration("20201106070554_AudioNarrations")]
partial class AudioNarrations
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -442,9 +442,10 @@ namespace RMuseum.Migrations
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b =>
{
b.Property<Guid>("Id")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudioArtist")
.HasColumnType("nvarchar(max)");
@ -467,6 +468,9 @@ namespace RMuseum.Migrations
b.Property<string>("AudioTitle")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("FileLastUpdated")
.HasColumnType("datetime2");
b.Property<string>("FileNameWithoutExtension")
.HasColumnType("nvarchar(max)");
@ -550,6 +554,9 @@ namespace RMuseum.Migrations
b.Property<bool>("IsDefault")
.HasColumnType("bit");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");

View File

@ -0,0 +1,309 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class AudioNarrations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AudioFiles",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OwnerId = table.Column<Guid>(nullable: false),
GanjoorAudioId = table.Column<int>(nullable: false),
GanjoorPostId = table.Column<int>(nullable: false),
AudioOrder = table.Column<int>(nullable: false),
FileNameWithoutExtension = table.Column<string>(nullable: true),
SoundFilesFolder = table.Column<string>(nullable: true),
AudioTitle = table.Column<string>(nullable: true),
AudioArtist = table.Column<string>(nullable: true),
AudioArtistUrl = table.Column<string>(nullable: true),
AudioSrc = table.Column<string>(nullable: true),
AudioSrcUrl = table.Column<string>(nullable: true),
LegacyAudioGuid = table.Column<Guid>(nullable: false),
Mp3FileCheckSum = table.Column<string>(nullable: true),
Mp3SizeInBytes = table.Column<int>(nullable: false),
OggSizeInBytes = table.Column<int>(nullable: false),
UploadDate = table.Column<DateTime>(nullable: false),
FileLastUpdated = table.Column<DateTime>(nullable: false),
ReviewDate = table.Column<DateTime>(nullable: false),
LocalMp3FilePath = table.Column<string>(nullable: true),
LocalXmlFilePath = table.Column<string>(nullable: true),
AudioSyncStatus = table.Column<int>(nullable: false),
ReviewStatus = table.Column<int>(nullable: false),
ReviewerId = table.Column<Guid>(nullable: true),
ReviewMsg = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AudioFiles", x => x.Id);
table.ForeignKey(
name: "FK_AudioFiles_AspNetUsers_OwnerId",
column: x => x.OwnerId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AudioFiles_AspNetUsers_ReviewerId",
column: x => x.ReviewerId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "GanjoorPoets",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorPoets", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UploadSessions",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
SessionType = table.Column<int>(nullable: false),
UserId = table.Column<Guid>(nullable: true),
UseId = table.Column<Guid>(nullable: false),
UploadStartTime = table.Column<DateTime>(nullable: false),
UploadEndTime = table.Column<DateTime>(nullable: false),
ProcessStartTime = table.Column<DateTime>(nullable: false),
ProcessEndTime = table.Column<DateTime>(nullable: false),
ProcessProgress = table.Column<int>(nullable: false),
Status = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadSessions", x => x.Id);
table.ForeignKey(
name: "FK_UploadSessions_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserNarrationProfiles",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
UserId = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
FileSuffixWithoutDash = table.Column<string>(nullable: true),
ArtistName = table.Column<string>(nullable: true),
ArtistUrl = table.Column<string>(nullable: true),
AudioSrc = table.Column<string>(nullable: true),
AudioSrcUrl = table.Column<string>(nullable: true),
IsDefault = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserNarrationProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserNarrationProfiles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GanjoorCategories",
columns: table => new
{
Id = table.Column<int>(nullable: false),
PoetId = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true),
ParentId = table.Column<int>(nullable: true),
UrlSlug = table.Column<string>(nullable: true),
FullUrl = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorCategories", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorCategories_GanjoorCategories_ParentId",
column: x => x.ParentId,
principalTable: "GanjoorCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_GanjoorCategories_GanjoorPoets_PoetId",
column: x => x.PoetId,
principalTable: "GanjoorPoets",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UploadedFiles",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
UploadSessionId = table.Column<Guid>(nullable: false),
ContentDisposition = table.Column<string>(nullable: true),
ContentType = table.Column<string>(nullable: true),
FileName = table.Column<string>(nullable: true),
Length = table.Column<long>(nullable: false),
Name = table.Column<string>(nullable: true),
FilePath = table.Column<string>(nullable: true),
MP3FileCheckSum = table.Column<string>(nullable: true),
ProcessResult = table.Column<bool>(nullable: false),
ProcessResultMsg = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadedFiles", x => x.Id);
table.ForeignKey(
name: "FK_UploadedFiles_UploadSessions_UploadSessionId",
column: x => x.UploadSessionId,
principalTable: "UploadSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GanjoorPoems",
columns: table => new
{
Id = table.Column<int>(nullable: false),
CatId = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true),
FullTitle = table.Column<string>(nullable: true),
UrlSlug = table.Column<string>(nullable: true),
FullUrl = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorPoems", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorPoems_GanjoorCategories_CatId",
column: x => x.CatId,
principalTable: "GanjoorCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GanjoorVerses",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PoemId = table.Column<int>(nullable: false),
VOrder = table.Column<int>(nullable: false),
VersePosition = table.Column<int>(nullable: false),
Text = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorVerses", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorVerses_GanjoorPoems_PoemId",
column: x => x.PoemId,
principalTable: "GanjoorPoems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_GanjoorPostId",
table: "AudioFiles",
column: "GanjoorPostId");
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_OwnerId",
table: "AudioFiles",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_ReviewerId",
table: "AudioFiles",
column: "ReviewerId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorCategories_FullUrl",
table: "GanjoorCategories",
column: "FullUrl");
migrationBuilder.CreateIndex(
name: "IX_GanjoorCategories_ParentId",
table: "GanjoorCategories",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorCategories_PoetId",
table: "GanjoorCategories",
column: "PoetId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoems_CatId",
table: "GanjoorPoems",
column: "CatId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoems_FullUrl",
table: "GanjoorPoems",
column: "FullUrl");
migrationBuilder.CreateIndex(
name: "IX_GanjoorVerses_PoemId",
table: "GanjoorVerses",
column: "PoemId");
migrationBuilder.CreateIndex(
name: "IX_UploadedFiles_UploadSessionId",
table: "UploadedFiles",
column: "UploadSessionId");
migrationBuilder.CreateIndex(
name: "IX_UploadSessions_UserId",
table: "UploadSessions",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserNarrationProfiles_UserId",
table: "UserNarrationProfiles",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AudioFiles");
migrationBuilder.DropTable(
name: "GanjoorVerses");
migrationBuilder.DropTable(
name: "UploadedFiles");
migrationBuilder.DropTable(
name: "UserNarrationProfiles");
migrationBuilder.DropTable(
name: "GanjoorPoems");
migrationBuilder.DropTable(
name: "UploadSessions");
migrationBuilder.DropTable(
name: "GanjoorCategories");
migrationBuilder.DropTable(
name: "GanjoorPoets");
}
}
}

View File

@ -440,9 +440,10 @@ namespace RMuseum.Migrations
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b =>
{
b.Property<Guid>("Id")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudioArtist")
.HasColumnType("nvarchar(max)");
@ -465,6 +466,9 @@ namespace RMuseum.Migrations
b.Property<string>("AudioTitle")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("FileLastUpdated")
.HasColumnType("datetime2");
b.Property<string>("FileNameWithoutExtension")
.HasColumnType("nvarchar(max)");
@ -548,6 +552,9 @@ namespace RMuseum.Migrations
b.Property<bool>("IsDefault")
.HasColumnType("bit");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");

View File

@ -148,6 +148,11 @@ namespace RMuseum.Models.GanjoorAudio
/// </summary>
public DateTime UploadDate { get; set; }
/// <summary>
/// File Last Updated
/// </summary>
public DateTime FileLastUpdated { get; set; }
/// <summary>
/// Review Date (Approve or Reject)
/// </summary>

View File

@ -23,6 +23,11 @@ namespace RMuseum.Models.GanjoorAudio
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// Profile Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// this would be appended to audio files names prefixed by a dash to make them unique and specfic to user
/// filenames usually would look like {GanjoorPostId}-{FileSuffixWithoutDash}.{ext}

View File

@ -39,6 +39,7 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
LocalXmlFilePath = src.LocalXmlFilePath;
ReviewStatus = src.ReviewStatus;
UploadDate = src.UploadDate;
FileLastUpdated = src.FileLastUpdated;
ReviewDate = src.ReviewDate;
if(poem != null)
{
@ -209,6 +210,11 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// </summary>
public DateTime UploadDate { get; set; }
/// <summary>
/// File Last Updated
/// </summary>
public DateTime FileLastUpdated { get; set; }
/// <summary>
/// Review Date (Approve or Reject)
/// </summary>

View File

@ -24,6 +24,7 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
Id = src.Id;
User = src.User == null ? null : new PublicRAppUser(src.User);
UserId = src.UserId;
Name = src.Name;
FileSuffixWithoutDash = src.FileSuffixWithoutDash;
ArtistName = src.ArtistName;
ArtistUrl = src.ArtistUrl;
@ -56,6 +57,11 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// </remarks>
public Guid UserId { get; set; }
/// <summary>
/// Profile Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// this would be appended to audio files names prefixed by a dash to make them unique and specfic to user
/// filenames usually would look like {GanjoorPostId}-{FileSuffixWithoutDash}.{ext}

View File

@ -1904,6 +1904,11 @@
Upload Date
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.PoemNarration.FileLastUpdated">
<summary>
File Last Updated
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.PoemNarration.ReviewDate">
<summary>
Review Date (Approve or Reject)
@ -1964,6 +1969,11 @@
UserId
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.UserNarrationProfile.Name">
<summary>
Profile Name
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.UserNarrationProfile.FileSuffixWithoutDash">
<summary>
this would be appended to audio files names prefixed by a dash to make them unique and specfic to user
@ -2241,6 +2251,11 @@
Upload Date
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationViewModel.FileLastUpdated">
<summary>
File Last Updated
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationViewModel.ReviewDate">
<summary>
Review Date (Approve or Reject)
@ -2306,6 +2321,11 @@
Do not fill it in POST api
</remarks>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.ViewModels.UserNarrationProfileViewModel.Name">
<summary>
Profile Name
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.ViewModels.UserNarrationProfileViewModel.FileSuffixWithoutDash">
<summary>
this would be appended to audio files names prefixed by a dash to make them unique and specfic to user

View File

@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MySql.Data.MySqlClient;
using Org.BouncyCastle.Crypto.Engines;
using Renci.SshNet;
using RMuseum.DbContext;
using RMuseum.Models.Ganjoor;
@ -15,7 +14,6 @@ using RMuseum.Models.UploadSession.ViewModels;
using RMuseum.Services.Implementation.ImportedFromDesktopGanjoor;
using RSecurityBackend.Models.Generic;
using RSecurityBackend.Services.Implementation;
using SQLitePCL;
using System;
using System.Collections.Generic;
using System.Data;
@ -227,6 +225,7 @@ namespace RMuseum.Services.Implementation
AudioSyncStatus = audioSyncStatus,
ReviewStatus = AudioReviewStatus.Approved
};
newRecord.FileLastUpdated = newRecord.UploadDate;
newRecord.ReviewDate = newRecord.UploadDate;
string audio_xml = row["audio_xml"].ToString();
//sample audio_xml value: /i/a/x/11876-Simorgh.xml
@ -322,6 +321,13 @@ namespace RMuseum.Services.Implementation
}
}
profile.FileSuffixWithoutDash = ext;
profile.Name = profile.ArtistName;
int pIndex = 1;
while((await _context.UserNarrationProfiles.Where(p => p.UserId == ownerRAppUserId && p.Name == profile.Name).SingleOrDefaultAsync())!=null)
{
pIndex++;
profile.Name = $"{profile.ArtistName} {GPersianTextSync.Sync(pIndex.ToString())}";
}
_context.UserNarrationProfiles.Add(profile);
await _context.SaveChangesAsync(); //this logically should be outside this loop,
//but it messes with the order of records so I decided
@ -566,6 +572,7 @@ namespace RMuseum.Services.Implementation
Mp3SizeInBytes = mp3fileSize,
OggSizeInBytes = 0,
UploadDate = session.UploadEndTime,
FileLastUpdated = session.UploadEndTime,
LocalMp3FilePath = localMp3FilePath,
LocalXmlFilePath = localXmlFilePath,
AudioSyncStatus = (int)AudioSyncStatus.NewItem,
@ -873,6 +880,10 @@ namespace RMuseum.Services.Implementation
/// <returns></returns>
private static string GetUserProfileValidationError(UserNarrationProfile p)
{
if(string.IsNullOrEmpty(p.Name))
{
return "نام نمایه نباید خالی باشد.";
}
if (p.ArtistName.Length < 3)
{
return "نام خوانشگر باید حداقل شامل سه نویسه باشد.";
@ -930,6 +941,7 @@ namespace RMuseum.Services.Implementation
var p = new UserNarrationProfile()
{
UserId = profile.UserId,
Name = profile.Name.Trim(),
ArtistName = profile.ArtistName.Trim(),
ArtistUrl = profile.ArtistUrl.Trim(),
AudioSrc = profile.AudioSrc.Trim(),
@ -944,6 +956,11 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<UserNarrationProfileViewModel>(null, error);
}
if((await _context.UserNarrationProfiles.Where(e => e.UserId == p.Id && e.Name == p.Name).SingleOrDefaultAsync())!=null)
{
return new RServiceResult<UserNarrationProfileViewModel>(null, "شما نمایهٔ دیگری با همین نام دارید.");
}
await _context.UserNarrationProfiles.AddAsync(p);
await _context.SaveChangesAsync();
@ -979,6 +996,7 @@ namespace RMuseum.Services.Implementation
if (p.UserId != profile.UserId)
return new RServiceResult<UserNarrationProfileViewModel>(null, "permission error");
p.Name = profile.Name.Trim();
p.ArtistName = profile.ArtistName.Trim();
p.ArtistUrl = profile.ArtistUrl.Trim();
p.AudioSrc = profile.AudioSrc.Trim();
@ -992,6 +1010,11 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<UserNarrationProfileViewModel>(null, error);
}
if ((await _context.UserNarrationProfiles.Where(e => e.UserId == p.Id && e.Name == p.Name && e.Id != p.Id).SingleOrDefaultAsync()) != null)
{
return new RServiceResult<UserNarrationProfileViewModel>(null, "شما نمایهٔ دیگری با همین نام دارید.");
}
_context.UserNarrationProfiles.Update(p);
await _context.SaveChangesAsync();