Хотя бы работает регистрация...

This commit is contained in:
Кашин Максим 2023-05-16 01:11:49 +04:00
parent 4c4d8a878a
commit 6d5a45f5e8
19 changed files with 182 additions and 73 deletions

View File

@ -1,21 +1,35 @@
@{ @{
ViewData["Title"] = "Enter"; ViewData["Title"] = "Enter";
} }
<head>
<link rel="stylesheet" href="~/css/entry.css" asp-append-version="true" />
</head>
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Вход в приложение</h2> <h2
class="u-text u-text-custom-color-1 u-text-default u-text-1"
>
Вход
</h2>
</div> </div>
<form method="post"> <form method="post">
<div class="row"> <div class="u-form-group u-label-top u-form-group-1">
<div class="col-4">Логин:</div> <label class="u-label u-text-custom-color-1 u-label-1">Электронная почта</label>
<div class="col-8"><input type="text" name="login" /></div> <input
</div> type="text"
<div class="row"> placeholder="Введите свой логин"
<div class="col-4">Пароль:</div> name="login"
<div class="col-8"><input type="password" name="password" /></div> class="u-input u-input-rectangle u-input-1"/>
</div> </div>
<div class="row"> <div class="u-form-group u-label-top u-form-group-2">
<div class="col-8"></div> <label class="u-label u-text-custom-color-1 u-label-2">Пароль</label>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div> <input
</div> type="password"
placeholder="Введите свой пароль"
name="password"
class="u-input u-input-rectangle u-input-2"/>
</div>
<div class="u-align-center u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Войти" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1"/></div>
</div>
</form> </form>

View File

@ -7,17 +7,44 @@
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Home Page";
} }
<div class="text-center"> <head>
<h1 class="display-4">Заказы</h1> <link rel="stylesheet" href="~/css/mainpage.css" asp-append-version="true" />
</div> </head>
<section class="u-clearfix u-section-1" id="sec-83a8">
<div class="u-clearfix u-sheet u-sheet-1">
<div class="text-center"> <div class="u-clearfix u-expanded-width u-layout-wrap u-layout-wrap-1">
@{ <div class="u-layout">
if (Model == null) <div class="u-layout-col">
{ <div
<h3 class="display-4">Авторизируйтесь</h3> class="u-container-style u-layout-cell u-size-30 u-layout-cell-1"
return; >
} <div
} class="u-container-layout u-valign-bottom u-container-layout-1"
</div> >
<h2
class="u-align-center u-text u-text-custom-color-1 u-text-default u-text-1"
>
Гостиница
</h2>
</div>
</div>
<div
class="u-container-style u-layout-cell u-size-30 u-layout-cell-2"
>
<div
class="u-container-layout u-valign-top u-container-layout-2"
style="padding: 120px"
>
<img
class="u-image u-image-contain u-image-1"
src="~/Images/logo.png"
data-image-width="2388"
data-image-height="1260"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</section>

View File

@ -1,33 +1,56 @@
@{ @{
ViewData["Title"] = "Register"; ViewData["Title"] = "Register";
} }
<head>
<link rel="stylesheet" href="~/css/register.css" asp-append-version="true" />
</head>
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Регистрация</h2> <h2 class="u-text u-text-custom-color-1 u-text-default u-text-1"> Регистрация </h2>
</div> </div>
<form method="post"> <form method="post">
<div class="row"> <div class="u-form-group u-form-name u-label-top">
<div class="col-4">ФИО:</div> <label class="u-label u-text-custom-color-1 u-label-1">Логин</label>
<div class="col-8"><input type="text" name="fio" /></div> <input
</div> type="text"
<div class="row"> placeholder="Введите логин"
<div class="col-4">Логин:</div> name="login"
<div class="col-8"><input type="text" name="login" /></div> class="u-input u-input-rectangle"/>
</div> </div>
<div class="row"> <div class="u-form-email u-form-group u-label-top">
<div class="col-4">Пароль:</div> <label class="u-label u-text-custom-color-1 u-label-2">Электронная почта</label>
<div class="col-8"><input type="password" name="password" /></div> <input
</div> type="email"
<div class="row"> placeholder="Введите электронную почту"
<div class="col-4">Электронная почта:</div> name="email"
<div class="col-8"><input type="text" name="email" /></div> class="u-input u-input-rectangle"/>
</div> </div>
<div class="row"> <div class="u-form-group u-label-top u-form-group-3">
<div class="col-4">Номер телефона:</div> <label class="u-label u-text-custom-color-1 u-label-3">ФИО</label>
<div class="col-8"><input type="text" name="telephone" /></div> <input
</div> type="text"
<div class="row"> placeholder="Введите ФИО"
<div class="col-8"></div> name="fio"
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div> class="u-input u-input-rectangle"/>
</div> </div>
</form> <div class="u-form-group u-label-top u-form-group-4">
<label class="u-label u-text-custom-color-1 u-label-4">Номер телефона</label>
<input
type="text"
name="telephone"
class="u-input u-input-rectangle"
placeholder="Введите номер телефона"/>
</div>
<div class="u-form-group u-label-top u-form-group-5">
<label class="u-label u-text-custom-color-1 u-label-5">Пароль</label>
<input
type="password"
placeholder="Введите пароль"
name="password"
class="u-input u-input-rectangle"/>
</div>
<div class="u-align-center u-form-group u-form-submit u-label-top"
style="padding: 120px">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Зарегистрироваться" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -5,6 +5,7 @@ namespace HotelContracts.SearchModels
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? HeadwaiterId { get; set; } public int? HeadwaiterId { get; set; }
public int? ConferenceId { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
} }

