готовый CRUD и привязка

This commit is contained in:
Salikh 2024-05-28 22:05:22 +04:00
parent 95a732593a
commit b3a3c573f2
31 changed files with 762 additions and 252 deletions

View File

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HotelBusinessLogic.BusinessLogic namespace HotelBusinessLogic.BusinessLogic
@ -16,6 +17,7 @@ namespace HotelBusinessLogic.BusinessLogic
{ {
private readonly int _loginMaxLength = 25; private readonly int _loginMaxLength = 25;
private readonly int _passwordMaxLength = 50; private readonly int _passwordMaxLength = 50;
private readonly int _passwordMinLength = 5;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrganiserStorage _organiserStorage; private readonly IOrganiserStorage _organiserStorage;
@ -138,9 +140,9 @@ namespace HotelBusinessLogic.BusinessLogic
{ {
throw new ArgumentNullException("Нет пароля организатора", nameof(model.OrganiserPassword)); throw new ArgumentNullException("Нет пароля организатора", nameof(model.OrganiserPassword));
} }
if (model.OrganiserPassword.Length > _passwordMaxLength) if (model.OrganiserPassword.Length > _passwordMaxLength || model.OrganiserPassword.Length < _passwordMinLength || !Regex.IsMatch(model.OrganiserPassword, @"^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$"))
{ {
throw new ArgumentNullException("Пароль превышает допустимое количество символов", nameof(model.OrganiserPassword)); throw new ArgumentNullException("Пароль превышает допустимое количество символов или их недостаточно", nameof(model.OrganiserPassword));
} }
_logger.LogInformation("Organiser. OrganiserFIO: {OrganiserFIO}. OrganiserLogin: {OrganiserLogin}. OrganiserNumber: {OrganiserNumber}.OrganiserEmail: {OrganiserEmail}.OrganiserPassword: {OrganiserPassword}.Id: {Id}", _logger.LogInformation("Organiser. OrganiserFIO: {OrganiserFIO}. OrganiserLogin: {OrganiserLogin}. OrganiserNumber: {OrganiserNumber}.OrganiserEmail: {OrganiserEmail}.OrganiserPassword: {OrganiserPassword}.Id: {Id}",
model.OrganiserFIO, model.OrganiserLogin, model.OrganiserNumber, model.OrganiserEmail, model.OrganiserPassword, model.Id); model.OrganiserFIO, model.OrganiserLogin, model.OrganiserNumber, model.OrganiserEmail, model.OrganiserPassword, model.Id);

View File

@ -114,7 +114,14 @@ namespace HotelBusinessLogic.BusinessLogic
throw new ArgumentNullException("Нет ФИО участника", nameof(model.ParticipantFIO)); throw new ArgumentNullException("Нет ФИО участника", nameof(model.ParticipantFIO));
if (string.IsNullOrEmpty (model.Number)) if (string.IsNullOrEmpty (model.Number))
throw new ArgumentNullException("Нет номера участника", nameof(model.Number)); throw new ArgumentNullException("Нет номера участника", nameof(model.Number));
var elementName = _participantStorage.GetElement(new ParticipantSearchModel
{
ParticipantFIO = model.ParticipantFIO
});
if (elementName != null && elementName.Id != model.Id)
{
throw new InvalidOperationException("Участник с таким именем уже есть");
}
_logger.LogInformation("Participant. FIO:{FIO}.Number:{Number}. Id:{Id}", model.ParticipantFIO, model.Number, model.Id); _logger.LogInformation("Participant. FIO:{FIO}.Number:{Number}. Id:{Id}", model.ParticipantFIO, model.Number, model.Id);
} }
} }

View File

@ -14,11 +14,14 @@ namespace HotelContracts.ViewModels
public int Id { get; set; } public int Id { get; set; }
public int AdministratorId { get; set; } public int AdministratorId { get; set; }
public int? ConferenceId { get; set; } public int? ConferenceId { get; set; }
[DisplayName("Название комнаты")]
public string PlaceСonference { get; set; } = string.Empty; public string PlaceСonference { get; set; } = string.Empty;
[DisplayName("Дата конференции")] [DisplayName("Дата конференции")]
public DateTime? DateСonference { get; set; } public DateTime? DateСonference { get; set; }
public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; } = new(); public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; } = new();
public ConferenceBookingViewModel() { } public ConferenceBookingViewModel() { }
[JsonConstructor] [JsonConstructor]
public ConferenceBookingViewModel(Dictionary<int, DinnerViewModel> ConferenceBookingDinners) public ConferenceBookingViewModel(Dictionary<int, DinnerViewModel> ConferenceBookingDinners)
{ {

View File

@ -5,6 +5,7 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
namespace HotelContracts.ViewModels namespace HotelContracts.ViewModels
{ {
@ -24,6 +25,11 @@ namespace HotelContracts.ViewModels
public Dictionary<int, IParticipantModel> ConferenceParticipants { get; set; } = new(); public Dictionary<int, IParticipantModel> ConferenceParticipants { get; set; } = new();
//public Dictionary<int, IConferenceBookingModel> ConferenceConferenceBooking { get; set; } = new(); public ConferenceViewModel() { }
[JsonConstructor]
public ConferenceViewModel(Dictionary<int, ParticipantViewModel> ConferenceParticipants)
{
this.ConferenceParticipants = ConferenceParticipants.ToDictionary(x => x.Key, x => x.Value as IParticipantModel);
}
} }
} }

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Newtonsoft.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HotelContracts.ViewModels namespace HotelContracts.ViewModels
@ -21,6 +22,16 @@ namespace HotelContracts.ViewModels
public int OrganiserId { get; set; } public int OrganiserId { get; set; }
public Dictionary<int, IParticipantModel> MealPlanParticipants { get; set; } = new(); public Dictionary<int, IParticipantModel> MealPlanParticipants { get; set; } = new();
//public Dictionary<int, IRoomModel> MealPlanRooms { get; set; } = new(); public MealPlanViewModel()
{
MealPlanParticipants = new Dictionary<int, IParticipantModel>();
}
[JsonConstructor]
public MealPlanViewModel(Dictionary<int, ParticipantViewModel> MealPlanParticipants)
{
this.MealPlanParticipants = MealPlanParticipants?.ToDictionary(x => x.Key, x => x.Value as IParticipantModel)
?? new Dictionary<int, IParticipantModel>();
}
} }
} }

