Номера 50/50
This commit is contained in:
parent
3d2a7d5425
commit
07a4b5582c
@ -11,7 +11,7 @@ namespace HotelContracts.BindingModels
|
||||
[DisplayName("Корпус комнаты")]
|
||||
public string RoomFrame { get; set; } = string.Empty;
|
||||
public double RoomPrice { get; set; }
|
||||
public int MealPlanId { get; set; }
|
||||
public int? MealPlanId { get; set; }
|
||||
public int HeadwaiterId { get; set; }
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, ILunchModel> RoomLunches { get; set; } = new();
|
||||
|
@ -17,7 +17,7 @@ namespace HotelContracts.ViewModels
|
||||
[DisplayName("Стоимость комнаты")]
|
||||
public double RoomPrice { get; set; }
|
||||
|
||||
public int MealPlanId { get; set; }
|
||||
public int? MealPlanId { get; set; }
|
||||
|
||||
public int HeadwaiterId { get; set; }
|
||||
|
||||
|
589
Hotel/HotelDataBaseImplement/Migrations/20240330181838_FixMealPlan.Designer.cs
generated
Normal file
589
Hotel/HotelDataBaseImplement/Migrations/20240330181838_FixMealPlan.Designer.cs
generated
Normal file
@ -0,0 +1,589 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HotelDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HotelDataBase))]
|
||||
[Migration("20240330181838_FixMealPlan")]
|
||||
partial class FixMealPlan
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ConferenceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("StartDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Conferences");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("BookingDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NameHall")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("ConferenceBookings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingLunch", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceBookingId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("LunchId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceBookingId");
|
||||
|
||||
b.HasIndex("LunchId");
|
||||
|
||||
b.ToTable("ConferenceBookingLunches");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("ConferenceMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("HeadwaiterEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterPatronymic")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterPhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Headwaiters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Lunch", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("LunchName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("LunchPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("Lunches");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MealPlanName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("MealPlanPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("MealPlans");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("MealPlanMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MemberName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MemberPatronymic")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MemberPhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MemberSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("OrganiserEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserPatronymic")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserPhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Organisers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RoomFrame")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("RoomName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("RoomPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.ToTable("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomLunch", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("LunchId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RoomId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("LunchId");
|
||||
|
||||
b.HasIndex("RoomId");
|
||||
|
||||
b.ToTable("RoomLunches");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Conferences")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("ConferenceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingLunch", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking")
|
||||
.WithMany("Lunches")
|
||||
.HasForeignKey("ConferenceBookingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Lunch", "Lunch")
|
||||
.WithMany("ConferenceBookingLunch")
|
||||
.HasForeignKey("LunchId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ConferenceBooking");
|
||||
|
||||
b.Navigation("Lunch");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("ConferenceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("ConferenceMembers")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Lunch", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("Lunches")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("MealPlans")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("MealPlanId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("MealPlanMember")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("MealPlanId");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomLunch", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Lunch", "Lunch")
|
||||
.WithMany("RoomLunches")
|
||||
.HasForeignKey("LunchId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Room", "Room")
|
||||
.WithMany("Lunches")
|
||||
.HasForeignKey("RoomId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Lunch");
|
||||
|
||||
b.Navigation("Room");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Navigation("Lunches");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Lunches");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Lunch", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookingLunch");
|
||||
|
||||
b.Navigation("RoomLunches");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Navigation("Members");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Navigation("ConferenceMembers");
|
||||
|
||||
b.Navigation("MealPlanMember");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Navigation("Conferences");
|
||||
|
||||
b.Navigation("MealPlans");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Navigation("Lunches");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FixMealPlan : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Rooms_MealPlans_MealPlanId",
|
||||
table: "Rooms");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "MealPlanId",
|
||||
table: "Rooms",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Rooms_MealPlans_MealPlanId",
|
||||
table: "Rooms",
|
||||
column: "MealPlanId",
|
||||
principalTable: "MealPlans",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Rooms_MealPlans_MealPlanId",
|
||||
table: "Rooms");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "MealPlanId",
|
||||
table: "Rooms",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Rooms_MealPlans_MealPlanId",
|
||||
table: "Rooms",
|
||||
column: "MealPlanId",
|
||||
principalTable: "MealPlans",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -323,7 +323,7 @@ namespace HotelDataBaseImplement.Migrations
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MealPlanId")
|
||||
b.Property<int?>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RoomFrame")
|
||||
@ -499,9 +499,7 @@ namespace HotelDataBaseImplement.Migrations
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("MealPlanId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("MealPlanId");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace HotelDataBaseImplement.Models
|
||||
[Required]
|
||||
public double RoomPrice { get; set; }
|
||||
|
||||
public int MealPlanId { get; private set; }
|
||||
public int? MealPlanId { get; private set; }
|
||||
public int HeadwaiterId { get; private set; }
|
||||
|
||||
public virtual Headwaiter? Headwaiter { get; set; }
|
||||
|
@ -5,7 +5,7 @@
|
||||
string RoomName { get; }
|
||||
string RoomFrame { get; }
|
||||
double RoomPrice { get; }
|
||||
int MealPlanId { get; }
|
||||
int? MealPlanId { get; }
|
||||
int HeadwaiterId { get; }
|
||||
public Dictionary<int, ILunchModel> RoomLunches { get; }
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
using HostrelHeadwaiterApp;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using HostrelHeadwaiterApp;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataBaseImplement.Models;
|
||||
using HotelHeadwaiterApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
@ -151,6 +154,10 @@ namespace HotelHeadwaiterApp.Controllers
|
||||
{
|
||||
throw new Exception("Цена не может быть отрицательной");
|
||||
}
|
||||
if (string.IsNullOrEmpty(lunchPrice.ToString()))
|
||||
{
|
||||
throw new Exception("Введите цену");
|
||||
}
|
||||
APIClient.PostRequest("api/lunch/createlunch", new LunchBindingModel
|
||||
{
|
||||
LunchPrice = lunchPrice,
|
||||
@ -185,6 +192,10 @@ namespace HotelHeadwaiterApp.Controllers
|
||||
{
|
||||
throw new Exception("Цена не может быть отрицательной");
|
||||
}
|
||||
if (string.IsNullOrEmpty(lunchPrice.ToString()))
|
||||
{
|
||||
throw new Exception("Введите цену");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/lunch/updatelunch", new LunchBindingModel
|
||||
{
|
||||
@ -221,6 +232,169 @@ namespace HotelHeadwaiterApp.Controllers
|
||||
Response.Redirect("ListLunches");
|
||||
}
|
||||
|
||||
public IActionResult ListRooms()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<RoomViewModel>>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult CreateRoom()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateRoom(string roomName, double roomPrice, string roomFrame)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
if (string.IsNullOrEmpty(roomName))
|
||||
{
|
||||
throw new Exception("Введите название");
|
||||
}
|
||||
if (string.IsNullOrEmpty(roomPrice.ToString()))
|
||||
{
|
||||
throw new Exception("Введите цену");
|
||||
}
|
||||
if (roomPrice < 0)
|
||||
{
|
||||
throw new Exception("Цена не может быть отрицательной");
|
||||
}
|
||||
APIClient.PostRequest("api/room/createroom", new RoomBindingModel
|
||||
{
|
||||
RoomName = roomName,
|
||||
RoomPrice = roomPrice,
|
||||
RoomFrame = roomFrame,
|
||||
HeadwaiterId = APIClient.Headwaiter.Id,
|
||||
});
|
||||
Response.Redirect("ListRooms");
|
||||
}
|
||||
|
||||
public IActionResult UpdateRoom()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateRoom(int room, string roomName, double roomPrice, string roomFrame)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
if (string.IsNullOrEmpty(roomName))
|
||||
{
|
||||
throw new Exception("Введите название");
|
||||
}
|
||||
if (string.IsNullOrEmpty(roomPrice.ToString()))
|
||||
{
|
||||
throw new Exception("Введите цену");
|
||||
}
|
||||
if (roomPrice < 0)
|
||||
{
|
||||
throw new Exception("Цена не может быть отрицательной");
|
||||
}
|
||||
APIClient.PostRequest("api/room/updateroom", new RoomBindingModel
|
||||
{
|
||||
Id = room,
|
||||
RoomName = roomName,
|
||||
RoomPrice = roomPrice,
|
||||
RoomFrame = roomFrame,
|
||||
HeadwaiterId = APIClient.Headwaiter.Id
|
||||
});
|
||||
Response.Redirect("ListRooms");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<RoomViewModel, string>? GetRoom(int roomId)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
var result = APIClient.GetRequest<Tuple<RoomViewModel, List<Tuple<string, string>>>>($"api/room/getroombyid?roomId={roomId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
string table = "";
|
||||
for (int i = 0; i < result.Item2.Count; i++)
|
||||
{
|
||||
var lunchName = result.Item2[i].Item1;
|
||||
var lunchPrice = result.Item2[i].Item2;
|
||||
table += "<tr style=\"height: 44px\">";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{lunchName}</td>";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{lunchPrice}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
return Tuple.Create(result.Item1, table);
|
||||
}
|
||||
|
||||
public IActionResult AddLunchToRoom()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(Tuple.Create(APIClient.GetRequest<List<RoomViewModel>>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}"),
|
||||
APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunchlist?headwaiterId={APIClient.Headwaiter.Id}")));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddLunchToRoom(int room, int[] lunch)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
for (int i = 0; i < lunch.Length; i++)
|
||||
{
|
||||
APIClient.PostRequest("api/room/AddLunchToRoom", Tuple.Create(
|
||||
new RoomSearchModel() { Id = room },
|
||||
new LunchViewModel() { Id = lunch[i] }
|
||||
));
|
||||
}
|
||||
Response.Redirect("ListRooms");
|
||||
}
|
||||
|
||||
public IActionResult DeleteRoom()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteRoom(int room)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
APIClient.PostRequest("api/room/deleteroom", new RoomBindingModel
|
||||
{
|
||||
Id = room
|
||||
});
|
||||
Response.Redirect("ListRooms");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
|
82
Hotel/HotelHeadwaiterApp/Views/Home/CreateRoom.cshtml
Normal file
82
Hotel/HotelHeadwaiterApp/Views/Home/CreateRoom.cshtml
Normal file
@ -0,0 +1,82 @@
|
||||
@using HotelContracts.ViewModels;
|
||||
@using HotelDataModels.Models;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "CreateRoom";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Добавление номера</h2>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-2">Название комнаты</label>
|
||||
</div>
|
||||
<input type="text"
|
||||
placeholder="Введите название комнаты"
|
||||
name="roomName"
|
||||
class="form-control" />
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-2">Цена комнаты</label>
|
||||
</div>
|
||||
<input type="number"
|
||||
placeholder="Введите цену комнаты"
|
||||
name="roomPrice"
|
||||
class="form-control" />
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-2">Корпус</label>
|
||||
</div>
|
||||
<input type="text"
|
||||
placeholder="Введите корпус комнаты"
|
||||
name="roomFrame"
|
||||
class="form-control" />
|
||||
<br>
|
||||
<div class="u-table u-table-responsive u-table-1">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Обеды для номеров</label>
|
||||
<table class="table">
|
||||
<thead class="thead-dark">
|
||||
<tr style="height: 44px">
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Обед
|
||||
</th>
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Цена
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="u-table-body" id="table-elements">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="u-container-layout u-container-layout-2">
|
||||
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center d-flex justify-content-md-center" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var room = $('#room').val();
|
||||
if (room) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetRoom",
|
||||
data: { roomId: room },
|
||||
success: function (result) {
|
||||
$('#roomName').val(result.item1.roomName);
|
||||
$('#roomPrice').val(result.item1.roomPrice);
|
||||
$('#roomFrame').val(result.item1.roomFrame);
|
||||
$('#table-elements').html(result.item2);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#room').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
17
Hotel/HotelHeadwaiterApp/Views/Home/DeleteRoom.cshtml
Normal file
17
Hotel/HotelHeadwaiterApp/Views/Home/DeleteRoom.cshtml
Normal file
@ -0,0 +1,17 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteRoom";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление номера</h2>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Комнаты: </label>
|
||||
<select id="room" name="room" class="form-control" asp-items="@(new SelectList(@ViewBag.Rooms, "Id", "RoomName"))"></select>
|
||||
</div>
|
||||
<br>
|
||||
<div class="u-container-layout u-container-layout-2">
|
||||
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center d-flex justify-content-md-center" />
|
||||
</div>
|
||||
</form>
|
76
Hotel/HotelHeadwaiterApp/Views/Home/ListRooms.cshtml
Normal file
76
Hotel/HotelHeadwaiterApp/Views/Home/ListRooms.cshtml
Normal file
@ -0,0 +1,76 @@
|
||||
@using HotelContracts.ViewModels
|
||||
|
||||
@model List<RoomViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ListRooms";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Список номеров</h2>
|
||||
</div>
|
||||
|
||||
<section class="u-clearfix u-section-1" id="sec-e38b">
|
||||
<div class="u-clearfix u-sheet u-sheet-1">
|
||||
<div class="u-container-style u-layout-cell u-size-48 u-layout-cell-1">
|
||||
<div class="u-container-layout u-container-layout-1">
|
||||
<div class="btn-group" role="group" aria-label="Basic example">
|
||||
<a asp-area="" asp-controller="Home" asp-action="CreateRoom"
|
||||
class="btn btn-outline-dark mr-2">Добавить</a>
|
||||
|
||||
<a asp-area="" asp-controller="Home" asp-action="UpdateRoom"
|
||||
class="btn btn-outline-dark mr-2">Изменить</a>
|
||||
|
||||
<a asp-area="" asp-controller="Home" asp-action="DeleteRoom"
|
||||
class="btn btn-outline-dark mr-2">Удалить</a>
|
||||
|
||||
</div>
|
||||
<div class="u-table u-table-responsive u-table-1">
|
||||
<table class="table">
|
||||
<thead class="thead-dark">
|
||||
<tr style="height: 31px">
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Номер
|
||||
</th>
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Корпус
|
||||
</th>
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Название
|
||||
</th>
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Цена
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="u-table-body">
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr style="height: 75px">
|
||||
<td class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell">
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell">
|
||||
@Html.DisplayFor(modelItem => item.RoomFrame)
|
||||
</td>
|
||||
<td class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell">
|
||||
@Html.DisplayFor(modelItem => item.RoomName)
|
||||
</td>
|
||||
<td class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell">
|
||||
@Html.DisplayFor(modelItem => item.RoomPrice)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.btn-group > .btn {
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
87
Hotel/HotelHeadwaiterApp/Views/Home/UpdateRoom.cshtml
Normal file
87
Hotel/HotelHeadwaiterApp/Views/Home/UpdateRoom.cshtml
Normal file
@ -0,0 +1,87 @@
|
||||
@using HotelContracts.ViewModels;
|
||||
@using HotelDataModels.Models;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateRoom";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Изменение номера</h2>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Комнаты: </label>
|
||||
<select id="room" name="room" class="form-control" asp-items="@(new SelectList(@ViewBag.Rooms, "Id", "RoomName"))"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Название комнаты</label>
|
||||
<input type="text"
|
||||
id="roomName"
|
||||
placeholder="Введите название номера"
|
||||
name="roomName"
|
||||
class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-2">Цена комнаты</label>
|
||||
<input type="number"
|
||||
id="roomPrice"
|
||||
placeholder="Введите цену номера"
|
||||
name="roomPrice"
|
||||
class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Корпус</label>
|
||||
<input type="text"
|
||||
id="roomFrame"
|
||||
placeholder="Введите название корпуса"
|
||||
name="roomFrame"
|
||||
class="form-control" />
|
||||
</div>
|
||||
<div class="u-table u-table-responsive u-table-1">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Обеды для номеров</label>
|
||||
<table class="table">
|
||||
<thead class="thead-dark">
|
||||
<tr style="height: 44px">
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Обед
|
||||
</th>
|
||||
<th class="u-border-1 u-border-grey-50 u-table-cell">
|
||||
Цена
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="u-table-body" id="table-elements">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
<div class="u-container-layout u-container-layout-2">
|
||||
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center d-flex justify-content-md-center" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var room = $('#room').val();
|
||||
if (room) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetRoom",
|
||||
data: { roomId: room },
|
||||
success: function (result) {
|
||||
$('#roomName').val(result.item1.roomName);
|
||||
$('#roomPrice').val(result.item1.roomPrice);
|
||||
$('#roomFrame').val(result.item1.roomFrame);
|
||||
$('#table-elements').html(result.item2);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#room').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user