View File

@ -4,6 +4,7 @@ namespace HotelContracts.SearchModels
public class DinnerSearchModel public class DinnerSearchModel
{ {
public string? DinnerName { get; set; } public string? DinnerName { get; set; }
public int? HeadwaiterId { get; set; }
public int? Id { get; set; } public int? Id { get; set; }
} }
} }

View File

@ -6,7 +6,7 @@ namespace HotelContracts.SearchModels
public string? HeadwaiterFIO { get; set; } public string? HeadwaiterFIO { get; set; }
public string? HeadwaiterPassword { get; set; } public string? HeadwaiterPassword { get; set; }
public string? HeadwaiterEmail { get; set; }
public string? HeadwaiterLogin { get; set; } public string? HeadwaiterLogin { get; set; }
public int? Id { get; set; } public int? Id { get; set; }
} }

View File

@ -4,6 +4,8 @@ namespace HotelContracts.SearchModels
public class RoomSearchModel public class RoomSearchModel
{ {
public string? RoomName { get; set; } public string? RoomName { get; set; }
public int? HeadwaiterId { get; set; }
public int? MealPlanId { get; set; }
public int? Id { get; set; } public int? Id { get; set; }
} }
} }

View File

@ -9,7 +9,7 @@ namespace HotelDataBaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-VG5USAH\SQLEXPRESS;Initial Catalog=HotelDataBaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-V0ON61E\SQLEXPRESS;Initial Catalog=HotelDataBaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -51,13 +51,26 @@ namespace HotelDataBaseImplement.Implemets
public List<DinnerViewModel> GetFilteredList(DinnerSearchModel model) public List<DinnerViewModel> GetFilteredList(DinnerSearchModel model)
{ {
if (string.IsNullOrEmpty(model.DinnerName)) if (string.IsNullOrEmpty(model.DinnerName) && !model.HeadwaiterId.HasValue)
{ {
return new(); return new();
} }
using var context = new HotelDataBase(); using var context = new HotelDataBase();
if (model.HeadwaiterId.HasValue)
{
return context.Dinners
.Include(x => x.RoomDinners)
.ThenInclude(x => x.Room)
.Include(x => x.ConferenceBookingDinners)
.ThenInclude(x => x.ConferenceBooking)
.Where(x => x.DinnerName.Contains(model.DinnerName))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
return context.Dinners return context.Dinners
.Include(x => x.RoomDinners) .Include(x => x.RoomDinners)
.ThenInclude(x => x.Room) .ThenInclude(x => x.Room)

View File

@ -43,20 +43,20 @@ namespace HotelDataBaseImplement.Implemets
.FirstOrDefault(x => x.Id == model.Id)? .FirstOrDefault(x => x.Id == model.Id)?
.GetViewModel; .GetViewModel;
if (!string.IsNullOrEmpty(model.HeadwaiterLogin) && !string.IsNullOrEmpty(model.HeadwaiterPassword)) if (!string.IsNullOrEmpty(model.HeadwaiterEmail) && !string.IsNullOrEmpty(model.HeadwaiterPassword))
return context.Headwaiters return context.Headwaiters
.Include(x => x.ConferenceBookings) .Include(x => x.ConferenceBookings)
.Include(x => x.Dinners) .Include(x => x.Dinners)
.Include(x => x.Rooms) .Include(x => x.Rooms)
.FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin) && x.HeadwaiterPassword.Equals(model.HeadwaiterPassword))? .FirstOrDefault(x => x.HeadwaiterEmail.Equals(model.HeadwaiterEmail) && x.HeadwaiterPassword.Equals(model.HeadwaiterPassword))?
.GetViewModel; .GetViewModel;
if (!string.IsNullOrEmpty(model.HeadwaiterLogin)) if (!string.IsNullOrEmpty(model.HeadwaiterEmail))
return context.Headwaiters return context.Headwaiters
.Include(x => x.ConferenceBookings) .Include(x => x.ConferenceBookings)
.Include(x => x.Dinners) .Include(x => x.Dinners)
.Include(x => x.Rooms) .Include(x => x.Rooms)
.FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin))? .FirstOrDefault(x => x.HeadwaiterEmail.Equals(model.HeadwaiterEmail))?
.GetViewModel; .GetViewModel;
return null; return null;