View File

@ -63,7 +63,15 @@ namespace HotelDataBaseImplement.Implements
.Include(x => x.Conferences) .Include(x => x.Conferences)
.FirstOrDefault(x => x.OrganiserEmail.Equals(model.OrganiserEmail))? .FirstOrDefault(x => x.OrganiserEmail.Equals(model.OrganiserEmail))?
.GetViewModel; .GetViewModel;
if (!string.IsNullOrEmpty(model.OrganiserLogin) && string.IsNullOrEmpty(model.OrganiserEmail) && !string.IsNullOrEmpty(model.OrganiserPassword))
{
return context.Organisers
.Include(x => x.MealPlans)
.Include(x => x.Participants)
.Include(x => x.Conferences)
.FirstOrDefault(x => x.OrganiserLogin.Equals(model.OrganiserLogin) && x.OrganiserPassword.Equals(model.OrganiserPassword))?
.GetViewModel;
}
return null; return null;
} }

View File

@ -44,9 +44,8 @@ namespace HotelDataBaseImplement.Models
{ {
if (_conferenceParticipents == null) if (_conferenceParticipents == null)
{ {
using var context = new HotelDataBase(); _conferenceParticipents = Participants
_conferenceParticipents = Participants.ToDictionary(x => x.ParticipantId, x => (context.Participants .ToDictionary(x => x.ParticipantId, x => (x.Participant as IParticipantModel));
.FirstOrDefault(y => y.Id == x.ParticipantId)! as IParticipantModel));
} }
return _conferenceParticipents; return _conferenceParticipents;
} }
@ -89,7 +88,11 @@ namespace HotelDataBaseImplement.Models
public void UpdateMembers(HotelDataBase context, ConferenceBindingModel model) public void UpdateMembers(HotelDataBase context, ConferenceBindingModel model)
{ {
var сonferenceParticipants = context.ConferenceParticipants.Where(rec => rec.ConferenceId == model.Id).ToList(); var сonferenceParticipants = context.ConferenceParticipants.Where(rec => rec.ConferenceId == model.Id).ToList();
var list = new List<int>();
foreach (var x in model.ConferenceParticipants)
{
list.Add(x.Key);
}
if (сonferenceParticipants != null && сonferenceParticipants.Count > 0) if (сonferenceParticipants != null && сonferenceParticipants.Count > 0)
{ {
context.ConferenceParticipants.RemoveRange(сonferenceParticipants.Where(rec => !model.ConferenceParticipants.ContainsKey(rec.ParticipantId))); context.ConferenceParticipants.RemoveRange(сonferenceParticipants.Where(rec => !model.ConferenceParticipants.ContainsKey(rec.ParticipantId)));

View File

@ -38,9 +38,8 @@ namespace HotelDataBaseImplement.Models
{ {
if( _mealPlanParticipants == null ) if( _mealPlanParticipants == null )
{ {
using var contex = new HotelDataBase(); _mealPlanParticipants = Participants
_mealPlanParticipants = Participants.ToDictionary(x => x.ParticipantId, x => (contex.Participants .ToDictionary(x => x.ParticipantId, x => (x.Participant as IParticipantModel));
.FirstOrDefault(y => y.Id == x.ParticipantId)! as IParticipantModel));
} }
return _mealPlanParticipants; return _mealPlanParticipants;
} }
@ -80,7 +79,11 @@ namespace HotelDataBaseImplement.Models
public void UpdateParticipants(HotelDataBase context, MealPlanBindingModel model) public void UpdateParticipants(HotelDataBase context, MealPlanBindingModel model)
{ {
var mealPlanParticipants = context.MealPlanParticipants.Where(rec => rec.MealPlanId == model.Id).ToList(); var mealPlanParticipants = context.MealPlanParticipants.Where(rec => rec.MealPlanId == model.Id).ToList();
var list = new List<int>();
foreach (var x in model.MealPlanParticipants)
{
list.Add(x.Key);
}
if (mealPlanParticipants != null && mealPlanParticipants.Count > 0) if (mealPlanParticipants != null && mealPlanParticipants.Count > 0)
{ {
context.MealPlanParticipants.RemoveRange(mealPlanParticipants.Where(rec => !model.MealPlanParticipants.ContainsKey(rec.ParticipantId))); context.MealPlanParticipants.RemoveRange(mealPlanParticipants.Where(rec => !model.MealPlanParticipants.ContainsKey(rec.ParticipantId)));

View File

@ -1,4 +1,5 @@
using HotelContracts.ViewModels; using HotelContracts.ViewModels;
using HotelDataBaseImplement.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;
@ -10,6 +11,7 @@ namespace HotelOrganiserApp
private static readonly HttpClient _organiser = new(); private static readonly HttpClient _organiser = new();
public static OrganiserViewModel? Organiser { get; set; } = null; public static OrganiserViewModel? Organiser { get; set; } = null;
public static ParticipantViewModel? Participant { get; set; } = null;
public static void Connect(IConfiguration configuration) public static void Connect(IConfiguration configuration)
{ {

View File

@ -1,5 +1,13 @@
using HotelOrganiserApp.Models; using HotelBusinessLogic.BusinessLogic;
using HotelContracts.BindingModels;
using HotelContracts.BusinessLogicsContracts;
using HotelContracts.SearchModels;
using HotelContracts.ViewModels;
using HotelDataBaseImplement.Models;
using HotelDataModels.Models;
using HotelOrganiserApp.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.Diagnostics; using System.Diagnostics;
namespace HotelOrganiserApp.Controllers namespace HotelOrganiserApp.Controllers
@ -7,10 +15,12 @@ namespace HotelOrganiserApp.Controllers
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
private readonly IParticipantLogic _participant;
public HomeController(ILogger<HomeController> logger) public HomeController(ILogger<HomeController> logger, IParticipantLogic participant)
{ {
_logger = logger; _logger = logger;
_participant = participant;
} }
public IActionResult Index() public IActionResult Index()
@ -18,96 +28,488 @@ namespace HotelOrganiserApp.Controllers
return View(); return View();
} }
[HttpGet]
public IActionResult Privacy() public IActionResult Privacy()
{ {
return View(); if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
} }
return View(APIClient.Organiser);
}
[HttpPost]
public void Privacy(string login, string email, string password, string fio, string phone)
{
if (APIClient.Organiser == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(phone))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/organiser/updatedata", new OrganiserBindingModel
{
Id = APIClient.Organiser.Id,
OrganiserFIO = fio,
OrganiserLogin = login,
OrganiserPassword = password,
OrganiserEmail = email,
OrganiserNumber = phone
});
APIClient.Organiser.OrganiserFIO = fio;
APIClient.Organiser.OrganiserLogin = login;
APIClient.Organiser.OrganiserPassword = password;
APIClient.Organiser.OrganiserEmail = email;
APIClient.Organiser.OrganiserNumber = phone;
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Register() public IActionResult Register()
{ {
return View(); return View();
} }
[HttpPost]
public void Register(string fio, string login, string email, string password, string phone)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(email))
{
throw new Exception("Введите все данные");
}
APIClient.PostRequest("api/organiser/register", new OrganiserBindingModel
{
OrganiserFIO = fio,
OrganiserLogin = login,
OrganiserPassword = password,
OrganiserEmail = email,
OrganiserNumber = phone
});
Response.Redirect("Enter");
return;
}
[HttpGet]
public IActionResult Enter() public IActionResult Enter()
{ {
return View(); return View();
} }
[HttpPost]
public void Enter(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIClient.Organiser = APIClient.GetRequest<OrganiserViewModel>($"api/organiser/login?login={login}&password={password}");
if (APIClient.Organiser == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
/*-------------------------Participant---------------------------------*/
public IActionResult Participants() public IActionResult Participants()
{ {
return View(); if (APIClient.Organiser == null)
}
public IActionResult MealPlans()
{ {
return View(); return Redirect("~/Home/Enter");
} }
return View(APIClient.GetRequest<List<ParticipantViewModel>>($"api/main/getparticipantlist?organiserId={APIClient.Organiser.Id}"));
public IActionResult Conferences()
{
return View();
} }
public IActionResult CreateParticipant() public IActionResult CreateParticipant()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
return View(); return View();
} }
[HttpPost]
public void CreateParticipant(string participantFIO, string number)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
if (string.IsNullOrEmpty(participantFIO) || string.IsNullOrEmpty(number))
{
throw new Exception("Введите данные");
}
APIClient.PostRequest("api/main/createparticipant", new ParticipantBindingModel
{
ParticipantFIO = participantFIO,
Number = number,
OrganiserId = APIClient.Organiser.Id,
});
Response.Redirect("Participants");
}
public IActionResult UpdateParticipant() public IActionResult UpdateParticipant()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Participants = APIClient.GetRequest<List<ParticipantViewModel>>($"api/main/getparticipantlist?organiserId={APIClient.Organiser.Id}");
return View(); return View();
} }
[HttpPost]
public void UpdateParticipant(int participant, string participantFIO, string number)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
if (string.IsNullOrEmpty(participantFIO) || string.IsNullOrEmpty(number))
{
throw new Exception("Данные пустые");
}
APIClient.PostRequest("api/main/updateparticipant", new ParticipantBindingModel
{
Id = participant,
ParticipantFIO = participantFIO,
Number = number,
OrganiserId = APIClient.Organiser.Id,
});
Response.Redirect("Participants");
}
public IActionResult DeleteParticipant() public IActionResult DeleteParticipant()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Participants = APIClient.GetRequest<List<ParticipantViewModel>>($"api/main/getparticipantlist?organiserId={APIClient.Organiser.Id}");
return View(); return View();
} }
[HttpPost]
public void DeleteParticipant(int participant)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/main/deleteparticipant", new ParticipantBindingModel
{
Id = participant
});
Response.Redirect("Participants");
}
[HttpGet]
public ParticipantViewModel? GetParticipant(int participantId)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
var result = APIClient.GetRequest<ParticipantViewModel>($"api/main/getparticipant?participantid={participantId}");
if (result == null)
{
return default;
}
return result;
}
/*-------------------------------MealPlans--------------------*/
public IActionResult MealPlans()
{
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<MealPlanViewModel>>($"api/main/getmealplanlist?organiserId={APIClient.Organiser.Id}"));
}
public IActionResult CreateMealPlan() public IActionResult CreateMealPlan()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
var list = _participant.ReadList(new ParticipantSearchModel { OrganiserId = APIClient.Organiser.Id });
var simpParticipant = list.Select(x => new { ParticipantId = x.Id, ParticipantFIO = x.ParticipantFIO });
ViewBag.Participants = new MultiSelectList(simpParticipant, "ParticipantId", "ParticipantFIO");
return View(); return View();
} }
[HttpPost]
public void CreateMealPlan(string mealPlanName, int mealPlanPrice, int[] participants)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
if (string.IsNullOrEmpty(mealPlanName) || mealPlanPrice <= 0 || participants.Length == 0)
{
throw new Exception("Введите данные");
}
Dictionary<int, IParticipantModel> MealPlanParticipants = new Dictionary<int, IParticipantModel>();
foreach (int id in participants)
{
MealPlanParticipants.Add(id, _participant.ReadElement(new ParticipantSearchModel { Id = id }));
}
APIClient.PostRequest("api/main/createmealplan", new MealPlanBindingModel
{
MealPlanName = mealPlanName,
MealPlanPrice = mealPlanPrice,
OrganiserId = APIClient.Organiser.Id,
});
for (int i = 0; i < participants.Length; i++)
{
APIClient.PostRequest("api/main/AddParticipantToMealPlan", Tuple.Create(
new MealPlanSearchModel() { MealPlanName = mealPlanName },
new ParticipantViewModel() { Id = participants[i] }
));
}
Response.Redirect("MealPlans");
}
public IActionResult UpdateMealPlan() public IActionResult UpdateMealPlan()
{ {
return View(); if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
} }
ViewBag.MealPlans = APIClient.GetRequest<List<MealPlanViewModel>>($"api/main/getmealplanlist?organiserId={APIClient.Organiser.Id}");
ViewBag.Participants = APIClient.GetRequest<List<ParticipantViewModel>>($"api/main/getparticipantlist?organiserId={APIClient.Organiser.Id}");
return View();
}
[HttpPost]
public void UpdateMealPlan(int mealPlan, string mealPlanName, int mealPlanPrice, List<int> participants)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
if (string.IsNullOrEmpty(mealPlanName) || mealPlanPrice <= 0)
{
throw new Exception("Введите данные");
}
Dictionary<int, IParticipantModel> participant = new Dictionary<int, IParticipantModel>();
foreach (int din in participants)
{
participant.Add(din, new ParticipantSearchModel { Id = din } as IParticipantModel);
}
APIClient.PostRequest("api/main/updatemealplan", new MealPlanBindingModel
{
Id = mealPlan,
MealPlanName = mealPlanName,
MealPlanPrice = mealPlanPrice,
OrganiserId = APIClient.Organiser.Id,
MealPlanParticipants = participant,
});
Response.Redirect("MealPlans");
}
public IActionResult DeleteMealPlan() public IActionResult DeleteMealPlan()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/main/getmealplanlist?organiserId={APIClient.Organiser.Id}");
return View(); return View();
} }
[HttpPost]
public void DeleteMealPlan(int room)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/main/deletemealplan", new MealPlanBindingModel
{
Id = room
});
Response.Redirect("MealPlans");
}
[HttpGet]
public Tuple<MealPlanViewModel, List<Tuple<string, double>>>? GetMealPlan(int mealPlanId)
{
if (APIClient.Organiser == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
var result = APIClient.GetRequest<Tuple<MealPlanViewModel, List<Tuple<string, double>>>>($"api/main/getmealplan?mealplanid={mealPlanId}");
if (result == null)
{
return default;
}
return result;
}
/*----------------------------Conferences--------------------*/
public IActionResult Conferences()
{
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<ConferenceViewModel>>($"api/main/getconferencelist?organiserId={APIClient.Organiser.Id}"));
}
public IActionResult CreateConference() public IActionResult CreateConference()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
var list = _participant.ReadList(new ParticipantSearchModel { OrganiserId = APIClient.Organiser.Id });
var simpParticipant = list.Select(x => new { ParticipantId = x.Id, ParticipantFIO = x.ParticipantFIO });
ViewBag.Participants = new MultiSelectList(simpParticipant, "ParticipantId", "ParticipantFIO");
return View(); return View();
} }
[HttpPost]
public void CreateConference(string conferenceName, string subject, int[] participants, DateTime startDate)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
if (string.IsNullOrEmpty(conferenceName))
{
throw new Exception("Введите данные");
}
Dictionary<int, IParticipantModel> ConferenceParticipants = new Dictionary<int, IParticipantModel>();
foreach (int id in participants)
{
ConferenceParticipants.Add(id, _participant.ReadElement(new ParticipantSearchModel { Id = id }));
}
APIClient.PostRequest("api/main/createconference", new ConferenceBindingModel
{
ConferenceName = conferenceName,
Subject = subject,
StartDate = startDate,
OrganiserId = APIClient.Organiser.Id,
});
for (int i = 0; i < participants.Length; i++)
{
APIClient.PostRequest("api/main/AddParticipantToConference", Tuple.Create(
new ConferenceSearchModel() { ConferenceName = conferenceName },
new ParticipantViewModel() { Id = participants[i] }
));
}
Response.Redirect("Conferences");
}
public IActionResult UpdateConference() public IActionResult UpdateConference()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Conferences = APIClient.GetRequest<List<ConferenceViewModel>>($"api/main/getconferencelist?organiserid={APIClient.Organiser.Id}");
ViewBag.Participants = APIClient.GetRequest<List<ParticipantViewModel>>($"api/main/getparticipantlist?organiserid={APIClient.Organiser.Id}");
return View(); return View();
} }
[HttpPost]
public void UpdateConference(int conference, string conferenceName, string subject, DateTime startDate, List<int> participants)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
if (string.IsNullOrEmpty(conferenceName))
{
throw new Exception("Введите данные");
}
Dictionary<int, IParticipantModel> participant = new Dictionary<int, IParticipantModel>();
foreach (int din in participants)
{
participant.Add(din, new ParticipantSearchModel { Id = din } as IParticipantModel);
}
APIClient.PostRequest("api/main/updateConference", new ConferenceBindingModel
{
Id = conference,
ConferenceName = conferenceName,
Subject = subject,
StartDate = startDate,
OrganiserId = APIClient.Organiser.Id,
ConferenceParticipants = participant,
});
Response.Redirect("Conferences");
}
public IActionResult DeleteConference() public IActionResult DeleteConference()
{ {
return View(); if (APIClient.Organiser == null)
}
public IActionResult AddParticipantToConferences()
{ {
return Redirect("~/Home/Enter");
}
ViewBag.Conferences = APIClient.GetRequest<List<ConferenceViewModel>>($"api/main/getconferencelist?organiserid={APIClient.Organiser.Id}");
return View(); return View();
} }
public IActionResult AddParticipantToMealPlan() [HttpPost]
public void DeleteConference(int conference)
{ {
return View(); if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/main/deleteconference", new ConferenceBindingModel
{
Id = conference
});
Response.Redirect("Conferences");
} }
[HttpGet]
public ConferenceViewModel? GetConference(int conferenceId)
{
if (APIClient.Organiser == null)
{
throw new Exception("Необходима авторизация");
}
var result = APIClient.GetRequest<ConferenceViewModel>($"api/main/getconference?conferenceid={conferenceId}");
if (result == null)
{
return default;
}
return result;
}
/*--------------------------AddConferenceBookingToConference------------------------------*/
[HttpGet]
public IActionResult AddConferenceBookingToConference() public IActionResult AddConferenceBookingToConference()
{ {
if (APIClient.Organiser == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Conferences = APIClient.GetRequest<List<ConferenceViewModel>>($"api/main/getconferencelist?organiserid={APIClient.Organiser.Id}");
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getConferenceBookings");
return View(); return View();
} }
[HttpPost]
public void AddConferenceBookingToConference(int conference, int conferencebooking, DateTime dateСonference)
{
if (APIClient.Organiser == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
var conferenceBookingElem = APIClient.GetRequest<ConferenceBookingViewModel>($"api/main/getConferenceBookingById?conferenceBookingId={conferencebooking}");
APIClient.PostRequest("api/main/updateconferenceBooking", new ConferenceBookingBindingModel
{
Id = conferencebooking,
ConferenceId = conference,
PlaceСonference = conferenceBookingElem.PlaceСonference,
DateСonference = conferenceBookingElem.DateСonference,
AdministratorId = conferenceBookingElem.AdministratorId,
});
Response.Redirect("Conferences");
}
public IActionResult ListParticipantToPdfFile() public IActionResult ListParticipantToPdfFile()
{ {
return View(); return View();

View File

@ -1,6 +1,15 @@
using HotelBusinessLogic.BusinessLogic;
using HotelContracts.BusinessLogicsContracts;
using HotelContracts.StoragesContracts;
using HotelDataBaseImplement.Implements;
using HotelOrganiserApp; using HotelOrganiserApp;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTransient<IParticipantStorage, ParticipantStorage>();
builder.Services.AddTransient<IParticipantLogic, ParticipantLogic>();
builder.Services.AddTransient<IMealPlanStorage, MealPlanStorage>();
builder.Services.AddTransient<IConferenceStorage, ConferenceStorage>();
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();

View File

@ -1,4 +1,7 @@
@{ @using HotelContracts.ViewModels;
@using HotelDataModels.Models;
@{
ViewData["Title"] = "AddConferenceBookingToConference"; ViewData["Title"] = "AddConferenceBookingToConference";
} }
<head> <head>
@ -25,11 +28,11 @@
<form method="post"> <form method="post">
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Наименование конференции: </label> <label class="u-label u-text-custom-color-1 u-label-1">Наименование конференции: </label>
<select class="form-control"></select> <select id="conference" name="conference" class="form-control" asp-items="@(new SelectList(@ViewBag.Conferences, "Id", "ConferenceName"))"></select>
</div> </div>
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Место конференции: </label> <label class="u-label u-text-custom-color-1 u-label-1">Место конференции: </label>
<select class="form-control"></select> <select id="conferencebooking" name="conferencebooking" class="form-control" asp-items="@(new SelectList(@ViewBag.ConferenceBookings, "Id", "PlaceСonference"))"></select>
</div> </div>
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Начало: </label> <label class="u-label u-text-custom-color-1 u-label-1">Начало: </label>

View File

@ -1,66 +0,0 @@
@{
ViewData["Title"] = "AddParticipantToConferences";
}
<head>
<style>
.general_style {
display: flex;
justify-content: space-between;
}
.button_action {
display: flex;
background-color: #5a9ad6;
}
.button_action:hover {
background-color: #225df2;
color: white;
}
.text-center {
margin-bottom: 30px;
}
.ord{
display: flex;
justify-content: center !important;
font-size: 20px;
}
.list-words-add{
margin-top: 30px;
}
</style>
</head>
<div class="text-center">
<h2 class="ord"> Добавить участника в конференцию</h2>
</div>
<form method="post">
<div class="form-group">
<label for="room">Выберите конференцию</label>
<select id="room" name="room" class="form-control">
</select>
</div>
<div class="form-group">
<label class="list-words-add">Выберите участника</label>
<table class="table">
<thead>
<tr>
<th>ФИО участника</th>
<th>Номер телефона</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<br>
<div class="general_style">
<div class="button">
<button class="btn button_action">Сохранить</button>
</div>
<div class="button">
<a asp-area="" asp-controller="Home" asp-action="Conferences" class="btn button_action">Назад</a>
</div>
</div>
</form>

View File

@ -1,67 +0,0 @@
@{
ViewData["Title"] = "AddParticipantToMealPlan";
}
<head>
<style>
.general_style {
display: flex;
justify-content: space-between;
}
.button_action {
display: flex;
background-color: #5a9ad6;
}
.button_action:hover {
background-color: #225df2;
color: white;
}
.text-center {
margin-bottom: 30px;
}
.ord {
display: flex;
justify-content: center !important;
font-size: 20px;
}
.list-words-add {
margin-top: 30px;
}
</style>
</head>
<div class="text-center">
<h2 class="ord"> Добавить участника в план питания</h2>
</div>
<form method="post">
<div class="form-group">
<label for="room">Выберите план питания</label>
<select id="room" name="room" class="form-control">
</select>
</div>
<div class="form-group">
<label class="list-words-add">Выберите участника</label>
<table class="table">
<thead>
<tr>
<th>ФИО участника</th>
<th>Номер телефона</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<br>
<div class="general_style">
<div class="button">
<button class="btn button_action">Сохранить</button>
</div>
<div class="button">
<a asp-area="" asp-controller="Home" asp-action="MealPlans" class="btn button_action">Назад</a>
</div>
</div>
</form>

View File

@ -1,4 +1,8 @@
@{ @using HotelContracts.ViewModels
@model List<ConferenceViewModel>
@{
ViewData["Title"] = "Conferences"; ViewData["Title"] = "Conferences";
} }
@ -40,6 +44,23 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var item in Model)
{
<tr style="height: 75px">
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ConferenceName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Subject)
</td>
<td>
@Html.DisplayFor(modelItem => item.StartDate)
</td>
</tr>
}
</tbody> </tbody>
</table> </table>
<div class="general_style"> <div class="general_style">
@ -55,14 +76,6 @@
<a asp-area="" asp-controller="Home" asp-action="DeleteConference" <a asp-area="" asp-controller="Home" asp-action="DeleteConference"
class="btn button_action">Удалить</a> class="btn button_action">Удалить</a>
</div> </div>
<div class="button">
<a asp-area="" asp-controller="Home" asp-action="AddParticipantToConferences"
class="btn button_action">Добавить участника</a>
</div>
<div class="button">
<a asp-area="" asp-controller="Home" asp-action="AddConferenceBookingToConference"
class="btn button_action">Привязка к брони по конференции</a>
</div>
</div> </div>
</div> </div>
</section> </section>

View File

@ -1,4 +1,8 @@
@{ @using HotelContracts.ViewModels
@model ParticipantViewModel
@{
ViewData["Title"] = "CreateConference"; ViewData["Title"] = "CreateConference";
} }
<style> <style>
@ -30,11 +34,24 @@
<h2 class="u-text u-text-custom-color-1 u-text-default u-text-1"> Добавить конференцию</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">
<input type="text" placeholder="Введите название конференции" class="form-control" /> <input type="text" name="conferenceName" placeholder="Введите название конференции" class="form-control" />
<input type="text" placeholder="Введите тематику конференции" class="form-control" /> <input type="text" name="subject" placeholder="Введите тематику конференции" class="form-control" />
<div class="form-control">
<label class="form-control">Начало</label>
<input type="datetime-local"
placeholder="Выберите дату начала"
name="startDate"
class="form-control" />
</div>
<div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Участники: </label>
<div>
@Html.ListBox("participants", (MultiSelectList)ViewBag.Participants, new { @class = "form-control", size = "10" })
</div>
</div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
<button class="btn button_action">Сохранить</button> <button type="submit" class="btn button_action">Сохранить</button>
</div> </div>
<div class="button"> <div class="button">
<a asp-area="" asp-controller="Home" asp-action="Conferences" class="btn button_action">Назад</a> <a asp-area="" asp-controller="Home" asp-action="Conferences" class="btn button_action">Назад</a>

View File

@ -1,4 +1,8 @@
@{ @using HotelContracts.ViewModels
@model ParticipantViewModel
@{
ViewData["Title"] = "CreateMealPlan"; ViewData["Title"] = "CreateMealPlan";
} }
<style> <style>
@ -30,11 +34,17 @@
<h2 class="u-text u-text-custom-color-1 u-text-default u-text-1"> Добавить план питания</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">
<input type="text" placeholder="Введите название плана питания" class="form-control" /> <input type="text" name="mealPlanName" placeholder="Введите название плана питания" class="form-control" />
<input type="text" placeholder="Введите стоимость плана питания" class="form-control" /> <input type="text" name="mealPlanPrice" placeholder="Введите стоимость плана питания" class="form-control" step="1000" />
<div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Участники: </label>
<div>
@Html.ListBox("participants", (MultiSelectList)ViewBag.Participants, new { @class = "form-control", size = "10" })
</div>
</div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
<button class="btn button_action">Сохранить</button> <button class="btn button_action" type="submit">Сохранить</button>
</div> </div>
<div class="button"> <div class="button">
<a asp-area="" asp-controller="Home" asp-action="MealPlans" class="btn button_action">Назад</a> <a asp-area="" asp-controller="Home" asp-action="MealPlans" class="btn button_action">Назад</a>

View File

@ -29,11 +29,11 @@
<h2 class="u-text u-text-custom-color-1 u-text-default u-text-1"> Добавить участника</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">
<input type="text" placeholder="Введите ФИО участника" class="form-control" /> <input type="text" placeholder="Введите ФИО участника" name="participantFIO" class="form-control" />
<input type="text" placeholder="Введите номер телефона участника" class="form-control" /> <input type="text" placeholder="Введите номер телефона участника" name="number" class="form-control" />
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
<button class="btn button_action">Сохранить</button> <button type="submit" class="btn button_action">Сохранить</button>
</div> </div>
<div class="button"> <div class="button">
<a asp-area="" asp-controller="Home" asp-action="Participants" class="btn button_action">Назад</a> <a asp-area="" asp-controller="Home" asp-action="Participants" class="btn button_action">Назад</a>

View File

@ -36,11 +36,11 @@
<form method="post"> <form method="post">
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Конференции: </label> <label class="u-label u-text-custom-color-1 u-label-1">Конференции: </label>
<select class="form-control"></select> <select id="conference" name="conference" class="form-control" asp-items="@(new SelectList(@ViewBag.Conferences, "Id", "ConferenceName"))"></select>
</div> </div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
<button class="btn button_action">Сохранить</button> <button type="submit" class="btn button_action">Удалить</button>
</div> </div>
<div class="button"> <div class="button">
<a asp-area="" asp-controller="Home" asp-action="Conferences" class="btn button_action">Назад</a> <a asp-area="" asp-controller="Home" asp-action="Conferences" class="btn button_action">Назад</a>

View File

@ -36,11 +36,11 @@
<form method="post"> <form method="post">
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Планы питания: </label> <label class="u-label u-text-custom-color-1 u-label-1">Планы питания: </label>
<select class="form-control"></select> <select id="mealPlan" name="mealPlan" class="form-control" asp-items="@(new SelectList(@ViewBag.MealPlans, "Id", "MealPlanName"))"></select>
</div> </div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
<button class="btn button_action">Сохранить</button> <button type="submit" class="btn button_action">Сохранить</button>
</div> </div>
<div class="button"> <div class="button">
<a asp-area="" asp-controller="Home" asp-action="MealPlans" class="btn button_action">Назад</a> <a asp-area="" asp-controller="Home" asp-action="MealPlans" class="btn button_action">Назад</a>

View File

@ -36,11 +36,11 @@
<form method="post"> <form method="post">
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Участники: </label> <label class="u-label u-text-custom-color-1 u-label-1">Участники: </label>
<select class="form-control"></select> <select id="participant" name="participant" class="form-control" asp-items="@(new SelectList(@ViewBag.Participants, "Id", "ParticipantFIO"))"></select>
</div> </div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
<button class="btn button_action">Сохранить</button> <button class="btn button_action" type="submit">Удалить</button>
</div> </div>
<div class="button"> <div class="button">
<a asp-area="" asp-controller="Home" asp-action="Participants" class="btn button_action">Назад</a> <a asp-area="" asp-controller="Home" asp-action="Participants" class="btn button_action">Назад</a>

View File

@ -40,10 +40,10 @@
<h2 class="text-center mb-5">Регистрация</h2> <h2 class="text-center mb-5">Регистрация</h2>
<form> <form>
<div data-mdb-input-init class="form-outline mb-4"> <div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Логин/Почта" /> <input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Логин/Почта" name="login" />
</div> </div>
<div data-mdb-input-init class="form-outline mb-4"> <div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Пароль" /> <input type="password" id="form3Example1cg" class="form-control form-control-lg" placeholder="Пароль" name="password"/>
</div> </div>
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<button type="submit" <button type="submit"

View File

@ -1,4 +1,8 @@
@{ @using HotelContracts.ViewModels
@model List<MealPlanViewModel>
@{
ViewData["Title"] = "MealPlans"; ViewData["Title"] = "MealPlans";
} }
@ -40,6 +44,20 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var item in Model)
{
<tr style="height: 75px">
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.MealPlanName)
</td>
<td>
@Html.DisplayFor(modelItem => item.MealPlanPrice)
</td>
</tr>
}
</tbody> </tbody>
</table> </table>
<div class="general_style"> <div class="general_style">
@ -55,10 +73,6 @@
<a asp-area="" asp-controller="Home" asp-action="DeleteMealPlan" <a asp-area="" asp-controller="Home" asp-action="DeleteMealPlan"
class="btn button_action">Удалить</a> class="btn button_action">Удалить</a>
</div> </div>
<div class="button">
<a asp-area="" asp-controller="Home" asp-action="AddParticipantToMealPlan"
class="btn button_action">Добавить участника</a>
</div>
</div> </div>
</div> </div>
</section> </section>

