круды

This commit is contained in:
russell 2024-05-28 18:32:51 +04:00
parent b7f769c086
commit 26f3a880ab
28 changed files with 661 additions and 133 deletions

View File

@ -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<int, ITourModel> ExcursionGroupTours { get; set; } = new();
}

View File

@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models;
namespace TravelAgencyContracts.ViewModels
{
public class ExcursionViewModel
public class ExcursionViewModel : IExcursionModel
{
public int Id { get; set; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models;
namespace TravelAgencyContracts.ViewModels
{
public class TripViewModel
public class TripViewModel : ITripModel
{
public int Id { get; set; }

View File

@ -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; }

View File

@ -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,

View File

@ -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,

View File

@ -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<ExcursionController> _logger;
private readonly IExcursionLogic _excursionLogic;
private readonly ITourLogic _tourLogic;
public ExcursionController(ILogger<ExcursionController> 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<int> tours)
{
if (LoggedinUser.User == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (string.IsNullOrEmpty(excursionName) || string.IsNullOrEmpty(excursionDescription) || price <= 0 || tours == null)
{
throw new Exception("Введены не все данные!");
}
Dictionary<int, ITourModel> excursionTours = new Dictionary<int, ITourModel>();
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<int> tours)
{
if (LoggedinUser.User == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (string.IsNullOrEmpty(excursionName) || string.IsNullOrEmpty(excursionDescription) || price <= 0 || tours == null)
{
throw new Exception("Введены не все данные!");
}
Dictionary<int, ITourModel> excursionTours = new Dictionary<int, ITourModel>();
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");
}
}
}

View File

@ -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<ExcursionGroupController> _logger;
private readonly IExcursionGroupLogic _excursionGroupLogic;
private readonly ITourLogic _tourLogic;
private readonly IGuideLogic _guideLogic;
public ExcursionGroupController(ILogger<ExcursionGroupController> 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<int> tours)
{
if (LoggedinUser.User == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (string.IsNullOrEmpty(excursionGroupName) || participantsAmount < 1 || guide <= 0 || tours == null)
{
throw new Exception("Введены не все данные!");
}
Dictionary<int, ITourModel> excursionGroupTours = new Dictionary<int, ITourModel>();
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<int> tours)
{
if (LoggedinUser.User == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (string.IsNullOrEmpty(excursionGroupName) || participantsAmount < 1 || guide <= 0 || tours == null)
{
throw new Exception("Введены не все данные!");
}
Dictionary<int, ITourModel> excursionGroupTours = new Dictionary<int, ITourModel>();
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");
}
}
}

View File

@ -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<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
private readonly IUserLogic _userLogic;
public HomeController(ILogger<HomeController> 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<ExcursionViewModel>());
}
[HttpGet]
public IActionResult ExcursionGroups()
{
return View(new List<ExcursionGroupViewModel>());
}
[HttpGet]
public IActionResult Tours()
{
return View(new List<TourViewModel>());
}
[HttpGet]
public IActionResult CreateTour()
{
return View();
}
[HttpGet]
public IActionResult CreateExcursion()
{
return View(new List<TourViewModel>());
}
[HttpGet]
public IActionResult CreateExcursionGroup()
{
return View(new List<TourViewModel>());
}
[HttpGet]
public IActionResult UpdateTour()
{
return View();
}
[HttpGet]
public IActionResult UpdateExcursion()
{
return View(new List<TourViewModel>());
}
[HttpGet]
public IActionResult UpdateExcursionGroup()
{
return View(new List<TourViewModel>());
}
[HttpGet]
public IActionResult ReportMenu()
{
@ -105,5 +56,79 @@ namespace TravelAgencyWebApp.Controllers
{
return View(new List<ReportTourPeriodViewModel>());
}
[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");
}
}
}

View File

@ -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<TourController> _logger;
private readonly ITourLogic _tourLogic;
public TourController(ILogger<TourController> 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");
}
}
}

View File

