работает список зарегистрированных пользователей
This commit is contained in:
parent
2539ec26b5
commit
3d709d3b57
@ -89,7 +89,6 @@ namespace EventVisitorClientApp.Controllers
|
||||
Name = name,
|
||||
Surname = surname,
|
||||
LastName = lastname,
|
||||
Role = role,
|
||||
OrganizationName = organizationName,
|
||||
Phone = phone,
|
||||
Email = login,
|
||||
@ -99,7 +98,6 @@ namespace EventVisitorClientApp.Controllers
|
||||
APIClient.Client.Name = name;
|
||||
APIClient.Client.Surname = surname;
|
||||
APIClient.Client.LastName = lastname;
|
||||
APIClient.Client.Role = role;
|
||||
APIClient.Client.OrganizationName = organizationName;
|
||||
APIClient.Client.Phone = phone;
|
||||
APIClient.Client.Email = login;
|
||||
@ -114,7 +112,7 @@ namespace EventVisitorClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(string login, string password, string surname, string name, string lastname, string role, string organizationName, string phone, string code)
|
||||
public void Register(string login, string password, string surname, string name, string lastname, string organizationName, string phone, string code)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login))
|
||||
{
|
||||
@ -136,83 +134,117 @@ namespace EventVisitorClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Ââåäèòå íàçâàíèå îðãàíèçàöèè");
|
||||
}
|
||||
if (string.IsNullOrEmpty(role))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ðîëü");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Organizer/Register", new OrganizerBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Surname = surname,
|
||||
LastName = lastname,
|
||||
Role = role,
|
||||
OrganizationName = organizationName,
|
||||
Phone = phone,
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
APIClient.PostRequest("api/Organizer/Register", new OrganizerBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Surname = surname,
|
||||
LastName = lastname,
|
||||
OrganizationName = organizationName,
|
||||
Phone = phone,
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
|
||||
public IActionResult MyEvents()
|
||||
{
|
||||
public IActionResult MyEvents()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<EventViewModel>>($"api/main/GetEventList?ClientId={APIClient.Client.Id}"));
|
||||
}
|
||||
public IActionResult CreateEvent()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
return View(APIClient.GetRequest<List<EventViewModel>>($"api/main/GetEventList?OrganizerId={APIClient.Client.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult ViewEvent(int id)
|
||||
public IActionResult Visitors(int id)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
|
||||
|
||||
return View(eventDetails);
|
||||
return View(APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}"));
|
||||
}
|
||||
|
||||
|
||||
public IActionResult RegistrationOnEvent(int id)
|
||||
{
|
||||
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
|
||||
public IActionResult CreateEvent()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
return View(eventDetails);
|
||||
}
|
||||
public IActionResult ViewEvent(int id)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void RegistrationOnEvent(int id, string name, string phone, string email, DateTime dayBirth)
|
||||
{
|
||||
APIClient.PostRequest("api/main/registrationonevent", new VisitorBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Phone = phone,
|
||||
Email = email,
|
||||
DayBirth = dayBirth.ToUniversalTime(),
|
||||
EventId = id,
|
||||
Status = "Çàðåãèñòèðîâàí"
|
||||
});
|
||||
Response.Redirect("ResultRegistration");
|
||||
}
|
||||
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ResultRegistration()
|
||||
return View(eventDetails);
|
||||
}
|
||||
|
||||
|
||||
public IActionResult RegistrationOnEvent(int id)
|
||||
{
|
||||
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
|
||||
|
||||
return View(eventDetails);
|
||||
}
|
||||
public IActionResult ResultRegistration()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void RegistrationOnEvent(int id, string name, string phone, string email, DateTime dayBirth)
|
||||
{
|
||||
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
|
||||
|
||||
if (eventDetails != null && eventDetails.FreePlaces > 0)
|
||||
{
|
||||
int updatedFreePlaces = eventDetails.FreePlaces - 1;
|
||||
|
||||
APIClient.PostRequest("api/main/registrationonevent", new VisitorBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Phone = phone,
|
||||
Email = email,
|
||||
DayBirth = dayBirth.ToUniversalTime(),
|
||||
EventId = id,
|
||||
Status = "Çàðåãèñòèðîâàí"
|
||||
});
|
||||
|
||||
// 4. Îáíîâèòå êîëè÷åñòâî ñâîáîäíûõ ìåñò
|
||||
APIClient.PostRequest("api/main/updateevent", new EventBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Name = eventDetails.Name,
|
||||
Description = eventDetails.Description,
|
||||
Type = eventDetails.Type,
|
||||
ContactPhone = eventDetails.ContactPhone,
|
||||
Address = eventDetails.Address,
|
||||
City = eventDetails.City,
|
||||
Status = eventDetails.Status,
|
||||
ContactEmail = eventDetails.ContactEmail,
|
||||
TimeEnd = eventDetails.TimeEnd.ToUniversalTime(),
|
||||
TimeStart = eventDetails.TimeStart.ToUniversalTime(),
|
||||
Date = eventDetails.Date.ToUniversalTime(),
|
||||
CountVisitors = eventDetails.CountVisitors,
|
||||
OrganizerId = eventDetails.OrganizerId,
|
||||
Link = eventDetails.Link,
|
||||
FreePlaces = updatedFreePlaces
|
||||
});
|
||||
Response.Redirect("ResultRegistration");
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect("NoFreePlaces");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateEvent(string name, string description, string type, string phone, string email, string address, string city, string status, int count, DateTime timestart, DateTime timeend)
|
||||
|
@ -40,16 +40,6 @@
|
||||
<input type="text" name="organizationName" class="form-control" id="InputCompany">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="InputRole" class="form-label" style="font-size: 24px">Выберите роль</label>
|
||||
<select name="role" class="form-control" id="InputRole" required>
|
||||
<option value="" disabled selected>Выберите роль</option>
|
||||
<option value="Организатор">Организатор</option>
|
||||
<option value="Регистратор">Регистратор</option>
|
||||
</select>
|
||||
<div class="invalid-feedback">Пожалуйста, выберите роль.</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="InputP" class="form-label" style="font-size: 24px">Введите номер телефона</label>
|
||||
<input type="text" name="phone" class="form-control" id="InputP" required>
|
||||
|
@ -2,9 +2,20 @@
|
||||
@model EventViewModel
|
||||
|
||||
@{
|
||||
Layout = null;
|
||||
ViewData["Title"] = "RegistrationOnEvent";
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - EventVisitorClientApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/EventVisitorClientApp.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<div class="container mt-5">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
@ -62,13 +73,15 @@
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<button type="submit" class="btn btn-dark btn-lg w-100">Зарегистрироваться</button>
|
||||
<button type="submit" class="btn btn-dark btn-lg w-100" onclick="submitForm()">Зарегистрироваться</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</html>
|
||||
|
||||
|
||||
<style>
|
||||
.containerenter {
|
||||
|
@ -1,7 +1,15 @@
|
||||
@{
|
||||
Layout = null;
|
||||
ViewData["Title"] = "Успешная регистрация";
|
||||
}
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - EventVisitorClientApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/EventVisitorClientApp.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<div class="container enter mt-5">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
@ -52,7 +52,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<a class="btn btn-dark btn-block mb-4" asp-action="RegistrationOnEvent" asp-route-id="@Model.Id">Страница с регистрацией</a>
|
||||
<button type="submit" class="btn btn-black btn-block">Зарегистрованные пользователи</button>
|
||||
<a class="btn btn-dark btn-block mb-4" asp-action="Visitors" asp-route-id="@Model.Id">Зарегистрированные пользователи</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -0,0 +1,72 @@
|
||||
@using EventVisitorLogic.ViewModels
|
||||
@model List<VisitorViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Зарегистрированные пользователи";
|
||||
}
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Зарегистрированные пользователи</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center mt-4">
|
||||
@{
|
||||
<table class="table table-striped table-bordered mt-4">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
<th>Почта</th>
|
||||
<th>Телефон</th>
|
||||
<th>Дата рождения</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.DisplayFor(modelItem => item.Name)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Email)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Phone)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.DayBirth)</td>
|
||||
<td>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="present_@item.Id" name="present_@item.Id" value="true">
|
||||
<label class="form-check-label" for="present_@item.Id">Да</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="not_present_@item.Id" name="not_present_@item.Id" value="true">
|
||||
<label class="form-check-label" for="not_present_@item.Id">Нет</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.table {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-light {
|
||||
background-color: #e9ecef; /* Светло-серый цвет */
|
||||
color: #495057; /* Тёмный текст для контраста */
|
||||
}
|
||||
|
||||
.btn-light:hover {
|
||||
background-color: #d3d3d3; /* Более тёмный светло-серый при наведении */
|
||||
}
|
||||
</style>
|
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace EventVisitorClientApp.Views.Home
|
||||
{
|
||||
public class VisitorsModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -42,11 +42,6 @@
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - EventVisitorClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
@ -46,6 +46,7 @@ namespace EventVisitorDatabase.Entities
|
||||
public int OrganizerId { get; set; }
|
||||
|
||||
public string Link { get; set; } = string.Empty;
|
||||
public virtual OrganizerEntity Organizer { get; set; }
|
||||
|
||||
|
||||
public static EventEntity? Create(EventBindingModel model)
|
||||
|
@ -22,8 +22,7 @@ namespace EventVisitorDatabase.Entities
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string OrganizationName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Role { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
@ -44,7 +43,6 @@ namespace EventVisitorDatabase.Entities
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Phone = model.Phone,
|
||||
Role = model.Role,
|
||||
Surname = model.Surname,
|
||||
LastName = model.LastName,
|
||||
OrganizationName = model.OrganizationName,
|
||||
@ -60,7 +58,6 @@ namespace EventVisitorDatabase.Entities
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Phone = model.Phone,
|
||||
Role = model.Role,
|
||||
Surname = model.Surname,
|
||||
LastName = model.LastName,
|
||||
OrganizationName = model.OrganizationName,
|
||||
@ -74,7 +71,6 @@ namespace EventVisitorDatabase.Entities
|
||||
{
|
||||
Name = model.Name;
|
||||
Phone = model.Phone;
|
||||
Role = model.Role;
|
||||
Surname = model.Surname;
|
||||
LastName = model.LastName;
|
||||
OrganizationName = model.OrganizationName;
|
||||
@ -86,7 +82,6 @@ namespace EventVisitorDatabase.Entities
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Phone = Phone,
|
||||
Role = Role,
|
||||
Surname = Surname,
|
||||
LastName = LastName,
|
||||
OrganizationName = OrganizationName,
|
||||
|
@ -35,6 +35,15 @@ namespace EventVisitorDatabase.Implements
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<EventViewModel> GetFilteredList(EventBindingModel model)
|
||||
{
|
||||
using var context = new EventVisitorDbContext();
|
||||
|
||||
return context.Events
|
||||
.Include(x => x.Organizer)
|
||||
.Where(x => x.OrganizerId == model.OrganizerId).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<EventViewModel> GetFullList()
|
||||
{
|
||||
using var context = new EventVisitorDbContext();
|
||||
|
@ -27,6 +27,19 @@ namespace EventVisitorDatabase.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<VisitorViewModel> GetFilteredList(VisitorBindingModel model)
|
||||
{
|
||||
if (model.EventId < 0)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new EventVisitorDbContext();
|
||||
|
||||
return context.Visitors
|
||||
.Include(x => x.Event)
|
||||
.Where(x => x.EventId == model.EventId).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public VisitorViewModel? GetElement(VisitorBindingModel model)
|
||||
{
|
||||
if (model.Id < 0)
|
||||
|
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace EventVisitorDatabase.Migrations
|
||||
{
|
||||
[DbContext(typeof(EventVisitorDbContext))]
|
||||
[Migration("20241104161237_InitialCreate")]
|
||||
[Migration("20241105194655_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -89,6 +89,8 @@ namespace EventVisitorDatabase.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganizerId");
|
||||
|
||||
b.ToTable("Events");
|
||||
});
|
||||
|
||||
@ -124,10 +126,6 @@ namespace EventVisitorDatabase.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@ -174,6 +172,17 @@ namespace EventVisitorDatabase.Migrations
|
||||
b.ToTable("Visitors");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EventVisitorDatabase.Entities.EventEntity", b =>
|
||||
{
|
||||
b.HasOne("EventVisitorDatabase.Entities.OrganizerEntity", "Organizer")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrganizerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organizer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EventVisitorDatabase.Entities.VisitorEntity", b =>
|
||||
{
|
||||
b.HasOne("EventVisitorDatabase.Entities.EventEntity", "Event")
|
@ -12,6 +12,25 @@ namespace EventVisitorDatabase.Migrations
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Organizers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Surname = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
LastName = table.Column<string>(type: "text", nullable: false),
|
||||
OrganizationName = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Phone = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Organizers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Events",
|
||||
columns: table => new
|
||||
@ -37,26 +56,12 @@ namespace EventVisitorDatabase.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Events", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Organizers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Surname = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
LastName = table.Column<string>(type: "text", nullable: false),
|
||||
OrganizationName = table.Column<string>(type: "text", nullable: false),
|
||||
Role = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Phone = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Organizers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Events_Organizers_OrganizerId",
|
||||
column: x => x.OrganizerId,
|
||||
principalTable: "Organizers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -83,6 +88,11 @@ namespace EventVisitorDatabase.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Events_OrganizerId",
|
||||
table: "Events",
|
||||
column: "OrganizerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visitors_EventId",
|
||||
table: "Visitors",
|
||||
@ -92,14 +102,14 @@ namespace EventVisitorDatabase.Migrations
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Organizers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Visitors");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Events");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Organizers");
|
||||
}
|
||||
}
|
||||
}
|
@ -86,6 +86,8 @@ namespace EventVisitorDatabase.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganizerId");
|
||||
|
||||
b.ToTable("Events");
|
||||
});
|
||||
|
||||
@ -121,10 +123,6 @@ namespace EventVisitorDatabase.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@ -171,6 +169,17 @@ namespace EventVisitorDatabase.Migrations
|
||||
b.ToTable("Visitors");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EventVisitorDatabase.Entities.EventEntity", b =>
|
||||
{
|
||||
b.HasOne("EventVisitorDatabase.Entities.OrganizerEntity", "Organizer")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrganizerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organizer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EventVisitorDatabase.Entities.VisitorEntity", b =>
|
||||
{
|
||||
b.HasOne("EventVisitorDatabase.Entities.EventEntity", "Event")
|
||||
|
@ -14,15 +14,8 @@ namespace EventVisitorLogic.BindingModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string OrganizationName { get; set; } = string.Empty;
|
||||
public string Role { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<int, IEventModel> OrganizerEvent
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,7 @@ namespace EventVisitorLogic.Logic
|
||||
|
||||
public List<EventViewModel>? ReadList(EventBindingModel? model)
|
||||
{
|
||||
//var list = model == null ? _eventStorage.GetFullList() : _eventStorage.GetFilteredList(model);
|
||||
var list = _eventStorage.GetFullList();
|
||||
var list = model == null ? _eventStorage.GetFullList() : _eventStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
|
@ -95,10 +95,6 @@ namespace EventVisitorLogic.Logic
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия компании", nameof(model.OrganizationName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Role))
|
||||
{
|
||||
throw new ArgumentNullException("Нет роли", nameof(model.Role));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Phone))
|
||||
{
|
||||
throw new ArgumentNullException("Нет телефона", nameof(model.Phone));
|
||||
|
@ -54,8 +54,7 @@ namespace EventVisitorLogic.Logic
|
||||
|
||||
public List<VisitorViewModel>? ReadList(VisitorBindingModel? model)
|
||||
{
|
||||
//var list = model == null ? _organizerStorage.GetFullList() : _organizerStorage.GetFilteredList(model);
|
||||
var list = _visitorStorage.GetFullList();
|
||||
var list = model == null ? _visitorStorage.GetFullList() : _visitorStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
|
@ -12,7 +12,7 @@ namespace EventVisitorLogic.StoragesContracts
|
||||
public interface IEventStorage
|
||||
{
|
||||
List<EventViewModel> GetFullList();
|
||||
// List<Event> GetFilteredList(Event model);
|
||||
List<EventViewModel> GetFilteredList(EventBindingModel model);
|
||||
EventViewModel? GetElement(EventBindingModel model);
|
||||
EventViewModel? Insert(EventBindingModel model);
|
||||
EventViewModel? Update(EventBindingModel model);
|
||||
|
@ -12,7 +12,6 @@ namespace EventVisitorLogic.StoragesContracts
|
||||
public interface IOrganizerStorage
|
||||
{
|
||||
List<OrganizerViewModel> GetFullList();
|
||||
// List<Organizer> GetFilteredList(Organizer model);
|
||||
OrganizerViewModel? GetElement(OrganizerBindingModel model);
|
||||
OrganizerViewModel? Insert(OrganizerBindingModel model);
|
||||
OrganizerViewModel? Update(OrganizerBindingModel model);
|
||||
|
@ -12,7 +12,7 @@ namespace EventVisitorLogic.StoragesContracts
|
||||
public interface IVisitorStorage
|
||||
{
|
||||
List<VisitorViewModel> GetFullList();
|
||||
//List<Visitor> GetFilteredList(Visitor model);
|
||||
List<VisitorViewModel> GetFilteredList(VisitorBindingModel model);
|
||||
VisitorViewModel? GetElement(VisitorBindingModel model);
|
||||
VisitorViewModel? Insert(VisitorBindingModel model);
|
||||
VisitorViewModel? Update(VisitorBindingModel model);
|
||||
|
@ -14,7 +14,6 @@ namespace EventVisitorLogic.ViewModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string OrganizationName { get; set; } = string.Empty;
|
||||
public string Role { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
@ -13,7 +13,6 @@ namespace EventVisitorModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string OrganizationName { get; set; } = string.Empty;
|
||||
public string Role { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
@ -40,6 +40,26 @@ namespace EventVisitorRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<VisitorViewModel>? GetVisitorList(int eventId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (eventId == null)
|
||||
{
|
||||
return _visitor.ReadList(null);
|
||||
}
|
||||
return _visitor.ReadList(new VisitorBindingModel
|
||||
{
|
||||
EventId = eventId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateEvent(EventBindingModel model)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user