2024-04-29 00:18:57 +04:00
|
|
|
|
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
|
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
|
|
using HotelBusinessLogic.BusinessLogics;
|
2024-03-31 22:00:39 +04:00
|
|
|
|
using HotelContracts.BindingModels;
|
2024-04-29 00:18:57 +04:00
|
|
|
|
using HotelContracts.BusinessLogicsContracts;
|
|
|
|
|
using HotelContracts.SearchModels;
|
2024-03-31 13:06:09 +04:00
|
|
|
|
using HotelContracts.ViewModels;
|
2024-04-29 00:18:57 +04:00
|
|
|
|
using HotelDataModels.Models;
|
2024-03-31 13:06:09 +04:00
|
|
|
|
using HotelOrganiserApp.Models;
|
2024-03-31 10:37:51 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace HotelOrganiserApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
2024-04-29 00:18:57 +04:00
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
2024-03-31 10:37:51 +04:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
2024-03-31 13:06:09 +04:00
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-03-31 10:37:51 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 13:06:09 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string login, string email, string password, string surname, string name, string patronymic, string telephone)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(patronymic))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин, пароль, фамилию, имя и отчество");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/organiser/register", new OrganiserBindingModel
|
|
|
|
|
{
|
|
|
|
|
OrganiserSurname = surname,
|
|
|
|
|
OrganiserName = name,
|
|
|
|
|
OrganiserPatronymic = patronymic,
|
|
|
|
|
OrganiserLogin = login,
|
|
|
|
|
OrganiserPassword = password,
|
|
|
|
|
OrganiserEmail = email,
|
|
|
|
|
OrganiserPhoneNumber = telephone
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Response.Redirect("Enter");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 10:37:51 +04:00
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
[HttpPost]
|
2024-03-31 13:06:09 +04:00
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
public IActionResult Privacy()
|
2024-03-31 10:37:51 +04:00
|
|
|
|
{
|
2024-03-31 22:00:39 +04:00
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIClient.Organiser);
|
2024-03-31 10:37:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Privacy(string login, string email, string password, string surname, string name, string patronymic, string telephone)
|
2024-03-31 10:37:51 +04:00
|
|
|
|
{
|
2024-03-31 22:00:39 +04:00
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(patronymic))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин, пароль, фамилию, имя и отчество");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/organiser/updatedata", new OrganiserBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = APIClient.Organiser.Id,
|
|
|
|
|
OrganiserSurname = surname,
|
|
|
|
|
OrganiserName = name,
|
|
|
|
|
OrganiserPatronymic = patronymic,
|
|
|
|
|
OrganiserLogin = login,
|
|
|
|
|
OrganiserPassword = password,
|
|
|
|
|
OrganiserEmail = email,
|
|
|
|
|
OrganiserPhoneNumber = telephone
|
|
|
|
|
});
|
2024-03-31 10:37:51 +04:00
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
APIClient.Organiser.OrganiserSurname = surname;
|
|
|
|
|
APIClient.Organiser.OrganiserName = name;
|
|
|
|
|
APIClient.Organiser.OrganiserPatronymic = patronymic;
|
|
|
|
|
APIClient.Organiser.OrganiserLogin = login;
|
|
|
|
|
APIClient.Organiser.OrganiserPassword = password;
|
|
|
|
|
APIClient.Organiser.OrganiserEmail = email;
|
|
|
|
|
APIClient.Organiser.OrganiserPhoneNumber = telephone;
|
|
|
|
|
Response.Redirect("Index");
|
2024-03-31 10:37:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
public IActionResult ListMembers()
|
2024-03-31 10:37:51 +04:00
|
|
|
|
{
|
2024-03-31 22:00:39 +04:00
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-05-01 17:07:23 +04:00
|
|
|
|
return View(APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}"));
|
2024-03-31 10:37:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
public IActionResult CreateMember()
|
2024-03-31 10:37:51 +04:00
|
|
|
|
{
|
2024-03-31 22:00:39 +04:00
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-03-31 10:37:51 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-03-31 22:00:39 +04:00
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateMember(string memberSurname, string memberName, string memberPatronymic, string memberPhoneNumber)
|
2024-03-31 10:37:51 +04:00
|
|
|
|
{
|
2024-03-31 22:00:39 +04:00
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(memberSurname) || string.IsNullOrEmpty(memberName) || string.IsNullOrEmpty(memberPatronymic) || string.IsNullOrEmpty(memberPhoneNumber))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите фамилию, имя, отчество и номер телефона");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/member/createmember", new MemberBindingModel
|
|
|
|
|
{
|
|
|
|
|
MemberSurname = memberSurname,
|
|
|
|
|
MemberName = memberName,
|
|
|
|
|
MemberPatronymic = memberPatronymic,
|
|
|
|
|
MemberPhoneNumber = memberPhoneNumber,
|
|
|
|
|
OrganiserId = APIClient.Organiser.Id,
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListMembers");
|
2024-03-31 10:37:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
public IActionResult UpdateMember()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-05-01 17:07:23 +04:00
|
|
|
|
ViewBag.Members = APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}");
|
2024-03-31 22:00:39 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateMember(int member, string memberSurname, string memberName, string memberPatronymic, string memberPhoneNumber)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(memberSurname))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Фамилия не может быть пустая");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(memberName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Имя не может быть пустым");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(memberPatronymic))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Отчество не может быть пустым");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(memberPhoneNumber))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Номер телефона не может быть пустым");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
APIClient.PostRequest("api/member/updatemember", new MemberBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = member,
|
|
|
|
|
MemberSurname = memberSurname,
|
|
|
|
|
MemberName = memberName,
|
|
|
|
|
MemberPatronymic = memberPatronymic,
|
|
|
|
|
MemberPhoneNumber = memberPhoneNumber,
|
|
|
|
|
OrganiserId = APIClient.Organiser.Id,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Response.Redirect("ListMembers");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult DeleteMember()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-05-01 17:07:23 +04:00
|
|
|
|
ViewBag.Members = APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}");
|
2024-03-31 22:00:39 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteMember(int member)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/member/deletemember", new MemberBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = member
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListMembers");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public MemberViewModel? GetMember(int memberId)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
var result = APIClient.GetRequest<MemberViewModel>($"api/member/getmember?memberid={memberId}");
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
return default;
|
|
|
|
|
}
|
|
|
|
|
var memberSurname = result.MemberSurname;
|
|
|
|
|
var memberName = result.MemberName;
|
|
|
|
|
var memberPatronymic = result.MemberPatronymic;
|
|
|
|
|
var memberPhoneNumber = result.MemberPhoneNumber;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-06 22:06:46 +04:00
|
|
|
|
public IActionResult ListMealPlans()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-05-01 17:07:23 +04:00
|
|
|
|
return View(APIClient.GetRequest<List<MealPlanViewModel>>($"api/mealplan/getmealplans?organiserId={APIClient.Organiser.Id}"));
|
2024-04-06 22:06:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult CreateMealPlan()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-05-01 17:07:23 +04:00
|
|
|
|
ViewBag.Member = APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}");
|
2024-04-06 22:06:46 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2024-04-29 00:18:57 +04:00
|
|
|
|
public void CreateMealPlan(string mealPlanName, double mealPlanPrice, List<int> memberselect)
|
2024-04-06 22:06:46 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(mealPlanName) || string.IsNullOrEmpty(mealPlanPrice.ToString()))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите название");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(mealPlanPrice.ToString()))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите стоимость");
|
|
|
|
|
}
|
|
|
|
|
if (mealPlanPrice < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Стоимость не может быть отрицательной");
|
|
|
|
|
}
|
2024-04-29 00:18:57 +04:00
|
|
|
|
|
|
|
|
|
Dictionary<int, IMemberModel> member = new Dictionary<int, IMemberModel>();
|
|
|
|
|
foreach (int members in memberselect)
|
|
|
|
|
{
|
|
|
|
|
member.Add(members, new MemberSearchModel { Id = members } as IMemberModel);
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/mealplan/createmealplan", new MealPlanBindingModel
|
2024-04-06 22:06:46 +04:00
|
|
|
|
{
|
|
|
|
|
MealPlanName = mealPlanName,
|
2024-04-29 00:18:57 +04:00
|
|
|
|
MealPlanPrice = mealPlanPrice,
|
|
|
|
|
OrganiserId = APIClient.Organiser.Id,
|
|
|
|
|
MealPlanMembers = member
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListMealPlans");
|
2024-04-06 22:06:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult UpdateMealPlan()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-05-01 17:07:23 +04:00
|
|
|
|
ViewBag.MealPlans = APIClient.GetRequest<List<MealPlanViewModel>>($"api/mealplan/getmealplans?organiserId={APIClient.Organiser.Id}");
|
|
|
|
|
ViewBag.Member = APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}");
|
2024-04-06 22:06:46 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2024-04-29 00:18:57 +04:00
|
|
|
|
public void UpdateMealPlan(int mealPlan, string mealPlanName, double mealPlanPrice, List<int> memberselect)
|
2024-04-06 22:06:46 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(mealPlanName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Название не может быть пустым");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(mealPlanPrice.ToString()))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите стоимость");
|
|
|
|
|
}
|
|
|
|
|
if (mealPlanPrice < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Стоимость не может быть отрицательной");
|
|
|
|
|
}
|
2024-04-29 00:18:57 +04:00
|
|
|
|
Dictionary<int, IMemberModel> member = new Dictionary<int, IMemberModel>();
|
|
|
|
|
foreach (int members in memberselect)
|
|
|
|
|
{
|
|
|
|
|
member.Add(members, new MemberSearchModel { Id = members } as IMemberModel);
|
|
|
|
|
}
|
2024-04-06 22:06:46 +04:00
|
|
|
|
APIClient.PostRequest("api/mealplan/updatemealplan", new MealPlanBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = mealPlan,
|
|
|
|
|
MealPlanName = mealPlanName,
|
|
|
|
|
MealPlanPrice = mealPlanPrice,
|
2024-04-29 00:18:57 +04:00
|
|
|
|
OrganiserId = APIClient.Organiser.Id,
|
|
|
|
|
MealPlanMembers = member
|
2024-04-06 22:06:46 +04:00
|
|
|
|
});
|
2024-04-26 13:49:36 +04:00
|
|
|
|
Response.Redirect("ListMealPlans");
|
2024-04-06 22:06:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2024-05-02 00:55:35 +04:00
|
|
|
|
public Tuple<MealPlanViewModel, List<string>>? GetMealPlan(int mealPlanId)
|
2024-04-06 22:06:46 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
2024-05-02 00:55:35 +04:00
|
|
|
|
var result = APIClient.GetRequest<Tuple<MealPlanViewModel, List<string>>>($"api/mealPlan/getmealPlan?mealPlanId={mealPlanId}");
|
2024-04-06 22:06:46 +04:00
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
return default;
|
|
|
|
|
}
|
2024-05-02 00:55:35 +04:00
|
|
|
|
|
|
|
|
|
return result;
|
2024-04-06 22:06:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult DeleteMealPlan()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2024-05-01 17:07:23 +04:00
|
|
|
|
ViewBag.MealPlans = APIClient.GetRequest<List<MealPlanViewModel>>($"api/mealplan/getmealplans?organiserId={APIClient.Organiser.Id}");
|
2024-04-06 22:06:46 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteMealPlan(int mealPlan)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/mealplan/deletemealplan", new MealPlanBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = mealPlan
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListMealPlans");
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-02 00:55:35 +04:00
|
|
|
|
public IActionResult ListConferences()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIClient.GetRequest<List<ConferenceViewModel>>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult CreateConference()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Member = APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateConference(string conferenceName, DateTime startDate, List<int> memberselect)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(conferenceName) || string.IsNullOrEmpty(startDate.ToString()))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите название");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(startDate.ToString()))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите дату");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dictionary<int, IMemberModel> member = new Dictionary<int, IMemberModel>();
|
|
|
|
|
foreach (int members in memberselect)
|
|
|
|
|
{
|
|
|
|
|
member.Add(members, new MemberSearchModel { Id = members } as IMemberModel);
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/conference/createconference", new ConferenceBindingModel
|
|
|
|
|
{
|
|
|
|
|
ConferenceName = conferenceName,
|
|
|
|
|
StartDate = startDate,
|
|
|
|
|
OrganiserId = APIClient.Organiser.Id,
|
|
|
|
|
ConferenceMembers = member
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListConferences");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult UpdateConference()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Conferences = APIClient.GetRequest<List<ConferenceViewModel>>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}");
|
|
|
|
|
ViewBag.Member = APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateConference(int conference, string conferenceName, DateTime startDate, List<int> memberselect)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(conferenceName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Название не может быть пустым");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(startDate.ToString()))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Дата не может быть пустым");
|
|
|
|
|
}
|
|
|
|
|
Dictionary<int, IMemberModel> member = new Dictionary<int, IMemberModel>();
|
|
|
|
|
foreach (int members in memberselect)
|
|
|
|
|
{
|
|
|
|
|
member.Add(members, new MemberSearchModel { Id = members } as IMemberModel);
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/conference/updateconference", new ConferenceBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = conference,
|
|
|
|
|
ConferenceName = conferenceName,
|
|
|
|
|
StartDate = startDate,
|
|
|
|
|
OrganiserId = APIClient.Organiser.Id,
|
|
|
|
|
ConferenceMembers = member
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListConferences");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<ConferenceViewModel, List<string>>? GetConference(int conferenceId)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
var result = APIClient.GetRequest<Tuple<ConferenceViewModel, List<string>>>($"api/conference/getconference?conferenceId={conferenceId}");
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
return default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult DeleteConference()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Conferences = APIClient.GetRequest<List<ConferenceViewModel>>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteConference(int conference)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/conference/deleteconference", new ConferenceBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = conference
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListConferences");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult ConferenceConferenceBookings()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Conferences = APIClient.GetRequest<List<ConferenceViewModel>>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}");
|
|
|
|
|
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/conferenceBooking/getconferenceBookings");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void ConferenceConferenceBookings(int conference, int conferenceBooking)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Organiser == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
|
|
|
|
}
|
|
|
|
|
var roomElem = APIClient.GetRequest<ConferenceBookingViewModel>($"api/conferenceBooking/getconferenceBookingbyid?conferenceBookingId={conferenceBooking}");
|
|
|
|
|
APIClient.PostRequest("api/conferencebooking/updateconferenceBooking", new ConferenceBookingBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = conferenceBooking,
|
|
|
|
|
HeadwaiterId = roomElem.HeadwaiterId,
|
|
|
|
|
ConferenceId = conference,
|
|
|
|
|
BookingDate = roomElem.BookingDate,
|
|
|
|
|
NameHall = roomElem.NameHall,
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 22:00:39 +04:00
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
2024-03-31 10:37:51 +04:00
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|