@ -0,0 +1,9 @@
using TravelAgencyContracts.ViewModels;
namespace TravelAgencyWebApp
{
public static class LoggedinUser
{
public static UserViewModel? User { get; set; } = null;
}
}

View File

@ -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<IUserStorage, UserStorage>();
builder.Services.AddTransient<ITourStorage, TourStorage>();
builder.Services.AddTransient<IExcursionStorage, ExcursionStorage>();
builder.Services.AddTransient<IExcursionGroupStorage, ExcursionGroupStorage>();
builder.Services.AddTransient<IGuideStorage, GuideStorage>();
builder.Services.AddTransient<IPlaceStorage, PlaceStorage>();
builder.Services.AddTransient<ITripStorage, TripStorage>();
builder.Services.AddTransient<IUserLogic, UserLogic>();
builder.Services.AddTransient<ITourLogic, TourLogic>();
builder.Services.AddTransient<IExcursionLogic, ExcursionLogic>();
builder.Services.AddTransient<IExcursionGroupLogic, ExcursionGroupLogic>();
builder.Services.AddTransient<IGuideLogic, GuideLogic>();
builder.Services.AddTransient<IPlaceLogic, PlaceLogic>();
builder.Services.AddTransient<ITripLogic, TripLogic>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{

View File

@ -11,7 +11,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TravelAgencyBusinessLogic\TravelAgencyBusinessLogic.csproj" />
<ProjectReference Include="..\TravelAgencyContracts\TravelAgencyContracts.csproj" />
<ProjectReference Include="..\TravelAgencyDatabaseImplement\TravelAgencyDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -1,7 +1,4 @@
@using TravelAgencyContracts.ViewModels
@model List<TourViewModel>
@{
@{
ViewData["Title"] = "Create excursion";
}
<div class="text-center">
@ -10,11 +7,11 @@
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="excursionname" id="excursionname" /></div>
<div class="col-8"><input type="text" name="excursionName" id="excursionName" /></div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8"><input type="text" name="description" id="description" /></div>
<div class="col-8"><input type="text" name="excursionDescription" id="excursionDescription" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
@ -31,12 +28,12 @@
</tr>
</thead>
<tbody>
@foreach (var tour in Model)
@foreach (var tour in ViewBag.Tours)
{
<tr>
<td>@tour.TourName</td>
<td>
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
<input type="checkbox" name="tours" value="@tour.Id" />
</td>
</tr>
}
@ -49,3 +46,4 @@
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -42,26 +42,26 @@
</tr>
</thead>
<tbody>
@foreach (var item in Model)
@foreach (var excursion in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
@Html.DisplayFor(modelItem => excursion.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ExcursionName)
@Html.DisplayFor(modelItem => excursion.ExcursionName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ExcursionDescription)
@Html.DisplayFor(modelItem => excursion.ExcursionDescription)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
@Html.DisplayFor(modelItem => excursion.Price)
</td>
<td>
<button type="button" class="btn btn-primary">Изменить</button>
<button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateExcursion", "/Excursion", new { id = excursion.Id })'">Изменить</button>
</td>
<td>
<button type="button" class="btn btn-primary">Удалить</button>
<button type="button" class="btn btn-primary" onclick="$.post('@Url.Action("DeleteExcursion", "/Excursion", new { id = excursion.Id })', function () {window.location.reload();})">Удалить</button>
</td>
</tr>
}

View File

@ -1,6 +1,6 @@
@using TravelAgencyContracts.ViewModels
@model List<TourViewModel>
@model ExcursionViewModel
@{
ViewData["Title"] = "Update excursion";
}
@ -10,15 +10,15 @@
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="excursionname" id="excursionname" /></div>
<div class="col-8"><input type="text" name="excursionName" id="excursionName" value="@Model.ExcursionName" /></div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8"><input type="text" name="description" id="description" /></div>
<div class="col-8"><input type="text" name="excursionDescription" id="excursionDescription" value="@Model.ExcursionDescription" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" id="price" name="price" /></div>
<div class="col-8"><input type="text" id="price" name="price" value="@Model.Price" /></div>
</div>
<div class="container">
<div>Туры</div>
@ -31,12 +31,13 @@
</tr>
</thead>
<tbody>
@foreach (var tour in Model)
@foreach (var tour in ViewBag.Tours)
{
var isChecked = Model.ExcursionTours.Any(x => x.Key.Equals(tour.Id));
<tr>
<td>@tour.TourName</td>
<td>
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
<input type="checkbox" name="tours" @(isChecked ? "checked" : "") value="@tour.Id" />
</td>
</tr>
}

View File

@ -1,7 +1,4 @@
@using TravelAgencyContracts.ViewModels
@model List<TourViewModel>
@{
@{
ViewData["Title"] = "Create excursion group";
}
<div class="text-center">
@ -10,11 +7,11 @@
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="excursionname" id="excursionname" /></div>
<div class="col-8"><input type="text" name="excursionGroupName" id="excursionGroupName" /></div>
</div>
<div class="row">
<div class="col-4">Количество участников:</div>
<div class="col-8"><input type="text" name="participants" id="participants" /></div>
<div class="col-8"><input type="text" name="participantsAmount" id="participantsAmount" /></div>
</div>
<div class="row">
<div class="col-4">Гид:</div>
@ -33,12 +30,12 @@
</tr>
</thead>
<tbody>
@foreach (var tour in Model)
@foreach (var tour in ViewBag.Tours)
{
<tr>
<td>@tour.TourName</td>
<td>
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
<input type="checkbox" name="tours" value="@tour.Id" />
</td>
</tr>
}

View File

@ -45,26 +45,26 @@
</tr>
</thead>
<tbody>
@foreach (var item in Model)
@foreach (var excursionGroup in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
@Html.DisplayFor(modelItem => excursionGroup.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ExcursionGroupName)
@Html.DisplayFor(modelItem => excursionGroup.ExcursionGroupName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ParticipantsAmount)
@Html.DisplayFor(modelItem => excursionGroup.ParticipantsAmount)
</td>
<td>
@Html.DisplayFor(modelItem => item.GuideFIO)
@Html.DisplayFor(modelItem => excursionGroup.GuideFIO)
</td>
<td>
<button type="button" class="btn btn-primary">Изменить</button>
<button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateExcursionGroup", "/ExcursionGroup", new { id = excursionGroup.Id })'">Изменить</button>
</td>
<td>
<button type="button" class="btn btn-primary">Удалить</button>
<button type="button" class="btn btn-primary" onclick="$.post('@Url.Action("DeleteExcursionGroup", "/ExcursionGroup", new { id = excursionGroup.Id })', function () {window.location.reload();})">Удалить</button>
</td>
</tr>
}

View File

@ -1,6 +1,6 @@
@using TravelAgencyContracts.ViewModels
@model List<TourViewModel>
@model ExcursionGroupViewModel
@{
ViewData["Title"] = "Update excursion group";
}
@ -10,16 +10,22 @@
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="excursionname" id="excursionname" /></div>
<div class="col-8"><input type="text" name="excursionGroupName" id="excursionGroupName" value="@Model.ExcursionGroupName" /></div>
</div>
<div class="row">
<div class="col-4">Количество участников:</div>
<div class="col-8"><input type="text" name="participants" id="participants" /></div>
<div class="col-8"><input type="text" name="participantsAmount" id="participantsAmount" value="@Model.ParticipantsAmount" /></div>
</div>
<div class="row">
<div class="col-4">Гид:</div>
<div class="col-8">
<select id="guide" name="guide" class="form-control" asp-items="@(new SelectList(@ViewBag.Guides,"Id", "GuideFIO"))"></select>
<select id="guide" name="guide" class="form-control">
@foreach (var guide in ViewBag.Guides)
{
var isSelected = Model.GuideId.Equals(guide.Id);
<option value="@guide.Id" selected="@isSelected">@guide.GuideFIO</option>
}
</select>
</div>
</div>
<div class="container">
@ -33,12 +39,13 @@
</tr>
</thead>
<tbody>
@foreach (var tour in Model)
@foreach (var tour in ViewBag.Tours)
{
var isChecked = Model.ExcursionGroupTours.Any(x => x.Key.Equals(tour.Id));
<tr>
<td>@tour.TourName</td>
<td>
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
<input type="checkbox" name="tours" @(isChecked ? "checked" : "") value="@tour.Id" />
</td>
</tr>
}

View File

@ -8,7 +8,7 @@
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
<div class="col-8"><input type="text" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>

View File

@ -8,7 +8,7 @@
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
<div class="col-8"><input type="text" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>

View File

@ -27,17 +27,20 @@
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Logout">Выход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Tours">Туры</a>
<a class="nav-link text-dark" asparea="" asp-controller="Tour" asp-action="Tours">Туры</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Excursions">Экскурсии</a>
<a class="nav-link text-dark" asparea="" asp-controller="Excursion" asp-action="Excursions">Экскурсии</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ExcursionGroups">Экскурсионные группы</a>
<a class="nav-link text-dark" asparea="" asp-controller="ExcursionGroup" asp-action="ExcursionGroups">Экскурсионные группы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ReportMenu">Отчеты</a>

View File

@ -7,11 +7,11 @@
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="tourname" id="tourname" /></div>
<div class="col-8"><input type="text" name="tourName" id="tourName" /></div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8"><input type="text" name="description" id="description" /></div>
<div class="col-8"><input type="text" name="tourDescription" id="tourDescription" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
@ -19,7 +19,7 @@
</div>
<div class="row">
<div class="col-4">Дата тура:</div>
<div class="col-8"><input type="date" name="tourdate" id="tourdate" /></div>
<div class="col-8"><input type="date" name="tourDate" id="tourDate" /></div>
</div>
<div class="row">
<div class="col-8"></div>

View File

@ -45,29 +45,31 @@
</tr>
</thead>
<tbody>
@foreach (var item in Model)
@foreach (var tour in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
@Html.DisplayFor(modelItem => tour.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.TourName)
@Html.DisplayFor(modelItem => tour.TourName)
</td>
<td>
@Html.DisplayFor(modelItem => item.TourDescription)
@Html.DisplayFor(modelItem => tour.TourDescription)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
@Html.DisplayFor(modelItem => tour.Price)
</td>
<td>
@Html.DisplayFor(modelItem => item.TourDate)
@Html.DisplayFor(modelItem => tour.TourDate)
</td>
<td>
<button type="button" class="btn btn-primary">Изменить</button>
<button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateTour", "/Tour", new { id = tour.Id })'">Изменить</button>
</td>
<td>
<button type="button" class="btn btn-primary">Удалить</button>
<button type="button" class="btn btn-primary" onclick="$.post('@Url.Action("DeleteTour", "/Tour", new { id = tour.Id })', function () {window.location.reload();})">
Удалить
</button>
</td>
</tr>
}

View File

@ -1,4 +1,8 @@
@{
@using TravelAgencyContracts.ViewModels
@model TourViewModel
@{
ViewData["Title"] = "Update tour";
}
<div class="text-center">
@ -7,19 +11,19 @@
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="tourname" id="tourname" /></div>
<div class="col-8"><input type="text" name="tourName" value="@Model.TourName" /></div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8"><input type="text" name="description" id="description" /></div>
<div class="col-8"><input type="text" name="tourDescription" value="@Model.TourDescription" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" id="price" name="price" /></div>
<div class="col-8"><input type="text" name="price" value="@Model.Price" /></div>
</div>
<div class="row">
<div class="col-4">Дата тура:</div>
<div class="col-8"><input type="date" name="tourdate" id="tourdate" /></div>
<div class="col-8"><input type="date" name="tourDate" value="@Model.TourDate.ToString("yyyy-MM-dd")" /></div>
</div>
<div class="row">
<div class="col-8"></div>