View File

@ -34,13 +34,26 @@ namespace HotelDataBaseImplement.Implemets
public RoomViewModel? GetElement(RoomSearchModel model) public RoomViewModel? GetElement(RoomSearchModel model)
{ {
if (!model.Id.HasValue) if (!model.Id.HasValue && !model.HeadwaiterId.HasValue)
{ {
return null; return null;
} }
using var context = new HotelDataBase(); using var context = new HotelDataBase();
if (model.HeadwaiterId.HasValue)
{
return context.Rooms
.Include(x => x.Dinners)
.ThenInclude(x => x.Dinner)
.ThenInclude(x => x.ConferenceBookingDinners)
.ThenInclude(x => x.ConferenceBooking)
.Include(x => x.MealPlan)
.Include(x => x.Headwaiter)
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
.GetViewModel;
}
return context.Rooms return context.Rooms
.Include(x => x.Dinners) .Include(x => x.Dinners)
.ThenInclude(x => x.Dinner) .ThenInclude(x => x.Dinner)

View File

@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace HotelDataBaseImplement.Migrations namespace HotelDataBaseImplement.Migrations
{ {
[DbContext(typeof(HotelDataBase))] [DbContext(typeof(HotelDataBase))]
[Migration("20230405210621_InitialCreate")] [Migration("20230515204810_coursework")]
partial class InitialCreate partial class coursework
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -137,7 +137,7 @@ namespace HotelDataBaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<double>("DinnetPrice") b.Property<double>("DinnerPrice")
.HasColumnType("float"); .HasColumnType("float");
b.Property<int>("HeadwaiterId") b.Property<int>("HeadwaiterId")

View File

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace HotelDataBaseImplement.Migrations namespace HotelDataBaseImplement.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class InitialCreate : Migration public partial class coursework : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
@ -53,7 +53,7 @@ namespace HotelDataBaseImplement.Migrations
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
HeadwaiterId = table.Column<int>(type: "int", nullable: false), HeadwaiterId = table.Column<int>(type: "int", nullable: false),
DinnerName = table.Column<string>(type: "nvarchar(max)", nullable: false), DinnerName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DinnetPrice = table.Column<double>(type: "float", nullable: false) DinnerPrice = table.Column<double>(type: "float", nullable: false)
}, },
constraints: table => constraints: table =>
{ {

View File

@ -134,7 +134,7 @@ namespace HotelDataBaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<double>("DinnetPrice") b.Property<double>("DinnerPrice")
.HasColumnType("float"); .HasColumnType("float");
b.Property<int>("HeadwaiterId") b.Property<int>("HeadwaiterId")

View File

@ -40,6 +40,8 @@ namespace HotelDataBaseImplement.Models
return new ConferenceBooking() return new ConferenceBooking()
{ {
Id = model.Id, Id = model.Id,
ConferenceId = model.ConferenceId,
HeadwaiterId = model.HeadwaiterId,
Dinners = model.ConferenceBookingDinners.Select(x => new ConferenceBookingDinner Dinners = model.ConferenceBookingDinners.Select(x => new ConferenceBookingDinner
{ {
Dinner = context.Dinners.First(y => y.Id == x.Key), Dinner = context.Dinners.First(y => y.Id == x.Key),
@ -49,12 +51,15 @@ namespace HotelDataBaseImplement.Models
public void Update(ConferenceBookingBindingModel model) public void Update(ConferenceBookingBindingModel model)
{ {
ConferenceId = model.ConferenceId;
HeadwaiterId = model.HeadwaiterId;
} }
public ConferenceBookingViewModel GetViewModel => new() public ConferenceBookingViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
ConferenceId = ConferenceId,
HeadwaiterId = HeadwaiterId,
ConferenceBookingDinners = ConferenceBookingDinners ConferenceBookingDinners = ConferenceBookingDinners
}; };

View File

@ -39,6 +39,7 @@ namespace HotelDataBaseImplement.Models
{ {
Id = model.Id, Id = model.Id,
DinnerName = model.DinnerName, DinnerName = model.DinnerName,
HeadwaiterId = model.HeadwaiterId,
DinnerPrice = model.DinnerPrice DinnerPrice = model.DinnerPrice
}; };
} }
@ -48,6 +49,7 @@ namespace HotelDataBaseImplement.Models
{ {
Id = model.Id, Id = model.Id,
DinnerName = model.DinnerName, DinnerName = model.DinnerName,
HeadwaiterId = model.HeadwaiterId,
DinnerPrice = model.DinnerPrice DinnerPrice = model.DinnerPrice
}; };
} }
@ -57,6 +59,7 @@ namespace HotelDataBaseImplement.Models
{ {
return; return;
} }
HeadwaiterId = model.HeadwaiterId;
DinnerName = model.DinnerName; DinnerName = model.DinnerName;
DinnerPrice = model.DinnerPrice; DinnerPrice = model.DinnerPrice;
} }
@ -64,6 +67,7 @@ namespace HotelDataBaseImplement.Models
{ {
Id = Id, Id = Id,
DinnerName = DinnerName, DinnerName = DinnerName,
HeadwaiterId = HeadwaiterId,
DinnerPrice = DinnerPrice DinnerPrice = DinnerPrice
}; };
} }

