2024-04-28 16:34:56 +04:00
|
|
|
|
using HotelContracts.BindingModels;
|
|
|
|
|
using HotelContracts.BusinessLogicsContracts;
|
|
|
|
|
using HotelContracts.SearchModels;
|
|
|
|
|
using HotelContracts.ViewModels;
|
|
|
|
|
using HotelDataBaseImplement;
|
|
|
|
|
using HotelDataBaseImplement.Models;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace HotelRestApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class MainController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IConferenceLogic _conference;
|
|
|
|
|
private readonly IParticipantLogic _participant;
|
|
|
|
|
private readonly IMealPlanLogic _mealPlan;
|
|
|
|
|
private readonly IDinnerLogic _dinner;
|
|
|
|
|
private readonly IConferenceBookingLogic _conferenceBooking;
|
|
|
|
|
private readonly IRoomLogic _room;
|
|
|
|
|
|
|
|
|
|
public MainController(ILogger<MainController> logger, IConferenceLogic conference, IParticipantLogic participant, IMealPlanLogic mealPlan, IDinnerLogic dinner, IConferenceBookingLogic conferenceBooking, IRoomLogic room)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_conference = conference;
|
|
|
|
|
_participant = participant;
|
|
|
|
|
_mealPlan = mealPlan;
|
|
|
|
|
_dinner = dinner;
|
|
|
|
|
_conferenceBooking = conferenceBooking;
|
|
|
|
|
_room = room;
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<ConferenceViewModel>? GetConferenceList(int organiserId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _conference.ReadList(new ConferenceSearchModel
|
|
|
|
|
{
|
|
|
|
|
OrganiserId = organiserId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get list Conference");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<ParticipantViewModel>? GetParticipantList(int organiserId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _participant.ReadList(new ParticipantSearchModel
|
|
|
|
|
{
|
|
|
|
|
OrganiserId = organiserId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get list Participant");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<MealPlanViewModel>? GetMealPlanList(int organiserId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _mealPlan.ReadList(new MealPlanSearchModel
|
|
|
|
|
{
|
|
|
|
|
OrganiserId = organiserId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get list MealPlan");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<DinnerViewModel>? GetDinnerList(int administratorId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _dinner.ReadList(new DinnerSearchModel
|
|
|
|
|
{
|
|
|
|
|
AdministratorId = administratorId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get list Dinner");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<ConferenceBookingViewModel>? GetConferenceBookingList(int administratorId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _conferenceBooking.ReadList(new ConferenceBookingSearchModel
|
|
|
|
|
{
|
|
|
|
|
AdministratorId = administratorId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get list ConferenceBooking");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<RoomViewModel>? GetRoomList(int administratorId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _room.ReadList(new RoomSearchModel
|
|
|
|
|
{
|
|
|
|
|
AdministratorId = administratorId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get list Room");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateParticipant(ParticipantBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_participant.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error update Participant");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public ParticipantViewModel? GetParticipant(int participantId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _participant.ReadElement(new ParticipantSearchModel
|
|
|
|
|
{
|
|
|
|
|
Id = participantId
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get participant by id={Id}", participantId);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateParticipant(ParticipantBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_participant.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error create Participant");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteParticipant(ParticipantBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_participant.Delete(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error delete Participant");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateDinner(DinnerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_dinner.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error update Dinner");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public DinnerViewModel? GetDinner(int dinnerId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _dinner.ReadElement(new DinnerSearchModel
|
|
|
|
|
{
|
|
|
|
|
Id = dinnerId
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get Dinner by id={Id}", dinnerId);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateDinner(DinnerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_dinner.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error create Dinner");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteDinner(DinnerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_dinner.Delete(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error delete Dinner");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateConference(ConferenceBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_conference.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error create Conference");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateConference(ConferenceBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
model.ConferenceParticipants = null!;
|
|
|
|
|
_conference.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error update Conference");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 17:12:25 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<ConferenceViewModel, List<Tuple<string, string>>>? GetConference(int conferenceId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var elem = _conference.ReadElement(new ConferenceSearchModel { Id = conferenceId });
|
|
|
|
|
if (elem == null)
|
|
|
|
|
return null;
|
|
|
|
|
return Tuple.Create(elem, elem.ConferenceParticipants.Select(x => Tuple.Create(x.Value.ParticipantFIO, x.Value.Number)).ToList());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка получения конференции по id={Id}", conferenceId);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
2024-04-28 16:34:56 +04:00
|
|
|
|
public void DeleteConference(ConferenceBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_conference.Delete(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error delete conference");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddParticipantToConference(Tuple<ConferenceSearchModel, ParticipantViewModel> model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_conference.AddParticipantToConference(model.Item1, model.Item2);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error add Participant to Conference");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateMealPlan(MealPlanBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_mealPlan.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error create MealPlan");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateMealPlan(MealPlanBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
model.MealPlanParticipants = null!;
|
|
|
|
|
_mealPlan.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error update MealPlan");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
2024-04-30 17:12:25 +04:00
|
|
|
|
|
|
|
|
|
public Tuple<MealPlanViewModel, List<Tuple<string, string>>, List<Tuple<int, int>>>? GetMealPlan(int mealPlanId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var context = new HotelDataBase();
|
|
|
|
|
var elem = _mealPlan.ReadElement(new MealPlanSearchModel { Id = mealPlanId });
|
|
|
|
|
if (elem == null)
|
|
|
|
|
return null;
|
2024-05-01 19:51:05 +04:00
|
|
|
|
return Tuple.Create(elem, elem.MealPlanParticipants.Select(x => Tuple.Create(x.Value.ParticipantFIO, x.Value.Number)).ToList(), context.Rooms.Where(x => x.MealPlanId == elem.Id).Select(x => Tuple.Create(x.RoomNumber, x.DateCreate.Year)).ToList());
|
2024-04-30 17:12:25 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get MealPlan by id={Id}", mealPlanId);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
2024-04-28 16:34:56 +04:00
|
|
|
|
public void DeleteMealPlan(MealPlanBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_mealPlan.Delete(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error delete MealPlan");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddParticipantToMealPlan(Tuple<MealPlanSearchModel, ParticipantViewModel> model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_mealPlan.AddParticipantToMealPlan(model.Item1, model.Item2);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error add Participant to MealPlan");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateRoom(RoomBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_room.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error create Room");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateRoom(RoomBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_room.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error update Room");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 17:12:25 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<RoomViewModel, List<Tuple<string, double>>>? GetRoom(int roomId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var elem = _room.ReadElement(new RoomSearchModel { Id = roomId });
|
|
|
|
|
if (elem == null)
|
|
|
|
|
return null;
|
2024-05-27 20:26:56 +04:00
|
|
|
|
var res = Tuple.Create(elem, elem.RoomDinners.Select(x => Tuple.Create(x.Value.DinnerName, x.Value.DinnerPrice)).ToList());
|
|
|
|
|
res.Item1.RoomDinners = null!;
|
|
|
|
|
return res;
|
2024-04-30 17:12:25 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get Room by id={Id}", roomId);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
2024-04-28 16:34:56 +04:00
|
|
|
|
public void DeleteRoom(RoomBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_room.Delete(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error delete Room");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddDinnerToRoom(Tuple<RoomSearchModel, DinnerViewModel> model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_room.AddDinnerToRoom(model.Item1, model.Item2);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error add Dinner to Room");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateConferenceBooking(ConferenceBookingBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_conferenceBooking.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error create ConferenceBooking");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateConferenceBooking(ConferenceBookingBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_conferenceBooking.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error update ConferenceBooking");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 17:12:25 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<ConferenceBookingViewModel, List<Tuple<string, double>>>? GetConferenceBooking(int conferenceBookingId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var elem = _conferenceBooking.ReadElement(new ConferenceBookingSearchModel { Id = conferenceBookingId });
|
|
|
|
|
if (elem == null)
|
|
|
|
|
return null;
|
|
|
|
|
return Tuple.Create(elem, elem.ConferenceBookingDinners.Select(x => Tuple.Create(x.Value.DinnerName, x.Value.DinnerPrice)).ToList());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error get ConferenceBooking by id={Id}", conferenceBookingId);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-28 16:34:56 +04:00
|
|
|
|
|
2024-04-30 17:12:25 +04:00
|
|
|
|
[HttpPost]
|
2024-04-28 16:34:56 +04:00
|
|
|
|
public void DeleteConferenceBooking(ConferenceBookingBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_conferenceBooking.Delete(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error delete ConferenceBooking");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddDinnerToConferenceBooking(Tuple<ConferenceBookingSearchModel, DinnerViewModel> model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_conferenceBooking.AddDinnerToConferenceBooking(model.Item1, model.Item2);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error add Dinner to ConferenceBooking");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-27 14:27:46 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<MealPlanViewModel>? GetMealPlans()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _mealPlan.ReadList(null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка получения списка конференций");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public RoomViewModel GetRoomById(int roomId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var elem = _room.ReadElement(new RoomSearchModel { Id = roomId });
|
|
|
|
|
if (elem == null)
|
|
|
|
|
return null;
|
|
|
|
|
return elem;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка получения по id={Id}", roomId);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-28 22:05:22 +04:00
|
|
|
|
[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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-28 16:34:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|