diff --git a/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionGroupViewModel.cs b/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionGroupViewModel.cs index 30793df..cc7e90b 100644 --- a/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionGroupViewModel.cs +++ b/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionGroupViewModel.cs @@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models; namespace TravelAgencyContracts.ViewModels { - public class ExcursionGroupViewModel + public class ExcursionGroupViewModel : IExcursionGroupModel { public int Id { get; set; } @@ -18,7 +18,7 @@ namespace TravelAgencyContracts.ViewModels public int GuideId { get; set; } [DisplayName("ФИО гида")] - public string GuideFIO { get; set; } = string.Empty; + public string? GuideFIO { get; set; } = string.Empty; public Dictionary ExcursionGroupTours { get; set; } = new(); } diff --git a/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionViewModel.cs b/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionViewModel.cs index f1dedb7..e7015b8 100644 --- a/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionViewModel.cs +++ b/TravelAgency/TravelAgencyContracts/ViewModels/ExcursionViewModel.cs @@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models; namespace TravelAgencyContracts.ViewModels { - public class ExcursionViewModel + public class ExcursionViewModel : IExcursionModel { public int Id { get; set; } diff --git a/TravelAgency/TravelAgencyContracts/ViewModels/GuideViewModel.cs b/TravelAgency/TravelAgencyContracts/ViewModels/GuideViewModel.cs index e65b8e9..cc27167 100644 --- a/TravelAgency/TravelAgencyContracts/ViewModels/GuideViewModel.cs +++ b/TravelAgency/TravelAgencyContracts/ViewModels/GuideViewModel.cs @@ -1,8 +1,9 @@ using System.ComponentModel; +using TravelAgencyDataModels.Models; namespace TravelAgencyContracts.ViewModels { - public class GuideViewModel + public class GuideViewModel : IGuideModel { public int Id { get; set; } diff --git a/TravelAgency/TravelAgencyContracts/ViewModels/PlaceViewModel.cs b/TravelAgency/TravelAgencyContracts/ViewModels/PlaceViewModel.cs index 9c2e0f0..737b87e 100644 --- a/TravelAgency/TravelAgencyContracts/ViewModels/PlaceViewModel.cs +++ b/TravelAgency/TravelAgencyContracts/ViewModels/PlaceViewModel.cs @@ -1,8 +1,9 @@ using System.ComponentModel; +using TravelAgencyDataModels.Models; namespace TravelAgencyContracts.ViewModels { - public class PlaceViewModel + public class PlaceViewModel : IPlaceModel { public int Id { get; set; } diff --git a/TravelAgency/TravelAgencyContracts/ViewModels/TourViewModel.cs b/TravelAgency/TravelAgencyContracts/ViewModels/TourViewModel.cs index 97472fd..87b9e9b 100644 --- a/TravelAgency/TravelAgencyContracts/ViewModels/TourViewModel.cs +++ b/TravelAgency/TravelAgencyContracts/ViewModels/TourViewModel.cs @@ -1,8 +1,9 @@ using System.ComponentModel; +using TravelAgencyDataModels.Models; namespace TravelAgencyContracts.ViewModels { - public class TourViewModel + public class TourViewModel : ITourModel { public int Id { get; set; } diff --git a/TravelAgency/TravelAgencyContracts/ViewModels/TripViewModel.cs b/TravelAgency/TravelAgencyContracts/ViewModels/TripViewModel.cs index e605b44..c6ee7b5 100644 --- a/TravelAgency/TravelAgencyContracts/ViewModels/TripViewModel.cs +++ b/TravelAgency/TravelAgencyContracts/ViewModels/TripViewModel.cs @@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models; namespace TravelAgencyContracts.ViewModels { - public class TripViewModel + public class TripViewModel : ITripModel { public int Id { get; set; } diff --git a/TravelAgency/TravelAgencyContracts/ViewModels/UserViewModel.cs b/TravelAgency/TravelAgencyContracts/ViewModels/UserViewModel.cs index f4f5fa9..d09ce0c 100644 --- a/TravelAgency/TravelAgencyContracts/ViewModels/UserViewModel.cs +++ b/TravelAgency/TravelAgencyContracts/ViewModels/UserViewModel.cs @@ -1,8 +1,9 @@ using System.ComponentModel; +using TravelAgencyDataModels.Models; namespace TravelAgencyContracts.ViewModels { - public class UserViewModel + public class UserViewModel : IUserModel { public int Id { get; set; } diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs index d83d9cf..d91f974 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs @@ -98,6 +98,10 @@ namespace TravelAgencyDatabaseImplement.Models var excursion = context.Excursions.First(x => x.Id == Id); foreach (var et in model.ExcursionTours) { + if (excursionTours!.Any(x => x.TourId == et.Key)) + { + continue; + } context.ExcursionTours.Add(new ExcursionTour { Excursion = excursion, diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs index 2e4fe35..5536c56 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs @@ -74,8 +74,12 @@ namespace TravelAgencyDatabaseImplement.Models { return; } + using var context = new TravelAgencyDatabase(); ExcursionGroupName = model.ExcursionGroupName; ParticipantsAmount = model.ParticipantsAmount; + GuideId = model.GuideId; + Guide = context.Guides + .First(x => x.Id == model.GuideId); } public ExcursionGroupViewModel GetViewModel => new() @@ -85,7 +89,7 @@ namespace TravelAgencyDatabaseImplement.Models ParticipantsAmount = ParticipantsAmount, UserId = UserId, GuideId = GuideId, - GuideFIO = Guide.GuideFIO, + GuideFIO = Guide?.GuideFIO, ExcursionGroupTours = ExcursionGroupTours }; @@ -100,6 +104,11 @@ namespace TravelAgencyDatabaseImplement.Models var excursionGroup = context.ExcursionGroups.First(x => x.Id == Id); foreach (var et in model.ExcursionGroupTours) { + + if (excursionGroupTours!.Any(x => x.TourId == et.Key)) + { + continue; + } context.ExcursionGroupTours.Add(new ExcursionGroupTour { ExcursionGroup = excursionGroup, diff --git a/TravelAgency/TravelAgencyWebApp/Controllers/ExcursionController.cs b/TravelAgency/TravelAgencyWebApp/Controllers/ExcursionController.cs new file mode 100644 index 0000000..c1181de --- /dev/null +++ b/TravelAgency/TravelAgencyWebApp/Controllers/ExcursionController.cs @@ -0,0 +1,153 @@ +using Microsoft.AspNetCore.Mvc; +using TravelAgencyContracts.BindingModels; +using TravelAgencyContracts.BusinessLogicsContracts; +using TravelAgencyContracts.SearchModels; +using TravelAgencyDatabaseImplement.Models; +using TravelAgencyDataModels.Models; + +namespace TravelAgencyWebApp.Controllers +{ + public class ExcursionController : Controller + { + private readonly ILogger _logger; + + private readonly IExcursionLogic _excursionLogic; + + private readonly ITourLogic _tourLogic; + + public ExcursionController(ILogger logger, IExcursionLogic excursionLogic, ITourLogic tourLogic) + { + _logger = logger; + _excursionLogic = excursionLogic; + _tourLogic = tourLogic; + } + + [HttpGet] + public IActionResult Excursions() + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(_excursionLogic.ReadList(new ExcursionSearchModel + { + UserId = LoggedinUser.User.Id, + })); + } + + [HttpGet] + public IActionResult CreateExcursion() + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Tours = _tourLogic.ReadList(new TourSearchModel + { + UserId = LoggedinUser.User.Id, + }); + + return View(); + } + + [HttpPost] + public void CreateExcursion(string excursionName, string excursionDescription, double price, List tours) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + if (string.IsNullOrEmpty(excursionName) || string.IsNullOrEmpty(excursionDescription) || price <= 0 || tours == null) + { + throw new Exception("Введены не все данные!"); + } + + Dictionary excursionTours = new Dictionary(); + foreach (var tourId in tours) + { + excursionTours.Add(tourId, _tourLogic.ReadElement(new TourSearchModel { Id = tourId })!); + } + + _excursionLogic.Create(new ExcursionBindingModel + { + ExcursionName = excursionName, + ExcursionDescription = excursionDescription, + Price = price, + UserId = LoggedinUser.User.Id, + ExcursionTours = excursionTours + }); + + Response.Redirect("/Excursion/Excursions"); + } + + [HttpGet] + public IActionResult UpdateExcursion(int id) + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Tours = _tourLogic.ReadList(new TourSearchModel + { + UserId = LoggedinUser.User.Id, + }); + + return View(_excursionLogic.ReadElement(new ExcursionSearchModel + { + Id = id + })); + } + + [HttpPost] + public void UpdateExcursion(int id, string excursionName, string excursionDescription, double price, List tours) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + if (string.IsNullOrEmpty(excursionName) || string.IsNullOrEmpty(excursionDescription) || price <= 0 || tours == null) + { + throw new Exception("Введены не все данные!"); + } + + Dictionary excursionTours = new Dictionary(); + foreach (var tourId in tours) + { + excursionTours.Add(tourId, _tourLogic.ReadElement(new TourSearchModel { Id = tourId })!); + } + + _excursionLogic.Update(new ExcursionBindingModel + { + Id = id, + ExcursionName = excursionName, + ExcursionDescription = excursionDescription, + Price = price, + UserId = LoggedinUser.User.Id, + ExcursionTours = excursionTours + }); + + Response.Redirect("/Excursion/Excursions"); + } + + [HttpPost] + public void DeleteExcursion(int id) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + _excursionLogic.Delete(new ExcursionBindingModel + { + Id = id + }); + + Response.Redirect("/Excursion/Excursions"); + } + } +} diff --git a/TravelAgency/TravelAgencyWebApp/Controllers/ExcursionGroupController.cs b/TravelAgency/TravelAgencyWebApp/Controllers/ExcursionGroupController.cs new file mode 100644 index 0000000..02f3eb9 --- /dev/null +++ b/TravelAgency/TravelAgencyWebApp/Controllers/ExcursionGroupController.cs @@ -0,0 +1,161 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using TravelAgencyContracts.BindingModels; +using TravelAgencyContracts.BusinessLogicsContracts; +using TravelAgencyContracts.SearchModels; +using TravelAgencyDatabaseImplement.Models; +using TravelAgencyDataModels.Models; + +namespace TravelAgencyWebApp.Controllers +{ + public class ExcursionGroupController : Controller + { + private readonly ILogger _logger; + + private readonly IExcursionGroupLogic _excursionGroupLogic; + + private readonly ITourLogic _tourLogic; + + private readonly IGuideLogic _guideLogic; + + public ExcursionGroupController(ILogger logger, IExcursionGroupLogic excursionGroupLogic, ITourLogic tourLogic, IGuideLogic guideLogic) + { + _logger = logger; + _excursionGroupLogic = excursionGroupLogic; + _tourLogic = tourLogic; + _guideLogic = guideLogic; + } + + [HttpGet] + public IActionResult ExcursionGroups() + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(_excursionGroupLogic.ReadList(new ExcursionGroupSearchModel + { + UserId = LoggedinUser.User.Id, + })); + } + + [HttpGet] + public IActionResult CreateExcursionGroup() + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Tours = _tourLogic.ReadList(new TourSearchModel + { + UserId = LoggedinUser.User.Id, + }); + + ViewBag.Guides = _guideLogic.ReadList(null); + + return View(); + } + + [HttpPost] + public void CreateExcursionGroup(string excursionGroupName, int participantsAmount, int guide, List tours) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + if (string.IsNullOrEmpty(excursionGroupName) || participantsAmount < 1 || guide <= 0 || tours == null) + { + throw new Exception("Введены не все данные!"); + } + + Dictionary excursionGroupTours = new Dictionary(); + foreach (var tourId in tours) + { + excursionGroupTours.Add(tourId, _tourLogic.ReadElement(new TourSearchModel { Id = tourId })!); + } + + _excursionGroupLogic.Create(new ExcursionGroupBindingModel + { + ExcursionGroupName = excursionGroupName, + ParticipantsAmount = participantsAmount, + UserId = LoggedinUser.User.Id, + GuideId = guide, + ExcursionGroupTours = excursionGroupTours + }); + + Response.Redirect("/ExcursionGroup/ExcursionGroups"); + } + + [HttpGet] + public IActionResult UpdateExcursionGroup(int id) + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Tours = _tourLogic.ReadList(new TourSearchModel + { + UserId = LoggedinUser.User.Id, + }); + + ViewBag.Guides = _guideLogic.ReadList(null); + + return View(_excursionGroupLogic.ReadElement(new ExcursionGroupSearchModel + { + Id = id + })); + } + + [HttpPost] + public void UpdateExcursionGroup(int id, string excursionGroupName, int participantsAmount, int guide, List tours) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + if (string.IsNullOrEmpty(excursionGroupName) || participantsAmount < 1 || guide <= 0 || tours == null) + { + throw new Exception("Введены не все данные!"); + } + + Dictionary excursionGroupTours = new Dictionary(); + foreach (var tourId in tours) + { + excursionGroupTours.Add(tourId, _tourLogic.ReadElement(new TourSearchModel { Id = tourId })!); + } + + _excursionGroupLogic.Update(new ExcursionGroupBindingModel + { + Id = id, + ExcursionGroupName = excursionGroupName, + ParticipantsAmount = participantsAmount, + UserId = LoggedinUser.User.Id, + GuideId = guide, + ExcursionGroupTours = excursionGroupTours + }); + + Response.Redirect("/ExcursionGroup/ExcursionGroups"); + } + + [HttpPost] + public void DeleteExcursionGroup(int id) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + _excursionGroupLogic.Delete(new ExcursionGroupBindingModel + { + Id = id + }); + + Response.Redirect("/ExcursionGroup/ExcursionGroups"); + } + } +} diff --git a/TravelAgency/TravelAgencyWebApp/Controllers/HomeController.cs b/TravelAgency/TravelAgencyWebApp/Controllers/HomeController.cs index 7e168ac..8cb9ea6 100644 --- a/TravelAgency/TravelAgencyWebApp/Controllers/HomeController.cs +++ b/TravelAgency/TravelAgencyWebApp/Controllers/HomeController.cs @@ -3,6 +3,8 @@ using TravelAgencyContracts.ViewModels; using TravelAgencyWebApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; +using TravelAgencyContracts.BusinessLogicsContracts; +using TravelAgencyContracts.SearchModels; namespace TravelAgencyWebApp.Controllers { @@ -10,14 +12,22 @@ namespace TravelAgencyWebApp.Controllers { private readonly ILogger _logger; - public HomeController(ILogger logger) + private readonly IUserLogic _userLogic; + + public HomeController(ILogger logger, IUserLogic userLogic) { _logger = logger; + _userLogic = userLogic; } public IActionResult Index() { - return View(); + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(LoggedinUser.User); } [HttpGet] @@ -31,65 +41,6 @@ namespace TravelAgencyWebApp.Controllers { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } - - [HttpGet] - public IActionResult Enter() - { - return View(); - } - - [HttpGet] - public IActionResult Register() - { - return View(); - } - - [HttpGet] - public IActionResult Excursions() - { - return View(new List()); - } - [HttpGet] - public IActionResult ExcursionGroups() - { - return View(new List()); - } - [HttpGet] - public IActionResult Tours() - { - return View(new List()); - } - - [HttpGet] - public IActionResult CreateTour() - { - return View(); - } - [HttpGet] - public IActionResult CreateExcursion() - { - return View(new List()); - } - [HttpGet] - public IActionResult CreateExcursionGroup() - { - return View(new List()); - } - [HttpGet] - public IActionResult UpdateTour() - { - return View(); - } - [HttpGet] - public IActionResult UpdateExcursion() - { - return View(new List()); - } - [HttpGet] - public IActionResult UpdateExcursionGroup() - { - return View(new List()); - } [HttpGet] public IActionResult ReportMenu() { @@ -105,5 +56,79 @@ namespace TravelAgencyWebApp.Controllers { return View(new List()); } + + [HttpGet] + public IActionResult Enter() + { + if (LoggedinUser.User != null) + { + throw new Exception("Вы уже авторизовались!"); + } + + return View(); + } + + [HttpPost] + public void Enter(string email, string password) + { + if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введены не все данные!"); + } + + LoggedinUser.User = _userLogic.ReadElement(new UserSearchModel + { + Email = email, + Password = password + }); + if (LoggedinUser.User == null) + { + throw new Exception("Неверный логин/пароль"); + } + + Response.Redirect("Index"); + } + + [HttpGet] + public IActionResult Register() + { + if (LoggedinUser.User != null) + { + throw new Exception("Вы уже зарегистрировались!"); + } + + return View(); + } + + [HttpPost] + public void Register(string fio, string email, string password, string phone) + { + if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введены не все данные!"); + } + + _userLogic.Create(new UserBindingModel + { + UserFIO = fio, + Email = email, + PhoneNumber = phone, + Password = password + }); + + Response.Redirect("Enter"); + } + + public void Logout() + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + LoggedinUser.User = null; + Response.Redirect("Enter"); + } + } } diff --git a/TravelAgency/TravelAgencyWebApp/Controllers/TourController.cs b/TravelAgency/TravelAgencyWebApp/Controllers/TourController.cs new file mode 100644 index 0000000..118aaac --- /dev/null +++ b/TravelAgency/TravelAgencyWebApp/Controllers/TourController.cs @@ -0,0 +1,126 @@ +using Microsoft.AspNetCore.Mvc; +using TravelAgencyContracts.BindingModels; +using TravelAgencyContracts.BusinessLogicsContracts; +using TravelAgencyContracts.SearchModels; + +namespace TravelAgencyWebApp.Controllers +{ + public class TourController : Controller + { + private readonly ILogger _logger; + + private readonly ITourLogic _tourLogic; + + public TourController(ILogger logger, ITourLogic tourLogic) + { + _logger = logger; + _tourLogic = tourLogic; + } + + [HttpGet] + public IActionResult Tours() + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(_tourLogic.ReadList(new TourSearchModel + { + UserId = LoggedinUser.User.Id, + })); + } + + [HttpGet] + public IActionResult CreateTour() + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(); + } + + [HttpPost] + public void CreateTour(string tourName, string tourDescription, double price, DateTime tourDate) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + if (string.IsNullOrEmpty(tourName) || string.IsNullOrEmpty(tourDescription) || price <= 0 || tourDate == DateTime.MinValue) + { + throw new Exception("Введены не все данные!"); + } + + _tourLogic.Create(new TourBindingModel + { + TourName = tourName, + TourDescription = tourDescription, + Price = price, + TourDate = tourDate, + UserId = LoggedinUser.User.Id + }); + + Response.Redirect("/Tour/Tours"); + } + + [HttpGet] + public IActionResult UpdateTour(int id) + { + if (LoggedinUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(_tourLogic.ReadElement(new TourSearchModel + { + Id = id + })); + } + + [HttpPost] + public void UpdateTour(int id, string tourName, string tourDescription, double price, DateTime tourDate) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + if (string.IsNullOrEmpty(tourName) || string.IsNullOrEmpty(tourDescription) || price <= 0 || tourDate == DateTime.MinValue) + { + throw new Exception("Введены не все данные!"); + } + + _tourLogic.Update(new TourBindingModel + { + Id = id, + TourName = tourName, + TourDescription = tourDescription, + Price = price, + TourDate = tourDate, + UserId = LoggedinUser.User.Id + }); + + Response.Redirect("/Tour/Tours"); + } + + [HttpPost] + public void DeleteTour(int id) + { + if (LoggedinUser.User == null) + { + throw new Exception("Необходимо авторизоваться!"); + } + + _tourLogic.Delete(new TourBindingModel + { + Id = id + }); + + Response.Redirect("/Tour/Tours"); + } + } +} diff --git a/TravelAgency/TravelAgencyWebApp/LoggedinUser.cs b/TravelAgency/TravelAgencyWebApp/LoggedinUser.cs new file mode 100644 index 0000000..02d1857 --- /dev/null +++ b/TravelAgency/TravelAgencyWebApp/LoggedinUser.cs @@ -0,0 +1,9 @@ +using TravelAgencyContracts.ViewModels; + +namespace TravelAgencyWebApp +{ + public static class LoggedinUser + { + public static UserViewModel? User { get; set; } = null; + } +} diff --git a/TravelAgency/TravelAgencyWebApp/Program.cs b/TravelAgency/TravelAgencyWebApp/Program.cs index 0f3ee13..5b194d9 100644 --- a/TravelAgency/TravelAgencyWebApp/Program.cs +++ b/TravelAgency/TravelAgencyWebApp/Program.cs @@ -1,7 +1,30 @@ +using TravelAgencyBusinessLogic.BusinessLogics; +using TravelAgencyContracts.BusinessLogicsContracts; +using TravelAgencyContracts.StoragesContracts; +using TravelAgencyDatabaseImplement.Implements; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); + +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(); + var app = builder.Build(); + // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { diff --git a/TravelAgency/TravelAgencyWebApp/TravelAgencyWebApp.csproj b/TravelAgency/TravelAgencyWebApp/TravelAgencyWebApp.csproj index 645daf2..6c36eb5 100644 --- a/TravelAgency/TravelAgencyWebApp/TravelAgencyWebApp.csproj +++ b/TravelAgency/TravelAgencyWebApp/TravelAgencyWebApp.csproj @@ -11,7 +11,9 @@ + + diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/CreateExcursion.cshtml b/TravelAgency/TravelAgencyWebApp/Views/Excursion/CreateExcursion.cshtml similarity index 73% rename from TravelAgency/TravelAgencyWebApp/Views/Home/CreateExcursion.cshtml rename to TravelAgency/TravelAgencyWebApp/Views/Excursion/CreateExcursion.cshtml index 111d822..2372092 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/CreateExcursion.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/Excursion/CreateExcursion.cshtml @@ -1,7 +1,4 @@ -@using TravelAgencyContracts.ViewModels - -@model List -@{ +@{ ViewData["Title"] = "Create excursion"; }
@@ -10,11 +7,11 @@
Название:
-
+
Описание:
-
+
Цена:
@@ -31,12 +28,12 @@ - @foreach (var tour in Model) + @foreach (var tour in ViewBag.Tours) { @tour.TourName - + } @@ -49,3 +46,4 @@
+ diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/Excursions.cshtml b/TravelAgency/TravelAgencyWebApp/Views/Excursion/Excursions.cshtml similarity index 56% rename from TravelAgency/TravelAgencyWebApp/Views/Home/Excursions.cshtml rename to TravelAgency/TravelAgencyWebApp/Views/Excursion/Excursions.cshtml index 9cee269..30c0bf5 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/Excursions.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/Excursion/Excursions.cshtml @@ -42,26 +42,26 @@ - @foreach (var item in Model) + @foreach (var excursion in Model) { - @Html.DisplayFor(modelItem => item.Id) + @Html.DisplayFor(modelItem => excursion.Id) - @Html.DisplayFor(modelItem => item.ExcursionName) + @Html.DisplayFor(modelItem => excursion.ExcursionName) - @Html.DisplayFor(modelItem => item.ExcursionDescription) + @Html.DisplayFor(modelItem => excursion.ExcursionDescription) - @Html.DisplayFor(modelItem => item.Price) + @Html.DisplayFor(modelItem => excursion.Price) - + - + } diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/UpdateExcursion.cshtml b/TravelAgency/TravelAgencyWebApp/Views/Excursion/UpdateExcursion.cshtml similarity index 66% rename from TravelAgency/TravelAgencyWebApp/Views/Home/UpdateExcursion.cshtml rename to TravelAgency/TravelAgencyWebApp/Views/Excursion/UpdateExcursion.cshtml index d1eac8d..8d39013 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/UpdateExcursion.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/Excursion/UpdateExcursion.cshtml @@ -1,6 +1,6 @@ @using TravelAgencyContracts.ViewModels -@model List +@model ExcursionViewModel @{ ViewData["Title"] = "Update excursion"; } @@ -10,15 +10,15 @@
Название:
-
+
Описание:
-
+
Цена:
-
+
Туры
@@ -31,12 +31,13 @@ - @foreach (var tour in Model) + @foreach (var tour in ViewBag.Tours) { + var isChecked = Model.ExcursionTours.Any(x => x.Key.Equals(tour.Id)); @tour.TourName - + } diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/CreateExcursionGroup.cshtml b/TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/CreateExcursionGroup.cshtml similarity index 75% rename from TravelAgency/TravelAgencyWebApp/Views/Home/CreateExcursionGroup.cshtml rename to TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/CreateExcursionGroup.cshtml index 488d925..0ad18ca 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/CreateExcursionGroup.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/CreateExcursionGroup.cshtml @@ -1,7 +1,4 @@ -@using TravelAgencyContracts.ViewModels - -@model List -@{ +@{ ViewData["Title"] = "Create excursion group"; }
@@ -10,11 +7,11 @@
Название:
-
+
Количество участников:
-
+
Гид:
@@ -33,12 +30,12 @@ - @foreach (var tour in Model) + @foreach (var tour in ViewBag.Tours) { @tour.TourName - + } diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/ExcursionGroups.cshtml b/TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/ExcursionGroups.cshtml similarity index 57% rename from TravelAgency/TravelAgencyWebApp/Views/Home/ExcursionGroups.cshtml rename to TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/ExcursionGroups.cshtml index 66ba4ee..5565c95 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/ExcursionGroups.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/ExcursionGroups.cshtml @@ -45,26 +45,26 @@ - @foreach (var item in Model) + @foreach (var excursionGroup in Model) { - @Html.DisplayFor(modelItem => item.Id) + @Html.DisplayFor(modelItem => excursionGroup.Id) - @Html.DisplayFor(modelItem => item.ExcursionGroupName) + @Html.DisplayFor(modelItem => excursionGroup.ExcursionGroupName) - @Html.DisplayFor(modelItem => item.ParticipantsAmount) + @Html.DisplayFor(modelItem => excursionGroup.ParticipantsAmount) - @Html.DisplayFor(modelItem => item.GuideFIO) + @Html.DisplayFor(modelItem => excursionGroup.GuideFIO) - + - + } diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/UpdateExcursionGroup.cshtml b/TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/UpdateExcursionGroup.cshtml similarity index 57% rename from TravelAgency/TravelAgencyWebApp/Views/Home/UpdateExcursionGroup.cshtml rename to TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/UpdateExcursionGroup.cshtml index b9e440c..4025e59 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/UpdateExcursionGroup.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/ExcursionGroup/UpdateExcursionGroup.cshtml @@ -1,6 +1,6 @@ @using TravelAgencyContracts.ViewModels -@model List +@model ExcursionGroupViewModel @{ ViewData["Title"] = "Update excursion group"; } @@ -10,16 +10,22 @@
Название:
-
+
Количество участников:
-
+
Гид:
- +
@@ -33,12 +39,13 @@ - @foreach (var tour in Model) + @foreach (var tour in ViewBag.Tours) { + var isChecked = Model.ExcursionGroupTours.Any(x => x.Key.Equals(tour.Id)); @tour.TourName - + } diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/Enter.cshtml b/TravelAgency/TravelAgencyWebApp/Views/Home/Enter.cshtml index 106d3d5..aebdfb2 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/Enter.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/Home/Enter.cshtml @@ -8,7 +8,7 @@
Логин:
-
+
Пароль:
diff --git a/TravelAgency/TravelAgencyWebApp/Views/Home/Register.cshtml b/TravelAgency/TravelAgencyWebApp/Views/Home/Register.cshtml index 4d91db5..622955d 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Home/Register.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/Home/Register.cshtml @@ -8,7 +8,7 @@
Логин:
-
+
Пароль:
diff --git a/TravelAgency/TravelAgencyWebApp/Views/Shared/_Layout.cshtml b/TravelAgency/TravelAgencyWebApp/Views/Shared/_Layout.cshtml index 56ee7cd..bb6cb88 100644 --- a/TravelAgency/TravelAgencyWebApp/Views/Shared/_Layout.cshtml +++ b/TravelAgency/TravelAgencyWebApp/Views/Shared/_Layout.cshtml @@ -27,17 +27,20 @@ +