View File

@ -1,4 +1,8 @@
@{ @using HotelContracts.ViewModels
@model List<ParticipantViewModel>
@{
ViewData["Title"] = "Participants"; ViewData["Title"] = "Participants";
} }
@ -40,6 +44,20 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var item in Model)
{
<tr style="height: 75px">
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ParticipantFIO)
</td>
<td>
@Html.DisplayFor(modelItem => item.Number)
</td>
</tr>
}
</tbody> </tbody>
</table> </table>
<div class="general_style"> <div class="general_style">

View File

@ -1,6 +1,6 @@
@using HotelContracts.ViewModels @using HotelContracts.ViewModels
@model AdministratorViewModel @model OrganiserViewModel
@{ @{
ViewData["Title"] = "Privacy"; ViewData["Title"] = "Privacy";
@ -30,31 +30,31 @@
<div class="form-group row mt-3"> <div class="form-group row mt-3">
<label class="col-sm-3 col-form-label labels">Логин</label> <label class="col-sm-3 col-form-label labels">Логин</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" class="form-control" name="login"> <input type="text" class="form-control" name="login" value="@Model.OrganiserLogin">
</div> </div>
</div> </div>
<div class="form-group row mt-3"> <div class="form-group row mt-3">
<label class="col-sm-3 col-form-label labels">Почта</label> <label class="col-sm-3 col-form-label labels">Почта</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" class="form-control"> <input type="email" name="email" class="form-control" value="@Model.OrganiserEmail">
</div> </div>
</div> </div>
<div class="form-group row mt-3"> <div class="form-group row mt-3">
<label class="col-sm-3 col-form-label labels">Пароль</label> <label class="col-sm-3 col-form-label labels">Пароль</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="password" class="form-control"> <input type="password" class="form-control" name="password" value="@Model.OrganiserPassword">
</div> </div>
</div> </div>
<div class="form-group row mt-3"> <div class="form-group row mt-3">
<label class="col-sm-3 col-form-label labels">ФИО</label> <label class="col-sm-3 col-form-label labels">ФИО</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" class="form-control"> <input type="text" name="fio" class="form-control" value="@Model.OrganiserFIO" />
</div> </div>
</div> </div>
<div class="form-group row mt-3"> <div class="form-group row mt-3">
<label class="col-sm-3 col-form-label labels">Номер</label> <label class="col-sm-3 col-form-label labels">Номер</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" class="form-control"> <input type="text" name="phone" class="form-control" value="@Model.OrganiserNumber" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -36,19 +36,19 @@
<h2 class="text-center mb-5">Регистрация</h2> <h2 class="text-center mb-5">Регистрация</h2>
<form> <form>
<div data-mdb-input-init class="form-outline mb-4"> <div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="ФИО" /> <input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="ФИО" name="fio" />
</div> </div>
<div data-mdb-input-init class="form-outline mb-4"> <div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Логин" /> <input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Логин" name="login" />
</div> </div>
<div data-mdb-input-init class="form-outline mb-4"> <div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Эл. почта" /> <input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Эл. почта" name="email" />
</div> </div>
<div data-mdb-input-init class="form-outline mb-4"> <div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Номер телефона" /> <input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Номер телефона" name="phone" />
</div> </div>
<div data-mdb-input-init class="form-outline mb-4"> <div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Пароль" /> <input type="text" id="form3Example1cg" class="form-control form-control-lg" placeholder="Пароль" name="password" />
</div> </div>
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<button type="submit" <button type="submit"

View File

@ -36,13 +36,20 @@
<form method="post"> <form method="post">
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Конференции: </label> <label class="u-label u-text-custom-color-1 u-label-1">Конференции: </label>
<select class="form-control"></select> <select id="conference" name="conference" class="form-control" asp-items="@(new SelectList(@ViewBag.Conferences, "Id", "ConferenceName"))"></select>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" placeholder="Введите название конференции" class="form-control" /> <input type="text" name="conferenceName" placeholder="Введите название конференции" class="form-control" />
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" placeholder="Введите тематику конференции" class="form-control" /> <input type="text" name="subject" placeholder="Введите тематику конференции" class="form-control" />
</div>
<div class="form-control">
<label class="form-control">Начало</label>
<input type="datetime-local"
placeholder="Выберите дату начала"
name="startDate"
class="form-control" />
</div> </div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
@ -53,3 +60,28 @@
</div> </div>
</div> </div>
</form> </form>
@section Scripts
{
<script>
function check() {
var conference = $('#conference').val();
if (conference {
$.ajax({
method: "GET",
url: "/Home/GetConference",
data: { conferenceId: conference },
success: function (result) {
$('#conferenceName').val(result.ConferenceName);
$('#subject').val(result.Subject);
$('#startDate').val(result.StartDate);
}
});
};
}
check();
$('#conference').on('change', function () {
check();
});
</script>
}

View File

@ -36,13 +36,13 @@
<form method="post"> <form method="post">
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Планы питания: </label> <label class="u-label u-text-custom-color-1 u-label-1">Планы питания: </label>
<select class="form-control"></select> <select id="mealPlan" name="mealPlan" class="form-control" asp-items="@(new SelectList(@ViewBag.MealPlans, "Id", "MealPlanName"))"></select>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" placeholder="Введите название плана питания" class="form-control" /> <input name="mealPlanName" type="text" placeholder="Введите название плана питания" class="form-control" />
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" placeholder="Введите стоимость плана питания" class="form-control" /> <input name="mealPlanPrice" type="text" placeholder="Введите стоимость плана питания" class="form-control" step="1000" />
</div> </div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
@ -53,3 +53,27 @@
</div> </div>
</div> </div>
</form> </form>
@section Scripts
{
<script>
function check() {
var mealPlan = $('#mealPlan').val();
if (mealPlan) {
$.ajax({
method: "GET",
url: "/Home/GetMealPlan",
data: { mealPlanId: mealPlan },
success: function (result) {
$('#mealPlanName').val(result.MealPlanName);
$('#mealPlanPrice').val(result.MealPlanPrice);
}
});
};
}
check();
$('#mealPlan').on('change', function () {
check();
});
</script>
}

View File

@ -36,20 +36,44 @@
<form method="post"> <form method="post">
<div class="spisok"> <div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Участники: </label> <label class="u-label u-text-custom-color-1 u-label-1">Участники: </label>
<select class="form-control"></select> <select id="participant" name="participant" class="form-control" asp-items="@(new SelectList(@ViewBag.Participants, "Id", "ParticipantFIO"))"></select>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" placeholder="Введите ФИО участника" class="form-control" /> <input type="text" name="participantFIO" placeholder="Введите ФИО участника" class="form-control" />
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" placeholder="Введите номер телефона участника" class="form-control" /> <input type="text" name="number" placeholder="Введите номер телефона участника" class="form-control" />
</div> </div>
<div class="general_style"> <div class="general_style">
<div class="button"> <div class="button">
<button class="btn button_action">Сохранить</button> <button class="btn button_action" type="submit">Сохранить</button>
</div> </div>
<div class="button"> <div class="button">
<a asp-area="" asp-controller="Home" asp-action="Participants" class="btn button_action">Назад</a> <a asp-area="" asp-controller="Home" asp-action="Participants" class="btn button_action">Назад</a>
</div> </div>
</div> </div>
</form> </form>
@section Scripts
{
<script>
function check() {
var member = $('#participant').val();
if (member) {
$.ajax({
method: "GET",
url: "/Home/GetParticipant",
data: { memberId: member },
success: function (result) {
$('#participantFIO').val(result.participantFIO);
$('#number').val(result.number);
}
});
};
}
check();
$('#participant').on('change', function () {
check();
});
</script>
}

View File

@ -104,6 +104,9 @@
</li> </li>
</ul> </ul>
</li> </li>
<li class="nav-item punkt">
<a class="nav-link" asparea="" asp-controller="Home" asp-action="AddConferenceBookingToConference">Привязка к брони по конференции</a>
</li>
<li class="nav-item punkt"> <li class="nav-item punkt">
<a class="nav-link" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a> <a class="nav-link" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li> </li>

View File

@ -570,5 +570,34 @@ namespace HotelRestApi.Controllers
throw; throw;
} }
} }
[HttpGet]
public List<ConferenceBookingViewModel>? GetConferenceBookings()
{
try
{
return _conferenceBooking.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка конференций");
throw;
}
}
[HttpGet]
public ConferenceBookingViewModel GetConferenceBookingById(int conferenceBookingId)
{
try
{
var elem = _conferenceBooking.ReadElement(new ConferenceBookingSearchModel { Id = conferenceBookingId });
if (elem == null)
return null;
return elem;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения по id={Id}", conferenceBookingId);
throw;
}
}
} }
} }