View File

@ -50,6 +50,8 @@ namespace HotelDataBaseImplement.Models
RoomName = model.RoomName, RoomName = model.RoomName,
RoomFrame = model.RoomFrame, RoomFrame = model.RoomFrame,
RoomPrice = model.RoomPrice, RoomPrice = model.RoomPrice,
HeadwaiterId = model.HeadwaiterId,
MealPlanId = model.MealPlanId,
Dinners = model.RoomDinners.Select(x => new RoomDinner Dinners = model.RoomDinners.Select(x => new RoomDinner
{ {
Dinner = context.Dinners.First(y => y.Id == x.Key), Dinner = context.Dinners.First(y => y.Id == x.Key),
@ -62,6 +64,8 @@ namespace HotelDataBaseImplement.Models
RoomName = model.RoomName; RoomName = model.RoomName;
RoomFrame = model.RoomFrame; RoomFrame = model.RoomFrame;
RoomPrice = model.RoomPrice; RoomPrice = model.RoomPrice;
HeadwaiterId = model.HeadwaiterId;
MealPlanId = model.MealPlanId;
} }
public RoomViewModel GetViewModel => new() public RoomViewModel GetViewModel => new()
@ -69,6 +73,8 @@ namespace HotelDataBaseImplement.Models
Id = Id, Id = Id,
RoomName = RoomName, RoomName = RoomName,
RoomFrame = RoomFrame, RoomFrame = RoomFrame,
HeadwaiterId = HeadwaiterId,
MealPlanId = MealPlanId,
RoomPrice = RoomPrice, RoomPrice = RoomPrice,
RoomDinners = RoomDinners RoomDinners = RoomDinners
}; };

View File

@ -25,7 +25,7 @@ namespace HotelRestApi.Controllers
{ {
return _logic.ReadElement(new HeadwaiterSearchModel return _logic.ReadElement(new HeadwaiterSearchModel
{ {
HeadwaiterEmail = login, //HeadwaiterEmail = login,
HeadwaiterPassword = password HeadwaiterPassword = password
}); });
} }

View File

@ -89,7 +89,7 @@ namespace HotelRestApi.Controllers
{ {
return _dinner.ReadList(new DinnerSearchModel return _dinner.ReadList(new DinnerSearchModel
{ {
HeadwaiterId = headwaiterId, //HeadwaiterId = headwaiterId,
}); });
} }
catch (Exception ex) catch (Exception ex)
@ -123,7 +123,7 @@ namespace HotelRestApi.Controllers
{ {
return _room.ReadList(new RoomSearchModel return _room.ReadList(new RoomSearchModel
{ {
HeadwaiterId = headwaiterId, //HeadwaiterId = headwaiterId,
}); });
} }
catch (Exception ex) catch (Exception ex)