diff --git a/Hotel/Hotel.sln b/Hotel/Hotel.sln index 46d4e10..991e2f4 100644 --- a/Hotel/Hotel.sln +++ b/Hotel/Hotel.sln @@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelContracts", "HotelCont EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelBusinessLogic", "HotelBusinessLogic\HotelBusinessLogic.csproj", "{B1B6D8C2-CCB1-47AB-A3B6-14BE5BE6E3E7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelDataBaseImplement", "HotelDataBaseImplement\HotelDataBaseImplement.csproj", "{7D0D63D3-754C-45C4-8B71-882AFD86AAB6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelDataBaseImplement", "HotelDataBaseImplement\HotelDataBaseImplement.csproj", "{7D0D63D3-754C-45C4-8B71-882AFD86AAB6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelRestApi", "HotelRestApi\HotelRestApi.csproj", "{0B4C604D-8EB3-45D0-8237-2816AF3BC004}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {7D0D63D3-754C-45C4-8B71-882AFD86AAB6}.Debug|Any CPU.Build.0 = Debug|Any CPU {7D0D63D3-754C-45C4-8B71-882AFD86AAB6}.Release|Any CPU.ActiveCfg = Release|Any CPU {7D0D63D3-754C-45C4-8B71-882AFD86AAB6}.Release|Any CPU.Build.0 = Release|Any CPU + {0B4C604D-8EB3-45D0-8237-2816AF3BC004}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B4C604D-8EB3-45D0-8237-2816AF3BC004}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B4C604D-8EB3-45D0-8237-2816AF3BC004}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B4C604D-8EB3-45D0-8237-2816AF3BC004}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Hotel/HotelBusinessLogic/BusinessLogic/ConferenceBookingLogic.cs b/Hotel/HotelBusinessLogic/BusinessLogic/ConferenceBookingLogic.cs index dc987a9..b8615a0 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogic/ConferenceBookingLogic.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogic/ConferenceBookingLogic.cs @@ -3,6 +3,7 @@ using HotelContracts.BusinessLogicsContracts; using HotelContracts.SearchModels; using HotelContracts.StoragesContracts; using HotelContracts.ViewModels; +using HotelDataModels.Models; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -97,6 +98,37 @@ namespace HotelBusinessLogic.BusinessLogic return true; } + public bool AddDinnerToConferenceBooking(ConferenceBookingSearchModel model, IDinnerModel dinner) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("AddDinnerToConferenceBooking. PlaceСonference:{PlaceСonference}.Id:{ Id}", model.PlaceСonference, model.Id); + var element = _conferenceBookingStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("AddDinnerToConferenceBooking element not found"); + return false; + } + + _logger.LogInformation("AddDinnerToConferenceBooking find. Id:{Id}", element.Id); + + element.ConferenceBookingDinners[dinner.Id] = dinner; + + _conferenceBookingStorage.Update(new() + { + Id = element.Id, + PlaceСonference = element.PlaceСonference, + DateСonference = element.DateСonference, + ConferenceId = element.ConferenceId, + AdministratorId = element.AdministratorId, + ConferenceBookingDinners = element.ConferenceBookingDinners, + }); + return true; + } private void CheckModel(ConferenceBookingBindingModel model, bool withParams = true) { if (model == null) diff --git a/Hotel/HotelBusinessLogic/BusinessLogic/RoomLogic.cs b/Hotel/HotelBusinessLogic/BusinessLogic/RoomLogic.cs index c97d34e..3357c74 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogic/RoomLogic.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogic/RoomLogic.cs @@ -3,6 +3,7 @@ using HotelContracts.BusinessLogicsContracts; using HotelContracts.SearchModels; using HotelContracts.StoragesContracts; using HotelContracts.ViewModels; +using HotelDataModels.Models; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -59,7 +60,6 @@ namespace HotelBusinessLogic.BusinessLogic return element; } - public bool Create(RoomBindingModel model) { CheckModel(model); @@ -98,6 +98,40 @@ namespace HotelBusinessLogic.BusinessLogic return true; } + public bool AddDinnerToRoom(RoomSearchModel model, IDinnerModel dinner) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("AddDinnerToRoom. RoomNumber:{RoomNumber}.Id:{ Id}", model.RoomNumber, model.Id); + var element = _roomStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("AddDinnerToRoom element not found"); + return false; + } + + _logger.LogInformation("AddDinnerToRoom find. Id:{Id}", element.Id); + + element.RoomDinners[dinner.Id] = dinner; + + _roomStorage.Update(new() + { + Id = element.Id, + RoomNumber = element.RoomNumber, + RoomPrice = element.RoomPrice, + CountBeds = element.CountBeds, + MealPlanId = element.MealPlanId, + AdministratorId = element.AdministratorId, + RoomDinners = element.RoomDinners, + }); + + return true; + } + private void CheckModel(RoomBindingModel model, bool withParams = true) { if (model == null) diff --git a/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs b/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs index 026710c..0ee27ec 100644 --- a/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs +++ b/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs @@ -17,5 +17,6 @@ namespace HotelContracts.BusinessLogicsContracts bool Create(ConferenceBookingBindingModel model); bool Update(ConferenceBookingBindingModel model); bool Delete(ConferenceBookingBindingModel model); + bool AddDinnerToConferenceBooking(ConferenceBookingSearchModel model, IDinnerModel dinner); } } diff --git a/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs b/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs index bcd307c..4d2a582 100644 --- a/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs +++ b/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs @@ -17,5 +17,6 @@ namespace HotelContracts.BusinessLogicsContracts bool Create(RoomBindingModel model); bool Update(RoomBindingModel model); bool Delete(RoomBindingModel model); + bool AddDinnerToRoom(RoomSearchModel model, IDinnerModel dinner); } } diff --git a/Hotel/HotelRestApi/Controllers/AdministratorController.cs b/Hotel/HotelRestApi/Controllers/AdministratorController.cs new file mode 100644 index 0000000..7aae32f --- /dev/null +++ b/Hotel/HotelRestApi/Controllers/AdministratorController.cs @@ -0,0 +1,66 @@ +using HotelContracts.BindingModels; +using HotelContracts.BusinessLogicsContracts; +using HotelContracts.SearchModels; +using HotelContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace HotelRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class AdministratorController : Controller + { + private readonly ILogger _logger; + private readonly IAdministratorLogic _logic; + public AdministratorController(IAdministratorLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + } + [HttpGet] + public AdministratorViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new AdministratorSearchModel + { + AdministratorLogin = login, + AdministratorPassword = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Login error"); + throw; + } + } + + [HttpPost] + public void Register(AdministratorBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Registration error"); + throw; + } + } + + [HttpPost] + public void UpdateData(AdministratorBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Update data error"); + throw; + } + } + } +} diff --git a/Hotel/HotelRestApi/Controllers/MainController.cs b/Hotel/HotelRestApi/Controllers/MainController.cs new file mode 100644 index 0000000..1874e95 --- /dev/null +++ b/Hotel/HotelRestApi/Controllers/MainController.cs @@ -0,0 +1,587 @@ +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 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? 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? 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? 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? 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? 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? 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; + } + } + + [HttpGet] + public (ConferenceViewModel, List<(string, string)>)? GetConference(int conferenceId) + { + try + { + var elem = _conference.ReadElement(new ConferenceSearchModel { Id = conferenceId }); + if (elem == null) + return null; + + var participants = new List<(string, string)>(); + + foreach (var participant in elem.ConferenceParticipants) + { + participants.Add((participant.Value.FIO, participant.Value.Number)); + } + return (elem, participants); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error get conference by id={Id}", conferenceId); + throw; + } + } + [HttpPost] + public void DeleteConference(ConferenceBindingModel model) + { + try + { + _conference.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error delete conference"); + throw; + } + } + + [HttpPost] + public void AddParticipantToConference(Tuple 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] + public (MealPlanViewModel, List<(string, string)>, List<(int, int)>)? GetMealPlan(int mealPlanId) + { + try + { + using var context = new HotelDataBase(); + + var elem = _mealPlan.ReadElement(new MealPlanSearchModel { Id = mealPlanId }); + if (elem == null) + return null; + + var participants = new List<(string, string)>(); + foreach (var participant in elem.MealPlanParticipants) + { + participants.Add((participant.Value.FIO, participant.Value.Number)); + } + + var rooms = new List<(int, int)>(); + foreach (var room in context.Rooms.Where(room => room.MealPlanId == elem.Id)) + { + rooms.Add((room.RoomNumber, room.CountBeds)); + } + + return (elem, participants, rooms); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error get MealPlan by id={Id}", mealPlanId); + throw; + } + } + + [HttpPost] + public void DeleteMealPlan(MealPlanBindingModel model) + { + try + { + _mealPlan.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error delete MealPlan"); + throw; + } + } + + [HttpPost] + public void AddParticipantToMealPlan(Tuple 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 + { + model.RoomDinners = null!; + _room.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error update Room"); + throw; + } + } + [HttpGet] + public (RoomViewModel, List<(string, double)>)? GetRoom(int roomId) + { + try + { + var elem = _room.ReadElement(new RoomSearchModel { Id = roomId }); + if (elem == null) + return null; + var dinners = new List<(string, double)>(); + foreach (var dinner in elem.RoomDinners) + { + dinners.Add((dinner.Value.DinnerName, dinner.Value.DinnerPrice)); + } + return (elem, dinners); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error get Room by id={Id}", roomId); + throw; + } + } + + [HttpPost] + public void DeleteRoom(RoomBindingModel model) + { + try + { + _room.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error delete Room"); + throw; + } + } + + [HttpPost] + public void AddDinnerToRoom(Tuple 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 + { + model.ConferenceBookingDinners = null!; + _conferenceBooking.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error update ConferenceBooking"); + throw; + } + } + + [HttpGet] + public (ConferenceBookingViewModel, List<(string, double)>)? GetConferenceBooking(int conferenceBookingId) + { + try + { + + var elem = _conferenceBooking.ReadElement(new ConferenceBookingSearchModel { Id = conferenceBookingId }); + if (elem == null) + return null; + var dinners = new List<(string, double)>(); + foreach (var dinner in elem.ConferenceBookingDinners) + { + dinners.Add((dinner.Value.DinnerName, dinner.Value.DinnerPrice)); + } + return (elem, dinners); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error get ConferenceBooking by id={Id}", conferenceBookingId); + throw; + } + } + + [HttpPost] + public void DeleteConferenceBooking(ConferenceBookingBindingModel model) + { + try + { + _conferenceBooking.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error delete ConferenceBooking"); + throw; + } + } + + [HttpPost] + public void AddDinnerToConferenceBooking(Tuple model) + { + try + { + _conferenceBooking.AddDinnerToConferenceBooking(model.Item1, model.Item2); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error add Dinner to ConferenceBooking"); + throw; + } + } + } +} diff --git a/Hotel/HotelRestApi/Controllers/OrganiserController.cs b/Hotel/HotelRestApi/Controllers/OrganiserController.cs new file mode 100644 index 0000000..cf31a1f --- /dev/null +++ b/Hotel/HotelRestApi/Controllers/OrganiserController.cs @@ -0,0 +1,69 @@ +using HotelContracts.BindingModels; +using HotelContracts.BusinessLogicsContracts; +using HotelContracts.SearchModels; +using HotelContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace HotelRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class OrganiserController : Controller + { + private readonly ILogger _logger; + + private readonly IOrganiserLogic _logic; + + public OrganiserController(IOrganiserLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + } + + [HttpGet] + public OrganiserViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new OrganiserSearchModel + { + OrganiserLogin = login, + OrganiserPassword = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Login error"); + throw; + } + } + + [HttpPost] + public void Register(OrganiserBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Registration error"); + throw; + } + } + + [HttpPost] + public void UpdateData(OrganiserBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Update data error"); + throw; + } + } + } +} diff --git a/Hotel/HotelRestApi/HotelRestApi.csproj b/Hotel/HotelRestApi/HotelRestApi.csproj new file mode 100644 index 0000000..956e41e --- /dev/null +++ b/Hotel/HotelRestApi/HotelRestApi.csproj @@ -0,0 +1,20 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + diff --git a/Hotel/HotelRestApi/Program.cs b/Hotel/HotelRestApi/Program.cs new file mode 100644 index 0000000..c0d01e1 --- /dev/null +++ b/Hotel/HotelRestApi/Program.cs @@ -0,0 +1,53 @@ +using HotelBusinessLogic.BusinessLogic; +using HotelContracts.BusinessLogicsContracts; +using HotelContracts.StoragesContracts; +using HotelDataBaseImplement.Implemets; +using Microsoft.OpenApi.Models; + +var builder = WebApplication.CreateBuilder(args); + +builder.Logging.SetMinimumLevel(LogLevel.Trace); +builder.Logging.AddLog4Net("log4net.config"); +// Add services to the container. +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo + { + Title = "HotelRestApi", + Version = "v1" + }); +}); + +var app = builder.Build(); +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HotelRestApi v1")); +} + +app.UseHttpsRedirection(); +app.UseAuthorization(); +app.MapControllers(); +app.Run(); diff --git a/Hotel/HotelRestApi/Properties/launchSettings.json b/Hotel/HotelRestApi/Properties/launchSettings.json new file mode 100644 index 0000000..1bba4bc --- /dev/null +++ b/Hotel/HotelRestApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:17840", + "sslPort": 44363 + } + }, + "profiles": { + "HotelRestApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7080;http://localhost:5286", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Hotel/HotelRestApi/appsettings.Development.json b/Hotel/HotelRestApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Hotel/HotelRestApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Hotel/HotelRestApi/appsettings.json b/Hotel/HotelRestApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Hotel/HotelRestApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Hotel/HotelRestApi/log4net.config b/Hotel/HotelRestApi/log4net.config new file mode 100644 index 0000000..565f19f --- /dev/null +++ b/Hotel/HotelRestApi/log4net.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file