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

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";
}
<head>
<link rel="stylesheet" href="~/css/entry.css" asp-append-version="true" />
</head>
<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>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
</div>
<div class="u-form-group u-label-top u-form-group-1">
<label class="u-label u-text-custom-color-1 u-label-1">Электронная почта</label>
<input
type="text"
placeholder="Введите свой логин"
name="login"
class="u-input u-input-rectangle u-input-1"/>
</div>
<div class="u-form-group u-label-top u-form-group-2">
<label class="u-label u-text-custom-color-1 u-label-2">Пароль</label>
<input
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>

View File

@ -7,17 +7,44 @@
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Заказы</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
}
</div>
<head>
<link rel="stylesheet" href="~/css/mainpage.css" asp-append-version="true" />
</head>
<section class="u-clearfix u-section-1" id="sec-83a8">
<div class="u-clearfix u-sheet u-sheet-1">
<div class="u-clearfix u-expanded-width u-layout-wrap u-layout-wrap-1">
<div class="u-layout">
<div class="u-layout-col">
<div
class="u-container-style u-layout-cell u-size-30 u-layout-cell-1"
>
<div
class="u-container-layout u-valign-bottom u-container-layout-1"
>
<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";
}
<head>
<link rel="stylesheet" href="~/css/register.css" asp-append-version="true" />
</head>
<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>
<form method="post">
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8"><input type="text" name="fio" /></div>
</div>
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-4">Электронная почта:</div>
<div class="col-8"><input type="text" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Номер телефона:</div>
<div class="col-8"><input type="text" name="telephone" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
</div>
</form>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Логин</label>
<input
type="text"
placeholder="Введите логин"
name="login"
class="u-input u-input-rectangle"/>
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Электронная почта</label>
<input
type="email"
placeholder="Введите электронную почту"
name="email"
class="u-input u-input-rectangle"/>
</div>
<div class="u-form-group u-label-top u-form-group-3">
<label class="u-label u-text-custom-color-1 u-label-3">ФИО</label>
<input
type="text"
placeholder="Введите ФИО"
name="fio"
class="u-input u-input-rectangle"/>
</div>
<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? HeadwaiterId { get; set; }
public int? ConferenceId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ namespace HotelDataBaseImplement
{
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);
}

View File

@ -51,13 +51,26 @@ namespace HotelDataBaseImplement.Implemets
public List<DinnerViewModel> GetFilteredList(DinnerSearchModel model)
{
if (string.IsNullOrEmpty(model.DinnerName))
if (string.IsNullOrEmpty(model.DinnerName) && !model.HeadwaiterId.HasValue)
{
return new();
}
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
.Include(x => x.RoomDinners)
.ThenInclude(x => x.Room)

View File

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

View File

@ -34,13 +34,26 @@ namespace HotelDataBaseImplement.Implemets
public RoomViewModel? GetElement(RoomSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && !model.HeadwaiterId.HasValue)
{
return null;
}
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
.Include(x => x.Dinners)
.ThenInclude(x => x.Dinner)

View File

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

View File

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace HotelDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class coursework : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -53,7 +53,7 @@ namespace HotelDataBaseImplement.Migrations
.Annotation("SqlServer:Identity", "1, 1"),
HeadwaiterId = table.Column<int>(type: "int", 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 =>
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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