664 lines
25 KiB
C#
664 lines
25 KiB
C#
using HotelAdministratorApp.Models;
|
||
using HotelContracts.BindingModels;
|
||
using HotelContracts.BusinessLogicsContracts;
|
||
using HotelContracts.SearchModels;
|
||
using HotelContracts.ViewModels;
|
||
using HotelDataBaseImplement;
|
||
using HotelDataBaseImplement.Models;
|
||
using HotelDataModels.Models;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||
using System.Diagnostics;
|
||
using System.Globalization;
|
||
using System.Numerics;
|
||
|
||
namespace HotelAdministratorApp.Controllers
|
||
{
|
||
public class HomeController : Controller
|
||
{
|
||
private readonly ILogger<HomeController> _logger;
|
||
private readonly IDinnerLogic _dinner;
|
||
|
||
public HomeController(ILogger<HomeController> logger, IDinnerLogic dinner)
|
||
{
|
||
_logger = logger;
|
||
_dinner = dinner;
|
||
}
|
||
|
||
public IActionResult Index()
|
||
{
|
||
return View();
|
||
}
|
||
public IActionResult Dinners()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View(APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?administratorId={APIClient.Administrator.Id}"));
|
||
}
|
||
public IActionResult Rooms()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View(APIClient.GetRequest<List<RoomViewModel>>($"api/main/getroomlist?administratorId={APIClient.Administrator.Id}"));
|
||
}
|
||
public IActionResult ConferenceBookings()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View(APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getConferenceBookinglist?administratorId={APIClient.Administrator.Id}"));
|
||
}
|
||
public IActionResult ConferenceBookingToConference()
|
||
{
|
||
return View();
|
||
}
|
||
[HttpGet]
|
||
public IActionResult Privacy()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View(APIClient.Administrator);
|
||
}
|
||
[HttpPost]
|
||
public void Privacy(string login, string email, string password, string fio, string phone)
|
||
{
|
||
if (APIClient.Administrator == 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/administrator/updatedata", new AdministratorBindingModel
|
||
{
|
||
Id = APIClient.Administrator.Id,
|
||
AdministratorFIO = fio,
|
||
AdministratorLogin = login,
|
||
AdministratorPassword = password,
|
||
AdministratorEmail = email,
|
||
AdministratorPhone = phone
|
||
});
|
||
|
||
APIClient.Administrator.AdministratorFIO = fio;
|
||
APIClient.Administrator.AdministratorLogin = login;
|
||
APIClient.Administrator.AdministratorPassword = password;
|
||
APIClient.Administrator.AdministratorEmail = email;
|
||
APIClient.Administrator.AdministratorPhone = phone;
|
||
Response.Redirect("Index");
|
||
}
|
||
[HttpGet]
|
||
public IActionResult Register()
|
||
{
|
||
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/administrator/register", new AdministratorBindingModel
|
||
{
|
||
AdministratorFIO = fio,
|
||
AdministratorLogin = login,
|
||
AdministratorPassword = password,
|
||
AdministratorEmail = email,
|
||
AdministratorPhone = phone
|
||
});
|
||
|
||
Response.Redirect("Enter");
|
||
return;
|
||
}
|
||
[HttpGet]
|
||
public IActionResult Enter()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void Enter(string login, string password)
|
||
{
|
||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||
{
|
||
throw new Exception("Введите логин и пароль");
|
||
}
|
||
APIClient.Administrator = APIClient.GetRequest<AdministratorViewModel>($"api/administrator/login?login={login}&password={password}");
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Неверный логин/пароль");
|
||
}
|
||
Response.Redirect("Index");
|
||
}
|
||
public IActionResult AddDinnerRoomToFiles()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
public IActionResult AddDinnerToFile()
|
||
{
|
||
return View();
|
||
}
|
||
public IActionResult CreateDinner()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void CreateDinner(double dinnerPrice, string dinnerName, int dinnerСalorie)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
if (string.IsNullOrEmpty(dinnerName) || dinnerPrice<=0 || dinnerСalorie<=0)
|
||
{
|
||
throw new Exception("Введите данные");
|
||
}
|
||
APIClient.PostRequest("api/main/createdinner", new DinnerBindingModel
|
||
{
|
||
DinnerPrice = dinnerPrice,
|
||
DinnerName = dinnerName,
|
||
DinnerСalorieСontent = dinnerСalorie,
|
||
AdministratorId = APIClient.Administrator.Id,
|
||
});
|
||
Response.Redirect("Dinners");
|
||
}
|
||
public IActionResult UpdateDinner()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Dinners = APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?administratorId={APIClient.Administrator.Id}");
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void UpdateDinner(int dinner, string dinnerName, double dinnerPrice, int dinnerСalorie)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
if (string.IsNullOrEmpty(dinnerName) || string.IsNullOrEmpty(dinnerPrice.ToString()) || string.IsNullOrEmpty(dinnerСalorie.ToString()))
|
||
{
|
||
throw new Exception("Данные пустые");
|
||
}
|
||
|
||
APIClient.PostRequest("api/main/updatedinner", new DinnerBindingModel
|
||
{
|
||
Id = dinner,
|
||
DinnerName = dinnerName,
|
||
DinnerPrice = dinnerPrice,
|
||
DinnerСalorieСontent = dinnerСalorie,
|
||
AdministratorId = APIClient.Administrator.Id,
|
||
});
|
||
|
||
Response.Redirect("Dinners");
|
||
}
|
||
public IActionResult DeleteDinner()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Dinners = APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?administratorId={APIClient.Administrator.Id}");
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void DeleteDinner(int dinner)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
APIClient.PostRequest("api/main/deletedinner", new DinnerBindingModel
|
||
{
|
||
Id = dinner
|
||
});
|
||
Response.Redirect("Dinners");
|
||
}
|
||
[HttpGet]
|
||
public DinnerViewModel? GetDinner(int dinnerId)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
var result = APIClient.GetRequest<DinnerViewModel>($"api/main/getdinner?dinnerid={dinnerId}");
|
||
if (result == null)
|
||
{
|
||
return default;
|
||
}
|
||
return result;
|
||
}
|
||
public IActionResult CreateRoom()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
var list = _dinner.ReadList(new DinnerSearchModel { AdministratorId = APIClient.Administrator.Id });
|
||
var simpDinner = list.Select(x => new { DinnerId = x.Id, DinnerName = x.DinnerName });
|
||
ViewBag.Dinners = new MultiSelectList(simpDinner, "DinnerId", "DinnerName");
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void CreateRoom(int roomNumber, double roomPrice, int[] dinners, DateTime dateCreate)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
if (roomNumber<=0 || roomPrice<=0 || dinners.Length == 0)
|
||
{
|
||
throw new Exception("Введите данные");
|
||
}
|
||
Dictionary<int, IDinnerModel> RoomDinners = new Dictionary<int, IDinnerModel>();
|
||
foreach (int id in dinners)
|
||
{
|
||
RoomDinners.Add(id, _dinner.ReadElement(new DinnerSearchModel { Id = id }));
|
||
|
||
}
|
||
|
||
APIClient.PostRequest("api/main/createroom", new RoomBindingModel
|
||
{
|
||
RoomNumber = roomNumber,
|
||
RoomPrice = roomPrice,
|
||
DateCreate = dateCreate,
|
||
AdministratorId = APIClient.Administrator.Id,
|
||
});
|
||
for (int i = 0; i < dinners.Length; i++)
|
||
{
|
||
APIClient.PostRequest("api/main/AddDinnerToRoom", Tuple.Create(
|
||
new RoomSearchModel() { RoomNumber = roomNumber },
|
||
new DinnerViewModel() { Id = dinners[i] }
|
||
));
|
||
}
|
||
Response.Redirect("Rooms");
|
||
}
|
||
public IActionResult UpdateRoom()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
|
||
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/main/getroomlist?administratorid={APIClient.Administrator.Id}");
|
||
ViewBag.Dinners = APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?administratorid={APIClient.Administrator.Id}");
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void UpdateRoom(int room, int roomNumber, double roomPrice, DateTime dateCreate, List<int> dinners)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
if (roomNumber <= 0 || roomPrice <= 0)
|
||
{
|
||
throw new Exception("Введите данные");
|
||
}
|
||
Dictionary<int, IDinnerModel> dinner = new Dictionary<int, IDinnerModel>();
|
||
foreach (int din in dinners)
|
||
{
|
||
dinner.Add(din, new DinnerSearchModel { Id = din } as IDinnerModel);
|
||
}
|
||
APIClient.PostRequest("api/main/updateroom", new RoomBindingModel
|
||
{
|
||
Id = room,
|
||
RoomNumber = roomNumber,
|
||
RoomPrice = roomPrice,
|
||
DateCreate = dateCreate,
|
||
AdministratorId = APIClient.Administrator.Id,
|
||
RoomDinners = dinner,
|
||
});
|
||
Response.Redirect("Rooms");
|
||
}
|
||
public IActionResult DeleteRoom()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/main/getroomlist?administratorId={APIClient.Administrator.Id}");
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void DeleteRoom(int room)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
APIClient.PostRequest("api/main/deleteroom", new RoomBindingModel
|
||
{
|
||
Id = room
|
||
});
|
||
Response.Redirect("Rooms");
|
||
}
|
||
[HttpGet]
|
||
public Tuple<RoomViewModel, List<Tuple<string, double>>>? GetRoom(int roomId)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||
}
|
||
var result = APIClient.GetRequest<Tuple<RoomViewModel, List<Tuple<string, double>>>>($"api/main/getroom?roomid={roomId}");
|
||
if (result == null)
|
||
{
|
||
return default;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
public IActionResult CreateConferenceBooking()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
var list = _dinner.ReadList(new DinnerSearchModel { AdministratorId = APIClient.Administrator.Id });
|
||
var simpDinner = list.Select(x => new { DinnerId = x.Id, DinnerName = x.DinnerName });
|
||
ViewBag.Dinners = new MultiSelectList(simpDinner, "DinnerId", "DinnerName");
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void CreateConferenceBooking(string placeСonference, int[] dinners, DateTime dateСonference)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
if (string.IsNullOrEmpty(placeСonference))
|
||
{
|
||
throw new Exception("Введите данные");
|
||
}
|
||
Dictionary<int, IDinnerModel> ConferenceBookingDinners = new Dictionary<int, IDinnerModel>();
|
||
foreach (int id in dinners)
|
||
{
|
||
ConferenceBookingDinners.Add(id, _dinner.ReadElement(new DinnerSearchModel { Id = id }));
|
||
|
||
}
|
||
|
||
APIClient.PostRequest("api/main/createconferencebooking", new ConferenceBookingBindingModel
|
||
{
|
||
PlaceСonference = placeСonference,
|
||
DateСonference = dateСonference,
|
||
AdministratorId = APIClient.Administrator.Id,
|
||
});
|
||
for (int i = 0; i < dinners.Length; i++)
|
||
{
|
||
APIClient.PostRequest("api/main/AddDinnerToConferenceBooking", Tuple.Create(
|
||
new ConferenceBookingSearchModel() { PlaceСonference = placeСonference },
|
||
new DinnerViewModel() { Id = dinners[i] }
|
||
));
|
||
}
|
||
Response.Redirect("ConferenceBookings");
|
||
}
|
||
public IActionResult UpdateConferenceBooking()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getconferencebookinglist?administratorid={APIClient.Administrator.Id}");
|
||
ViewBag.Dinners = APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?administratorid={APIClient.Administrator.Id}");
|
||
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void UpdateConferenceBooking(int conferencebooking, string placeСonference, DateTime dateСonference, List<int> dinners)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
if (string.IsNullOrEmpty(placeСonference))
|
||
{
|
||
throw new Exception("Введите данные");
|
||
}
|
||
Dictionary<int, IDinnerModel> dinner = new Dictionary<int, IDinnerModel>();
|
||
foreach (int din in dinners)
|
||
{
|
||
dinner.Add(din, new DinnerSearchModel { Id = din } as IDinnerModel);
|
||
}
|
||
APIClient.PostRequest("api/main/updateConferenceBooking", new ConferenceBookingBindingModel
|
||
{
|
||
Id = conferencebooking,
|
||
PlaceСonference = placeСonference,
|
||
DateСonference = dateСonference,
|
||
AdministratorId = APIClient.Administrator.Id,
|
||
ConferenceBookingDinners = dinner,
|
||
});
|
||
Response.Redirect("ConferenceBookings");
|
||
}
|
||
public IActionResult DeleteConferenceBooking()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getConferenceBookinglist?administratorId={APIClient.Administrator.Id}");
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void DeleteConferenceBooking(int conferencebooking)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Необходима авторизация");
|
||
}
|
||
APIClient.PostRequest("api/main/deleteconferencebooking", new ConferenceBookingBindingModel
|
||
{
|
||
Id = conferencebooking
|
||
});
|
||
Response.Redirect("ConferenceBookings");
|
||
}
|
||
[HttpGet]
|
||
public IActionResult AddRoomToMealPlan()
|
||
{
|
||
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.MealPlans = APIClient.GetRequest<List<MealPlanViewModel>>($"api/main/getmealplans");
|
||
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/main/getroomlist?administratorId={APIClient.Administrator.Id}");
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
public void AddRoomToMealPlan(int room, int mealplan)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||
}
|
||
using var context = new HotelDataBase();
|
||
var roomElem = APIClient.GetRequest<RoomViewModel>($"api/main/getroombyid?roomId={room}");
|
||
var dinners = _dinner.ReadList(new DinnerSearchModel { AdministratorId = APIClient.Administrator.Id });
|
||
|
||
APIClient.PostRequest("api/main/updateroom", new RoomBindingModel
|
||
{
|
||
Id = room,
|
||
MealPlanId = mealplan,
|
||
RoomNumber = roomElem.RoomNumber,
|
||
DateCreate = roomElem.DateCreate,
|
||
RoomPrice = roomElem.RoomPrice,
|
||
/*RoomDinners = roomElemrs,*/
|
||
AdministratorId = roomElem.AdministratorId,
|
||
});
|
||
Response.Redirect("Rooms");
|
||
}
|
||
[HttpGet]
|
||
public IActionResult MealPlanDinnerReport()
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Dinners = APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?administratorid={APIClient.Administrator.Id}");
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void MealPlanDinnerReport(List<int> dinners, string type)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||
}
|
||
|
||
if (dinners.Count <= 0)
|
||
{
|
||
throw new Exception("Количество должно быть больше 0");
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(type))
|
||
{
|
||
throw new Exception("Неверный тип отчета");
|
||
}
|
||
|
||
if (type == "docx")
|
||
{
|
||
APIClient.PostRequest("api/reportadministrator/createmealplanlistwordfile", new ReportMealPlanDinnerBindingModel
|
||
{
|
||
Dinners = dinners,
|
||
FileName = "C:\\Users\\sshan\\OneDrive\\Desktop\\reports\\wordfile.docx"
|
||
});
|
||
Response.Redirect("GetWordFile");
|
||
}
|
||
else
|
||
{
|
||
APIClient.PostRequest("api/reportadministrator/createmealplanlistexcelfile", new ReportMealPlanDinnerBindingModel
|
||
{
|
||
Dinners = dinners,
|
||
FileName = "C:\\Users\\sshan\\OneDrive\\Desktop\\reports\\exelfile.xlsx"
|
||
});
|
||
Response.Redirect("GetExcelFile");
|
||
}
|
||
}
|
||
|
||
[HttpGet]
|
||
public IActionResult GetWordFile()
|
||
{
|
||
return new PhysicalFileResult("C:\\Users\\sshan\\OneDrive\\Desktop\\reports\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||
}
|
||
|
||
public IActionResult GetExcelFile()
|
||
{
|
||
return new PhysicalFileResult("C:\\Users\\sshan\\OneDrive\\Desktop\\reports\\exelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||
}
|
||
[HttpGet]
|
||
public IActionResult Report()
|
||
{
|
||
ViewBag.Report = new List<ReportRoomsConferenceBindingModel>();
|
||
return View();
|
||
}
|
||
|
||
[HttpGet]
|
||
public string GetDinnersReport(DateTime dateFrom, DateTime dateTo)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||
}
|
||
List<ReportRoomsConferencesViewModel> result;
|
||
try
|
||
{
|
||
string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture);
|
||
string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture);
|
||
result = APIClient.GetRequest<List<ReportRoomsConferencesViewModel>>
|
||
($"api/reportadministrator/getroomsconferencesreport?datefrom={dateFromS}&dateto={dateToS}&administratorid={APIClient.Administrator.Id}")!;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_logger.LogError(ex, "Ошибка создания отчета");
|
||
throw;
|
||
}
|
||
string table = "";
|
||
table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
|
||
table += "<div class=\"table-responsive\">";
|
||
table += "<table class=\"table table-striped table-bordered table-hover\">";
|
||
table += "<thead class=\"table-dark\">";
|
||
table += "<tr>";
|
||
table += "<th scope=\"col\">Дата</th>";
|
||
table += "<th scope=\"col\">Название обеда</th>";
|
||
table += "<th scope=\"col\">Номер комнаты</th>";
|
||
table += "<th scope=\"col\">Название конференции</th>";
|
||
table += "</tr>";
|
||
table += "</thead>";
|
||
foreach (var dinner in result)
|
||
{
|
||
table += "<tbody>";
|
||
table += "<tr>";
|
||
table += $"<td></td>";
|
||
table += $"<td>{dinner.DinnerName}</td>";
|
||
table += $"<td></td>";
|
||
table += $"<td></td>";
|
||
table += "</tr>";
|
||
foreach (var room in dinner.Rooms)
|
||
{
|
||
table += "<tr>";
|
||
table += $"<td>{room.DateCreate}</td>";
|
||
table += $"<td></td>";
|
||
table += $"<td>{room.RoomNumber}</td>";
|
||
table += $"<td></td>";
|
||
table += "</tr>";
|
||
}
|
||
foreach (var conference in dinner.Conferences)
|
||
{
|
||
table += "<tr>";
|
||
table += $"<td>{conference.StartDate}</td>";
|
||
table += $"<td></td>";
|
||
table += $"<td></td>";
|
||
table += $"<td>{conference.ConferenceName}</td>";
|
||
table += "</tr>";
|
||
}
|
||
table += "</tbody>";
|
||
}
|
||
table += "</table>";
|
||
table += "</div>";
|
||
return table;
|
||
}
|
||
|
||
[HttpPost]
|
||
public void AddDinnerToFile(DateTime dateFrom, DateTime dateTo)
|
||
{
|
||
if (APIClient.Administrator == null)
|
||
{
|
||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||
}
|
||
APIClient.PostRequest("api/reportadministrator/SendRoomsConferencesReportToEmail", new ReportRoomsConferenceBindingModel
|
||
{
|
||
FileName = "C:\\Users\\sshan\\OneDrive\\Desktop\\reports\\reportpdf.pdf",
|
||
AdministratorId = APIClient.Administrator.Id,
|
||
DateFrom = dateFrom,
|
||
DateTo = dateTo,
|
||
Email = APIClient.Administrator.AdministratorEmail,
|
||
|
||
});
|
||
Response.Redirect("AddDinnerToFile");
|
||
|
||
}
|
||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||
public IActionResult Error()
|
||
{
|
||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||
}
|
||
}
|
||
}
|