diff --git a/Hotel/HotelAdministratorApp/Controllers/HomeController.cs b/Hotel/HotelAdministratorApp/Controllers/HomeController.cs index 5611868..34c1ff4 100644 --- a/Hotel/HotelAdministratorApp/Controllers/HomeController.cs +++ b/Hotel/HotelAdministratorApp/Controllers/HomeController.cs @@ -487,8 +487,12 @@ namespace HotelAdministratorApp.Controllers throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); } using var context = new HotelDataBase(); - var roomElem = APIClient.GetRequest($"api/main/getroombyid?roomId={room}"); - var dinners = _dinner.ReadList(new DinnerSearchModel { AdministratorId = APIClient.Administrator.Id }); + var roomElem = APIClient.GetRequest($"api/main/getroombyid?roomId={room}"); //комната со всеми ее атрибутами + var dinners = _dinner.ReadList(new DinnerSearchModel { AdministratorId = APIClient.Administrator.Id }); //все обеды у администратора + List roomDinnersIds = context.RoomDinners + .Where(rd => rd.RoomId == room) + .Select(rd => rd.DinnerId) + .ToList(); APIClient.PostRequest("api/main/updateroom", new RoomBindingModel { diff --git a/Hotel/HotelBusinessLogic/BusinessLogic/ReportLogicAdministrator.cs b/Hotel/HotelBusinessLogic/BusinessLogic/ReportLogicAdministrator.cs index c4d5aad..d8e66ef 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogic/ReportLogicAdministrator.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogic/ReportLogicAdministrator.cs @@ -35,7 +35,7 @@ namespace HotelBusinessLogic.BusinessLogic _saveToExcel.CreateReport(new ExcelInfoAdministrator { FileName = model.FileName, - Title = "Список покупок по медикаментам", + Title = "Список покупок по обедам", MealPlanDinners = GetMealPlanDinners(model) }); } @@ -45,7 +45,7 @@ namespace HotelBusinessLogic.BusinessLogic _saveToWord.CreateDoc(new WordInfoAdministrator { FileName = model.FileName, - Title = "Список покупок по медикаментам", + Title = "Список покупок по обедам", MealPlanDinners = GetMealPlanDinners(model) }); } diff --git a/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj b/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj index d680eeb..9e45a48 100644 --- a/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj +++ b/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -8,8 +8,9 @@ - + + diff --git a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfAdministrator.cs b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfAdministrator.cs index ebae8d8..2658fb4 100644 --- a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfAdministrator.cs +++ b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfAdministrator.cs @@ -18,21 +18,21 @@ namespace HotelBusinessLogic.OfficePackage Text = info.Title, Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAligmentType.Center + ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", - ParagraphAlignment = PdfParagraphAligmentType.Center + ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateTable(new List { "4cm", "4cm", "4cm", "4cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Дата", "Название обеда", "Комната", "Бронь" }, + Texts = new List { "Дата", "Название медикамента", "Посещение ", "Лекарство" }, Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAligmentType.Center + ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var dinner in info.ReportRoomsConferences) { @@ -40,24 +40,24 @@ namespace HotelBusinessLogic.OfficePackage { Texts = new List { "", dinner.DinnerName, "", "" }, Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAligmentType.Center + ParagraphAlignment = PdfParagraphAlignmentType.Center }); - foreach (var conference in dinner.Conferences) + foreach (var conf in dinner.Conferences) { CreateRow(new PdfRowParameters { - Texts = new List { conference.StartDate.ToString(), "", "", conference.ConferenceName }, + Texts = new List { conf.StartDate.ToString(), "", "", conf.ConferenceName }, Style = "Normal", - ParagraphAlignment = PdfParagraphAligmentType.Center + ParagraphAlignment = PdfParagraphAlignmentType.Center }); } - foreach (var room in dinner.Rooms) + foreach (var guidance in dinner.Rooms) { CreateRow(new PdfRowParameters { - Texts = new List { room.DateCreate.ToString(), "", room.RoomNumber.ToString(), "" }, + Texts = new List { guidance.DateCreate.ToString(), "", guidance.RoomNumber.ToString(), "" }, Style = "Normal", - ParagraphAlignment = PdfParagraphAligmentType.Center + ParagraphAlignment = PdfParagraphAlignmentType.Center }); } } diff --git a/Hotel/HotelBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAligmentType.cs b/Hotel/HotelBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAligmentType.cs index afc6dee..614aaf6 100644 --- a/Hotel/HotelBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAligmentType.cs +++ b/Hotel/HotelBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAligmentType.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace HotelBusinessLogic.OfficePackage.HelperEnums { - public enum PdfParagraphAligmentType + public enum PdfParagraphAlignmentType { Center, Left, diff --git a/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 7ce681b..804b017 100644 --- a/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -14,6 +14,5 @@ namespace HotelBusinessLogic.OfficePackage.HelperModels public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } public List ReportRoomsConferences { get; set; } = new(); - /* public List ReportVisitsDrugs { get; set; } = new();*/ } } diff --git a/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs index 06f59b1..6339266 100644 --- a/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs +++ b/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -11,7 +11,7 @@ namespace HotelBusinessLogic.OfficePackage.HelperModels { public string Text { get; set; } = string.Empty; public string Style { get; set; } = string.Empty; - public PdfParagraphAligmentType ParagraphAlignment { get; set; } + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } } } diff --git a/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs index d645eef..533bc35 100644 --- a/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs +++ b/Hotel/HotelBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -11,6 +11,6 @@ namespace HotelBusinessLogic.OfficePackage.HelperModels { public List Texts { get; set; } = new(); public string Style { get; set; } = string.Empty; - public PdfParagraphAligmentType ParagraphAlignment { get; set; } + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } } } diff --git a/Hotel/HotelBusinessLogic/OfficePackage/Implements/SaveToPdfAdministrator.cs b/Hotel/HotelBusinessLogic/OfficePackage/Implements/SaveToPdfAdministrator.cs index 0f51a0a..d28e76e 100644 --- a/Hotel/HotelBusinessLogic/OfficePackage/Implements/SaveToPdfAdministrator.cs +++ b/Hotel/HotelBusinessLogic/OfficePackage/Implements/SaveToPdfAdministrator.cs @@ -17,13 +17,13 @@ namespace HotelBusinessLogic.OfficePackage.Implements private Section? _section; private Table? _table; private static ParagraphAlignment - GetParagraphAlignment(PdfParagraphAligmentType type) + GetParagraphAlignment(PdfParagraphAlignmentType type) { return type switch { - PdfParagraphAligmentType.Center => ParagraphAlignment.Center, - PdfParagraphAligmentType.Left => ParagraphAlignment.Left, - PdfParagraphAligmentType.Right => ParagraphAlignment.Right, + PdfParagraphAlignmentType.Center => ParagraphAlignment.Center, + PdfParagraphAlignmentType.Left => ParagraphAlignment.Left, + PdfParagraphAlignmentType.Right => ParagraphAlignment.Right, _ => ParagraphAlignment.Justify, }; } diff --git a/Hotel/HotelDataBaseImplement/HotelDataBase.cs b/Hotel/HotelDataBaseImplement/HotelDataBase.cs index f68800f..2229508 100644 --- a/Hotel/HotelDataBaseImplement/HotelDataBase.cs +++ b/Hotel/HotelDataBaseImplement/HotelDataBase.cs @@ -6,18 +6,16 @@ namespace HotelDataBaseImplement { public class HotelDataBase : DbContext { - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - if (optionsBuilder.IsConfigured == false) - { - optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=Hotel_bd;Username=postgres;Password=admin"); - } - base.OnConfiguring(optionsBuilder); - AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); - AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); - } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=HotellllDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + } - public virtual DbSet Conferences { get; set; } + base.OnConfiguring(optionsBuilder); + } + public virtual DbSet Conferences { get; set; } public virtual DbSet MealPlans { set; get; } public virtual DbSet Participants { set; get; } public virtual DbSet Organisers { set; get; } diff --git a/Hotel/HotelDataBaseImplement/HotelDataBaseImplement.csproj b/Hotel/HotelDataBaseImplement/HotelDataBaseImplement.csproj index ff65fb6..b4b9add 100644 --- a/Hotel/HotelDataBaseImplement/HotelDataBaseImplement.csproj +++ b/Hotel/HotelDataBaseImplement/HotelDataBaseImplement.csproj @@ -8,7 +8,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Hotel/HotelDataBaseImplement/Migrations/20240501171235_DeleteManyMigration.Designer.cs b/Hotel/HotelDataBaseImplement/Migrations/20240528212239_Init.Designer.cs similarity index 79% rename from Hotel/HotelDataBaseImplement/Migrations/20240501171235_DeleteManyMigration.Designer.cs rename to Hotel/HotelDataBaseImplement/Migrations/20240528212239_Init.Designer.cs index 01af8d9..b65b26a 100644 --- a/Hotel/HotelDataBaseImplement/Migrations/20240501171235_DeleteManyMigration.Designer.cs +++ b/Hotel/HotelDataBaseImplement/Migrations/20240528212239_Init.Designer.cs @@ -3,17 +3,17 @@ using System; using HotelDataBaseImplement; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace HotelDataBaseImplement.Migrations { [DbContext(typeof(HotelDataBase))] - [Migration("20240501171235_DeleteManyMigration")] - partial class DeleteManyMigration + [Migration("20240528212239_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -21,37 +21,37 @@ namespace HotelDataBaseImplement.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "7.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 63); + .HasAnnotation("Relational:MaxIdentifierLength", 128); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); modelBuilder.Entity("HotelDataBaseImplement.Models.Administrator", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorEmail") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorFIO") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorLogin") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorPassword") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorPhone") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -62,23 +62,23 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ConferenceName") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("StartDate") - .HasColumnType("timestamp without time zone"); + .HasColumnType("datetime2"); b.Property("Subject") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -91,22 +91,22 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ConferenceId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DateСonference") - .HasColumnType("timestamp without time zone"); + .HasColumnType("datetime2"); b.Property("PlaceСonference") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -121,15 +121,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ConferenceBookingId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DinnerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -144,15 +144,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ConferenceId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ParticipantId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -167,22 +167,22 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DinnerName") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("DinnerPrice") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("DinnerСalorieСontent") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -195,19 +195,19 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("MealPlanName") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("MealPlanPrice") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("OrganiserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -220,15 +220,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("MealPlanId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ParticipantId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -243,29 +243,29 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("OrganiserEmail") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserFIO") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserLogin") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserNumber") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserPassword") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -276,20 +276,20 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("Number") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ParticipantFIO") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -302,24 +302,24 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DateCreate") - .HasColumnType("timestamp without time zone"); + .HasColumnType("datetime2"); b.Property("MealPlanId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("RoomNumber") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("RoomPrice") - .HasColumnType("double precision"); + .HasColumnType("float"); b.HasKey("Id"); @@ -334,15 +334,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("DinnerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("RoomId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); diff --git a/Hotel/HotelDataBaseImplement/Migrations/20240501171235_DeleteManyMigration.cs b/Hotel/HotelDataBaseImplement/Migrations/20240528212239_Init.cs similarity index 71% rename from Hotel/HotelDataBaseImplement/Migrations/20240501171235_DeleteManyMigration.cs rename to Hotel/HotelDataBaseImplement/Migrations/20240528212239_Init.cs index 5b04ffb..ad5311a 100644 --- a/Hotel/HotelDataBaseImplement/Migrations/20240501171235_DeleteManyMigration.cs +++ b/Hotel/HotelDataBaseImplement/Migrations/20240528212239_Init.cs @@ -1,13 +1,12 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace HotelDataBaseImplement.Migrations { /// - public partial class DeleteManyMigration : Migration + public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -16,13 +15,13 @@ namespace HotelDataBaseImplement.Migrations name: "Administrators", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - AdministratorFIO = table.Column(type: "text", nullable: false), - AdministratorPhone = table.Column(type: "text", nullable: false), - AdministratorLogin = table.Column(type: "text", nullable: false), - AdministratorPassword = table.Column(type: "text", nullable: false), - AdministratorEmail = table.Column(type: "text", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AdministratorFIO = table.Column(type: "nvarchar(max)", nullable: false), + AdministratorPhone = table.Column(type: "nvarchar(max)", nullable: false), + AdministratorLogin = table.Column(type: "nvarchar(max)", nullable: false), + AdministratorPassword = table.Column(type: "nvarchar(max)", nullable: false), + AdministratorEmail = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -33,13 +32,13 @@ namespace HotelDataBaseImplement.Migrations name: "Organisers", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - OrganiserLogin = table.Column(type: "text", nullable: false), - OrganiserPassword = table.Column(type: "text", nullable: false), - OrganiserEmail = table.Column(type: "text", nullable: false), - OrganiserNumber = table.Column(type: "text", nullable: false), - OrganiserFIO = table.Column(type: "text", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrganiserLogin = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserPassword = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserEmail = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserNumber = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserFIO = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -50,12 +49,12 @@ namespace HotelDataBaseImplement.Migrations name: "Dinners", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DinnerName = table.Column(type: "text", nullable: false), - DinnerСalorieСontent = table.Column(type: "integer", nullable: false), - DinnerPrice = table.Column(type: "double precision", nullable: false), - AdministratorId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DinnerName = table.Column(type: "nvarchar(max)", nullable: false), + DinnerСalorieСontent = table.Column(type: "int", nullable: false), + DinnerPrice = table.Column(type: "float", nullable: false), + AdministratorId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -72,12 +71,12 @@ namespace HotelDataBaseImplement.Migrations name: "Conferences", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ConferenceName = table.Column(type: "text", nullable: false), - Subject = table.Column(type: "text", nullable: false), - StartDate = table.Column(type: "timestamp without time zone", nullable: false), - OrganiserId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ConferenceName = table.Column(type: "nvarchar(max)", nullable: false), + Subject = table.Column(type: "nvarchar(max)", nullable: false), + StartDate = table.Column(type: "datetime2", nullable: false), + OrganiserId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -94,11 +93,11 @@ namespace HotelDataBaseImplement.Migrations name: "MealPlans", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - MealPlanName = table.Column(type: "text", nullable: false), - MealPlanPrice = table.Column(type: "double precision", nullable: false), - OrganiserId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MealPlanName = table.Column(type: "nvarchar(max)", nullable: false), + MealPlanPrice = table.Column(type: "float", nullable: false), + OrganiserId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -115,11 +114,11 @@ namespace HotelDataBaseImplement.Migrations name: "Participants", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ParticipantFIO = table.Column(type: "text", nullable: false), - Number = table.Column(type: "text", nullable: false), - OrganiserId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ParticipantFIO = table.Column(type: "nvarchar(max)", nullable: false), + Number = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -136,12 +135,12 @@ namespace HotelDataBaseImplement.Migrations name: "ConferenceBookings", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DateСonference = table.Column(type: "timestamp without time zone", nullable: true), - AdministratorId = table.Column(type: "integer", nullable: false), - ConferenceId = table.Column(type: "integer", nullable: true), - PlaceСonference = table.Column(type: "text", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DateСonference = table.Column(type: "datetime2", nullable: true), + AdministratorId = table.Column(type: "int", nullable: false), + ConferenceId = table.Column(type: "int", nullable: true), + PlaceСonference = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -156,20 +155,21 @@ namespace HotelDataBaseImplement.Migrations name: "FK_ConferenceBookings_Conferences_ConferenceId", column: x => x.ConferenceId, principalTable: "Conferences", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Rooms", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoomNumber = table.Column(type: "integer", nullable: false), - RoomPrice = table.Column(type: "double precision", nullable: false), - DateCreate = table.Column(type: "timestamp without time zone", nullable: false), - AdministratorId = table.Column(type: "integer", nullable: false), - MealPlanId = table.Column(type: "integer", nullable: true) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoomNumber = table.Column(type: "int", nullable: false), + RoomPrice = table.Column(type: "float", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + AdministratorId = table.Column(type: "int", nullable: false), + MealPlanId = table.Column(type: "int", nullable: true) }, constraints: table => { @@ -184,17 +184,18 @@ namespace HotelDataBaseImplement.Migrations name: "FK_Rooms_MealPlans_MealPlanId", column: x => x.MealPlanId, principalTable: "MealPlans", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ConferenceParticipants", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ParticipantId = table.Column(type: "integer", nullable: false), - ConferenceId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ParticipantId = table.Column(type: "int", nullable: false), + ConferenceId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -204,7 +205,7 @@ namespace HotelDataBaseImplement.Migrations column: x => x.ConferenceId, principalTable: "Conferences", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ConferenceParticipants_Participants_ParticipantId", column: x => x.ParticipantId, @@ -217,10 +218,10 @@ namespace HotelDataBaseImplement.Migrations name: "MealPlanParticipants", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ParticipantId = table.Column(type: "integer", nullable: false), - MealPlanId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ParticipantId = table.Column(type: "int", nullable: false), + MealPlanId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -230,49 +231,49 @@ namespace HotelDataBaseImplement.Migrations column: x => x.MealPlanId, principalTable: "MealPlans", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_MealPlanParticipants_Participants_ParticipantId", column: x => x.ParticipantId, principalTable: "Participants", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ConferenceBookingDinners", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ConferenceBookingId = table.Column(type: "integer", nullable: false), - DinnerId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ConferenceBookingId = table.Column(type: "int", nullable: false), + DinnerId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ConferenceBookingDinners", x => x.Id); table.ForeignKey( - name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBooki~", + name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBookingId", column: x => x.ConferenceBookingId, principalTable: "ConferenceBookings", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ConferenceBookingDinners_Dinners_DinnerId", column: x => x.DinnerId, principalTable: "Dinners", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "RoomDinners", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoomId = table.Column(type: "integer", nullable: false), - DinnerId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoomId = table.Column(type: "int", nullable: false), + DinnerId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -282,13 +283,13 @@ namespace HotelDataBaseImplement.Migrations column: x => x.DinnerId, principalTable: "Dinners", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_RoomDinners_Rooms_RoomId", column: x => x.RoomId, principalTable: "Rooms", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( diff --git a/Hotel/HotelDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs b/Hotel/HotelDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs index 80bed9a..1e39570 100644 --- a/Hotel/HotelDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs +++ b/Hotel/HotelDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs @@ -3,8 +3,8 @@ using System; using HotelDataBaseImplement; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -18,37 +18,37 @@ namespace HotelDataBaseImplement.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "7.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 63); + .HasAnnotation("Relational:MaxIdentifierLength", 128); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); modelBuilder.Entity("HotelDataBaseImplement.Models.Administrator", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorEmail") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorFIO") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorLogin") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorPassword") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("AdministratorPhone") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -59,23 +59,23 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ConferenceName") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("StartDate") - .HasColumnType("timestamp without time zone"); + .HasColumnType("datetime2"); b.Property("Subject") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -88,22 +88,22 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ConferenceId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DateСonference") - .HasColumnType("timestamp without time zone"); + .HasColumnType("datetime2"); b.Property("PlaceСonference") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -118,15 +118,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ConferenceBookingId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DinnerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -141,15 +141,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ConferenceId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ParticipantId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -164,22 +164,22 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DinnerName") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("DinnerPrice") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("DinnerСalorieСontent") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -192,19 +192,19 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("MealPlanName") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("MealPlanPrice") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("OrganiserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -217,15 +217,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("MealPlanId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ParticipantId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -240,29 +240,29 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("OrganiserEmail") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserFIO") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserLogin") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserNumber") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserPassword") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -273,20 +273,20 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("Number") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("OrganiserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ParticipantFIO") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -299,24 +299,24 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AdministratorId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DateCreate") - .HasColumnType("timestamp without time zone"); + .HasColumnType("datetime2"); b.Property("MealPlanId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("RoomNumber") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("RoomPrice") - .HasColumnType("double precision"); + .HasColumnType("float"); b.HasKey("Id"); @@ -331,15 +331,15 @@ namespace HotelDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("DinnerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("RoomId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id");