круды
This commit is contained in:
parent
b7f769c086
commit
26f3a880ab
@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models;
|
|||||||
|
|
||||||
namespace TravelAgencyContracts.ViewModels
|
namespace TravelAgencyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ExcursionGroupViewModel
|
public class ExcursionGroupViewModel : IExcursionGroupModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ namespace TravelAgencyContracts.ViewModels
|
|||||||
public int GuideId { get; set; }
|
public int GuideId { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО гида")]
|
[DisplayName("ФИО гида")]
|
||||||
public string GuideFIO { get; set; } = string.Empty;
|
public string? GuideFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
public Dictionary<int, ITourModel> ExcursionGroupTours { get; set; } = new();
|
public Dictionary<int, ITourModel> ExcursionGroupTours { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models;
|
|||||||
|
|
||||||
namespace TravelAgencyContracts.ViewModels
|
namespace TravelAgencyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ExcursionViewModel
|
public class ExcursionViewModel : IExcursionModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using TravelAgencyDataModels.Models;
|
||||||
|
|
||||||
namespace TravelAgencyContracts.ViewModels
|
namespace TravelAgencyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class GuideViewModel
|
public class GuideViewModel : IGuideModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using TravelAgencyDataModels.Models;
|
||||||
|
|
||||||
namespace TravelAgencyContracts.ViewModels
|
namespace TravelAgencyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class PlaceViewModel
|
public class PlaceViewModel : IPlaceModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using TravelAgencyDataModels.Models;
|
||||||
|
|
||||||
namespace TravelAgencyContracts.ViewModels
|
namespace TravelAgencyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class TourViewModel
|
public class TourViewModel : ITourModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using TravelAgencyDataModels.Models;
|
|||||||
|
|
||||||
namespace TravelAgencyContracts.ViewModels
|
namespace TravelAgencyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class TripViewModel
|
public class TripViewModel : ITripModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using TravelAgencyDataModels.Models;
|
||||||
|
|
||||||
namespace TravelAgencyContracts.ViewModels
|
namespace TravelAgencyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class UserViewModel
|
public class UserViewModel : IUserModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
@ -98,6 +98,10 @@ namespace TravelAgencyDatabaseImplement.Models
|
|||||||
var excursion = context.Excursions.First(x => x.Id == Id);
|
var excursion = context.Excursions.First(x => x.Id == Id);
|
||||||
foreach (var et in model.ExcursionTours)
|
foreach (var et in model.ExcursionTours)
|
||||||
{
|
{
|
||||||
|
if (excursionTours!.Any(x => x.TourId == et.Key))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
context.ExcursionTours.Add(new ExcursionTour
|
context.ExcursionTours.Add(new ExcursionTour
|
||||||
{
|
{
|
||||||
Excursion = excursion,
|
Excursion = excursion,
|
||||||
|
@ -74,8 +74,12 @@ namespace TravelAgencyDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
using var context = new TravelAgencyDatabase();
|
||||||
ExcursionGroupName = model.ExcursionGroupName;
|
ExcursionGroupName = model.ExcursionGroupName;
|
||||||
ParticipantsAmount = model.ParticipantsAmount;
|
ParticipantsAmount = model.ParticipantsAmount;
|
||||||
|
GuideId = model.GuideId;
|
||||||
|
Guide = context.Guides
|
||||||
|
.First(x => x.Id == model.GuideId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExcursionGroupViewModel GetViewModel => new()
|
public ExcursionGroupViewModel GetViewModel => new()
|
||||||
@ -85,7 +89,7 @@ namespace TravelAgencyDatabaseImplement.Models
|
|||||||
ParticipantsAmount = ParticipantsAmount,
|
ParticipantsAmount = ParticipantsAmount,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
GuideId = GuideId,
|
GuideId = GuideId,
|
||||||
GuideFIO = Guide.GuideFIO,
|
GuideFIO = Guide?.GuideFIO,
|
||||||
ExcursionGroupTours = ExcursionGroupTours
|
ExcursionGroupTours = ExcursionGroupTours
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,6 +104,11 @@ namespace TravelAgencyDatabaseImplement.Models
|
|||||||
var excursionGroup = context.ExcursionGroups.First(x => x.Id == Id);
|
var excursionGroup = context.ExcursionGroups.First(x => x.Id == Id);
|
||||||
foreach (var et in model.ExcursionGroupTours)
|
foreach (var et in model.ExcursionGroupTours)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (excursionGroupTours!.Any(x => x.TourId == et.Key))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
context.ExcursionGroupTours.Add(new ExcursionGroupTour
|
context.ExcursionGroupTours.Add(new ExcursionGroupTour
|
||||||
{
|
{
|
||||||
ExcursionGroup = excursionGroup,
|
ExcursionGroup = excursionGroup,
|
||||||
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ using TravelAgencyContracts.ViewModels;
|
|||||||
using TravelAgencyWebApp.Models;
|
using TravelAgencyWebApp.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using TravelAgencyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelAgencyContracts.SearchModels;
|
||||||
|
|
||||||
namespace TravelAgencyWebApp.Controllers
|
namespace TravelAgencyWebApp.Controllers
|
||||||
{
|
{
|
||||||
@ -10,14 +12,22 @@ namespace TravelAgencyWebApp.Controllers
|
|||||||
{
|
{
|
||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger)
|
private readonly IUserLogic _userLogic;
|
||||||
|
|
||||||
|
public HomeController(ILogger<HomeController> logger, IUserLogic userLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_userLogic = userLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
return View();
|
if (LoggedinUser.User == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(LoggedinUser.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -31,65 +41,6 @@ namespace TravelAgencyWebApp.Controllers
|
|||||||
{
|
{
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
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]
|
[HttpGet]
|
||||||
public IActionResult ReportMenu()
|
public IActionResult ReportMenu()
|
||||||
{
|
{
|
||||||
@ -105,5 +56,79 @@ namespace TravelAgencyWebApp.Controllers
|
|||||||
{
|
{
|
||||||
return View(new List<ReportTourPeriodViewModel>());
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
126
TravelAgency/TravelAgencyWebApp/Controllers/TourController.cs
Normal file
126
TravelAgency/TravelAgencyWebApp/Controllers/TourController.cs
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
TravelAgency/TravelAgencyWebApp/LoggedinUser.cs
Normal file
9
TravelAgency/TravelAgencyWebApp/LoggedinUser.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using TravelAgencyContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace TravelAgencyWebApp
|
||||||
|
{
|
||||||
|
public static class LoggedinUser
|
||||||
|
{
|
||||||
|
public static UserViewModel? User { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,30 @@
|
|||||||
|
using TravelAgencyBusinessLogic.BusinessLogics;
|
||||||
|
using TravelAgencyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelAgencyContracts.StoragesContracts;
|
||||||
|
using TravelAgencyDatabaseImplement.Implements;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
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();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TravelAgencyBusinessLogic\TravelAgencyBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\TravelAgencyContracts\TravelAgencyContracts.csproj" />
|
<ProjectReference Include="..\TravelAgencyContracts\TravelAgencyContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\TravelAgencyDatabaseImplement\TravelAgencyDatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
@using TravelAgencyContracts.ViewModels
|
@{
|
||||||
|
|
||||||
@model List<TourViewModel>
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Create excursion";
|
ViewData["Title"] = "Create excursion";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@ -10,11 +7,11 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Описание:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Цена:</div>
|
<div class="col-4">Цена:</div>
|
||||||
@ -31,12 +28,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var tour in Model)
|
@foreach (var tour in ViewBag.Tours)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@tour.TourName</td>
|
<td>@tour.TourName</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
|
<input type="checkbox" name="tours" value="@tour.Id" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
@ -49,3 +46,4 @@
|
|||||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -42,26 +42,26 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var excursion in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Id)
|
@Html.DisplayFor(modelItem => excursion.Id)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.ExcursionName)
|
@Html.DisplayFor(modelItem => excursion.ExcursionName)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.ExcursionDescription)
|
@Html.DisplayFor(modelItem => excursion.ExcursionDescription)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Price)
|
@Html.DisplayFor(modelItem => excursion.Price)
|
||||||
</td>
|
</td>
|
||||||
<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>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
@using TravelAgencyContracts.ViewModels
|
@using TravelAgencyContracts.ViewModels
|
||||||
|
|
||||||
@model List<TourViewModel>
|
@model ExcursionViewModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Update excursion";
|
ViewData["Title"] = "Update excursion";
|
||||||
}
|
}
|
||||||
@ -10,15 +10,15 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Описание:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Цена:</div>
|
<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>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div>Туры</div>
|
<div>Туры</div>
|
||||||
@ -31,12 +31,13 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var tour in Model)
|
@foreach (var tour in ViewBag.Tours)
|
||||||
{
|
{
|
||||||
|
var isChecked = Model.ExcursionTours.Any(x => x.Key.Equals(tour.Id));
|
||||||
<tr>
|
<tr>
|
||||||
<td>@tour.TourName</td>
|
<td>@tour.TourName</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
|
<input type="checkbox" name="tours" @(isChecked ? "checked" : "") value="@tour.Id" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
@ -1,7 +1,4 @@
|
|||||||
@using TravelAgencyContracts.ViewModels
|
@{
|
||||||
|
|
||||||
@model List<TourViewModel>
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Create excursion group";
|
ViewData["Title"] = "Create excursion group";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@ -10,11 +7,11 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Количество участников:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Гид:</div>
|
<div class="col-4">Гид:</div>
|
||||||
@ -33,12 +30,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var tour in Model)
|
@foreach (var tour in ViewBag.Tours)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@tour.TourName</td>
|
<td>@tour.TourName</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
|
<input type="checkbox" name="tours" value="@tour.Id" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
@ -45,26 +45,26 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var excursionGroup in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Id)
|
@Html.DisplayFor(modelItem => excursionGroup.Id)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.ExcursionGroupName)
|
@Html.DisplayFor(modelItem => excursionGroup.ExcursionGroupName)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.ParticipantsAmount)
|
@Html.DisplayFor(modelItem => excursionGroup.ParticipantsAmount)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.GuideFIO)
|
@Html.DisplayFor(modelItem => excursionGroup.GuideFIO)
|
||||||
</td>
|
</td>
|
||||||
<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>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
@using TravelAgencyContracts.ViewModels
|
@using TravelAgencyContracts.ViewModels
|
||||||
|
|
||||||
@model List<TourViewModel>
|
@model ExcursionGroupViewModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Update excursion group";
|
ViewData["Title"] = "Update excursion group";
|
||||||
}
|
}
|
||||||
@ -10,16 +10,22 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Количество участников:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Гид:</div>
|
<div class="col-4">Гид:</div>
|
||||||
<div class="col-8">
|
<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>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -33,12 +39,13 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var tour in Model)
|
@foreach (var tour in ViewBag.Tours)
|
||||||
{
|
{
|
||||||
|
var isChecked = Model.ExcursionGroupTours.Any(x => x.Key.Equals(tour.Id));
|
||||||
<tr>
|
<tr>
|
||||||
<td>@tour.TourName</td>
|
<td>@tour.TourName</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" name="tourcheckbox" value="@tour.Id" />
|
<input type="checkbox" name="tours" @(isChecked ? "checked" : "") value="@tour.Id" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
@ -8,7 +8,7 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Логин:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Пароль:</div>
|
<div class="col-4">Пароль:</div>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Логин:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Пароль:</div>
|
<div class="col-4">Пароль:</div>
|
||||||
|
@ -27,17 +27,20 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Logout">Выход</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<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>
|
||||||
<li class="nav-item">
|
<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>
|
||||||
<li class="nav-item">
|
<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>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ReportMenu">Отчеты</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ReportMenu">Отчеты</a>
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Описание:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Цена:</div>
|
<div class="col-4">Цена:</div>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Дата тура:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
@ -45,29 +45,31 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var tour in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Id)
|
@Html.DisplayFor(modelItem => tour.Id)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.TourName)
|
@Html.DisplayFor(modelItem => tour.TourName)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.TourDescription)
|
@Html.DisplayFor(modelItem => tour.TourDescription)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Price)
|
@Html.DisplayFor(modelItem => tour.Price)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.TourDate)
|
@Html.DisplayFor(modelItem => tour.TourDate)
|
||||||
</td>
|
</td>
|
||||||
<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>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
@ -1,4 +1,8 @@
|
|||||||
@{
|
@using TravelAgencyContracts.ViewModels
|
||||||
|
|
||||||
|
@model TourViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
ViewData["Title"] = "Update tour";
|
ViewData["Title"] = "Update tour";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@ -7,19 +11,19 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Описание:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Цена:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Дата тура:</div>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
Loading…
Reference in New Issue
Block a user