diff --git a/TourCompanyBusinessLogic/BusinessLogics/GidLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/GidLogic.cs new file mode 100644 index 0000000..d0b75ab --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/GidLogic.cs @@ -0,0 +1,104 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.BusinessLogicsContracts; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.StoragesContracts; +using TourCompanyContracts.ViewModels; + +namespace TourCompanyBusinessLogic.BusinessLogics +{ + public class GidLogic : IGidLogic + { + private readonly ILogger _logger; + private readonly IGidStorage _gidStorage; + public GidLogic(ILogger logger, IGidStorage gidStorage) + { + _logger = logger; + _gidStorage = gidStorage; + } + public List? ReadList(GidSearchModel? model) + { + _logger.LogInformation("ReadList. Id: { Id}", model?.Id); + var list = model == null ? _gidStorage.GetFullList() : _gidStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public GidViewModel? ReadElement(GidSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Id: { Id}", model.Id); + var element = _gidStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(GidBindingModel model) + { + CheckModel(model); + if (_gidStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(GidBindingModel model) + { + CheckModel(model); + if (_gidStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(GidBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_gidStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(GidBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + _logger.LogInformation("Gid. Id: { Id}", model.Id); + var element = _gidStorage.GetElement(new GidSearchModel + { + GidFIO = model.GidFIO + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/PlaceVisitLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/PlaceVisitLogic.cs index 3e18dcb..05a7698 100644 --- a/TourCompanyBusinessLogic/BusinessLogics/PlaceVisitLogic.cs +++ b/TourCompanyBusinessLogic/BusinessLogics/PlaceVisitLogic.cs @@ -12,7 +12,7 @@ using TourCompanyContracts.ViewModels; namespace TourCompanyBusinessLogic.BusinessLogics { - internal class PlaceVisitLogic : IPlaceVisitLogic + public class PlaceVisitLogic : IPlaceVisitLogic { private readonly ILogger _logger; private readonly IPlaceVisitStorage _placeVisitStorage; diff --git a/TourCompanyBusinessLogic/BusinessLogics/TourGroupLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/TourGroupLogic.cs index 20a5262..a32e042 100644 --- a/TourCompanyBusinessLogic/BusinessLogics/TourGroupLogic.cs +++ b/TourCompanyBusinessLogic/BusinessLogics/TourGroupLogic.cs @@ -12,7 +12,7 @@ using TourCompanyContracts.ViewModels; namespace TourCompanyBusinessLogic.BusinessLogics { - internal class TourGroupLogic : ITourGroupLogic + public class TourGroupLogic : ITourGroupLogic { private readonly ILogger _logger; private readonly ITourGroupStorage _tourGroupStorage; diff --git a/TourCompanyBusinessLogic/BusinessLogics/TripLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/TripLogic.cs new file mode 100644 index 0000000..19c94fc --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/TripLogic.cs @@ -0,0 +1,106 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.BusinessLogicsContracts; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.StoragesContracts; +using TourCompanyContracts.ViewModels; + +namespace TourCompanyBusinessLogic.BusinessLogics +{ + public class TripLogic : ITripLogic + { + private readonly ILogger _logger; + private readonly ITripStorage _tripStorage; + public TripLogic(ILogger logger, ITripStorage tripStorage) + { + _logger = logger; + _tripStorage = tripStorage; + } + public List? ReadList(TripSearchModel? model) + { + _logger.LogInformation("ReadList. Id: { Id}", model?.Id); + var list = model == null ? _tripStorage.GetFullList() : _tripStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public TripViewModel? ReadElement(TripSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Id: { Id}", model.Id); + var element = _tripStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(TripBindingModel model) + { + CheckModel(model); + if (_tripStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(TripBindingModel model) + { + CheckModel(model); + if (_tripStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(TripBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_tripStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(TripBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + + _logger.LogInformation("Trip. GidId:{GidId}. Id: { Id}", model.GidId, model.Id); + var element = _tripStorage.GetElement(new TripSearchModel + { + GidId = model.GidId + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyClientApp/APIClient.cs b/TourCompanyClientApp/APIClient.cs index fc9309e..6cd0dd3 100644 --- a/TourCompanyClientApp/APIClient.cs +++ b/TourCompanyClientApp/APIClient.cs @@ -7,43 +7,7 @@ namespace TourCompanyClientApp { public class APIClient { - private static readonly HttpClient _client = new(); public static UserViewModel? User { get; set; } = null; - - public static void Connect(IConfiguration configuration) - { - _client.BaseAddress = new Uri(configuration["IPAddress"]); - _client.DefaultRequestHeaders.Accept.Clear(); - _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - } - - public static T? GetRequest(string requestUrl) - { - var response = _client.GetAsync(requestUrl); - var result = response.Result.Content.ReadAsStringAsync().Result; - if (response.Result.IsSuccessStatusCode) - { - return JsonConvert.DeserializeObject(result); - } - else - { - throw new Exception(result); - } - } - - public static void PostRequest(string requestUrl, T model) - { - var json = JsonConvert.SerializeObject(model); - var data = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _client.PostAsync(requestUrl, data); - - var result = response.Result.Content.ReadAsStringAsync().Result; - if (!response.Result.IsSuccessStatusCode) - { - throw new Exception(result); - } - } } } diff --git a/TourCompanyClientApp/Controllers/HomeController.cs b/TourCompanyClientApp/Controllers/HomeController.cs index 820b95e..9404790 100644 --- a/TourCompanyClientApp/Controllers/HomeController.cs +++ b/TourCompanyClientApp/Controllers/HomeController.cs @@ -7,6 +7,7 @@ using TourCompanyContracts.BusinessLogicsContracts; using TourCompanyContracts.SearchModels; using TourCompanyContracts.ViewModels; using TourCompanyDatabaseImplement.Models; +using TourCompanyDataModels.Enums; using TourCompanyDataModels.Models; namespace TourCompanyClientApp.Controllers @@ -16,14 +17,25 @@ namespace TourCompanyClientApp.Controllers private readonly ILogger _logger; private readonly IExecurtionLogic _execurtion; + private readonly ITourGroupLogic _tourGroup; private readonly ITourLogic _tour; + private readonly IUserLogic _user; - public HomeController(ILogger logger , IExecurtionLogic execurtion, ITourLogic tour) + private readonly IPlaceVisitLogic _placeVisitLogic; + private readonly IGidLogic _gid; + private readonly ITripLogic _trip; + + public HomeController(ILogger logger , IExecurtionLogic execurtion, ITourLogic tour, IUserLogic user, ITourGroupLogic tourGroup, IPlaceVisitLogic placeVisitLogic, IGidLogic gid, ITripLogic trip) { _logger = logger; _execurtion = execurtion; _tour = tour; + _user = user; + _tourGroup = tourGroup; + _placeVisitLogic = placeVisitLogic; + _gid = gid; + _trip = trip; } [HttpGet] @@ -37,7 +49,7 @@ namespace TourCompanyClientApp.Controllers { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/tour/gettours?userId={APIClient.User.Id}")); + return View(_tour.ReadList(new TourSearchModel { UserId = APIClient.User.Id})); } [HttpGet] @@ -61,9 +73,8 @@ namespace TourCompanyClientApp.Controllers { throw new Exception("Введите логин, пароль и ФИО"); } - APIClient.PostRequest("api/user/updatedata", new UserBindingModel + _user.Update(new UserBindingModel { - Id = APIClient.User.Id, UserFIO = fio, Email = login, Password = password @@ -94,7 +105,7 @@ namespace TourCompanyClientApp.Controllers { throw new Exception("Введите логин и пароль"); } - APIClient.User = APIClient.GetRequest($"api/user/login?login={login}&password={password}"); + APIClient.User = _user.ReadElement(new UserSearchModel { Email = login, Password = password }); if (APIClient.User == null) { throw new Exception("Неверный логин/пароль"); @@ -115,7 +126,7 @@ namespace TourCompanyClientApp.Controllers { throw new Exception("Введите логин, пароль и ФИО"); } - APIClient.PostRequest("api/user/register", new UserBindingModel + _user.Create(new UserBindingModel { UserFIO = fio, Email = login, @@ -136,7 +147,7 @@ namespace TourCompanyClientApp.Controllers { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } - APIClient.PostRequest("api/tour/createtour", new TourBindingModel + _tour.Create(new TourBindingModel { UserId = APIClient.User.Id, TourName = tourName, @@ -151,7 +162,7 @@ namespace TourCompanyClientApp.Controllers { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/execurtion/getexecurtions")); + return View(_execurtion.ReadList(null)); } [HttpGet] public IActionResult CreateExecurtion() @@ -183,5 +194,176 @@ namespace TourCompanyClientApp.Controllers }); Response.Redirect("Index"); } + [HttpGet] + public IActionResult TourGroup() + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(_tourGroup.ReadList(null)); + } + [HttpGet] + public IActionResult CreateTourGroup() + { + var list = _tour.ReadList(new TourSearchModel { UserId = APIClient.User.Id }); + var simpTour = list.Select(x => new { TourId = x.Id, TourName = x.TourName }); + ViewBag.Tours = new MultiSelectList(simpTour, "TourId", "TourName"); + return View(); + } + [HttpPost] + public void CreateTourGroup(string tourGroupName, int typekey, int[] tours) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + Dictionary tourGroupTours = new Dictionary(); + foreach (int id in tours) + { + tourGroupTours.Add(id, _tour.ReadElement(new TourSearchModel { Id = id })); + } + TourType type = TourType.Гражданский; + if(typekey == 1) + { + type = TourType.Гражданский; + } + else if (typekey == 0) + { + type = TourType.Учебный; + } + _tourGroup.Create(new TourGroupBindingModel + { + TourGroupName = tourGroupName, + Type = type, + TourGroupTours = tourGroupTours + + }); + Response.Redirect("Index"); + } + [HttpGet] + public IActionResult PlaceVisit() + { + + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(_placeVisitLogic.ReadList(null)); + } + [HttpGet] + public IActionResult CreatePlaceVisit() + { + ViewBag.TourGroups = _tourGroup.ReadList(null); + var list = _trip.ReadList(null); + var simpTrip = list.Select(x => new { TripId = x.Id, TripName = x.TripName}); + ViewBag.Trips = new MultiSelectList(simpTrip, "TripId", "TripName"); + return View(); + } + + [HttpPost] + public void CreatePlaceVisit(int tourGroup, string placeVisitName, DateTime datePlaceVisit, int[] trips) + { + var prod = _tourGroup.ReadElement(new TourGroupSearchModel { Id = tourGroup }); + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + Dictionary placeVisitTrips = new Dictionary(); + foreach (int id in trips) + { + placeVisitTrips.Add(id, _trip.ReadElement(new TripSearchModel { Id = id })); + } + _placeVisitLogic.Create(new PlaceVisitBindingModel + { + PlaceVisitName = placeVisitName, + DatePlaceVisit = datePlaceVisit, + TourGroupId = tourGroup, + TourGroupName = prod.TourGroupName, + PlaceVisitTrips = placeVisitTrips + }); + Response.Redirect("Index"); + } + /// + /// Gid + /// + /// + [HttpGet] + public IActionResult Gid() + { + + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(_gid.ReadList(null)); + } + [HttpGet] + public IActionResult CreateGid() + { + var list = _execurtion.ReadList(null); + var simpExecurtion = list.Select(x => new { ExecurtionId = x.Id, Purpose = x.Purpose }); + ViewBag.Execurtions = new MultiSelectList(simpExecurtion, "ExecurtionId", "Purpose"); + return View(); + } + + [HttpPost] + public void CreateGid(int experion, string GidFio, int[] execurtions) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + Dictionary gidExecurtions = new Dictionary(); + foreach (int id in execurtions) + { + gidExecurtions.Add(id, _execurtion.ReadElement(new ExecurtionSearchModel { Id = id })); + } + _gid.Create(new GidBindingModel + { + Experion = experion, + GidFIO = GidFio, + GidExecurtions = gidExecurtions + }); + Response.Redirect("Index"); + } + /// + /// Trip + /// + /// + [HttpGet] + public IActionResult Trip() + { + + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(_trip.ReadList(null)); + } + [HttpGet] + public IActionResult CreateTrip() + { + ViewBag.Gids = _gid.ReadList(null); + return View(); + } + + [HttpPost] + public void CreateTrip(int gid, string tripName, DateTime dateTrip) + { + var prod = _gid.ReadElement(new GidSearchModel { Id = gid }); + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + _trip.Create(new TripBindingModel + { + TripName = tripName, + DateTrip = dateTrip, + GidId = gid, + GidFIO = prod.GidFIO + }); + Response.Redirect("Index"); + } } } \ No newline at end of file diff --git a/TourCompanyClientApp/Program.cs b/TourCompanyClientApp/Program.cs index 8b66a13..601d863 100644 --- a/TourCompanyClientApp/Program.cs +++ b/TourCompanyClientApp/Program.cs @@ -3,24 +3,33 @@ using TourCompanyClientApp; using TourCompanyContracts.BusinessLogicsContracts; using TourCompanyContracts.StoragesContracts; using TourCompanyDatabaseImplement.Implements; +using TourCompanyDatabaseImplement.Models; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +// Add services to the container. builder.Services.AddControllersWithViews(); var app = builder.Build(); -APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); diff --git a/TourCompanyClientApp/Views/Home/CreateGid.cshtml b/TourCompanyClientApp/Views/Home/CreateGid.cshtml new file mode 100644 index 0000000..1aeb3e0 --- /dev/null +++ b/TourCompanyClientApp/Views/Home/CreateGid.cshtml @@ -0,0 +1,26 @@ +@{ + ViewData["Title"] = "CreateGid"; +} +
+

Создание Гида

+
+
+
+
Опыт:
+
+
+
+
ФИО:
+
+
+
+
экускурсии:
+
+ @Html.ListBox("execurtions", (MultiSelectList)ViewBag.Execurtions) +
+
+
+
+
+
+
diff --git a/TourCompanyClientApp/Views/Home/CreatePlaceVisit.cshtml b/TourCompanyClientApp/Views/Home/CreatePlaceVisit.cshtml new file mode 100644 index 0000000..b159901 --- /dev/null +++ b/TourCompanyClientApp/Views/Home/CreatePlaceVisit.cshtml @@ -0,0 +1,32 @@ +@{ + ViewData["Title"] = "CreatePlaceVisit"; +} +
+

Создание мест посещения

+
+
+
+
Тур Группа:
+
+ +
+
+
+
Место посещения:
+
+
+
+
Дата посещения:
+
+
+
+
поездки:
+
+ @Html.ListBox("trips", (MultiSelectList)ViewBag.Trips) +
+
+
+
+
+
+
diff --git a/TourCompanyClientApp/Views/Home/CreateTourGroup.cshtml b/TourCompanyClientApp/Views/Home/CreateTourGroup.cshtml new file mode 100644 index 0000000..5ccbc8b --- /dev/null +++ b/TourCompanyClientApp/Views/Home/CreateTourGroup.cshtml @@ -0,0 +1,26 @@ +@{ + ViewData["Title"] = "CreateTourGroup"; +} +
+

Создание тур группы

+
+
+
+
Название группы:
+
+
+
+
Тип группы:
+
+
+
+
туры:
+
+ @Html.ListBox("tours", (MultiSelectList)ViewBag.Tours) +
+
+
+
+
+
+
\ No newline at end of file diff --git a/TourCompanyClientApp/Views/Home/CreateTrip.cshtml b/TourCompanyClientApp/Views/Home/CreateTrip.cshtml new file mode 100644 index 0000000..8c8dd1e --- /dev/null +++ b/TourCompanyClientApp/Views/Home/CreateTrip.cshtml @@ -0,0 +1,26 @@ +@{ + ViewData["Title"] = "CreateTrip"; +} +
+

Создание Поездки

+
+
+
+
Гид:
+
+ +
+
+
+
Место посещения:
+
+
+
+
Дата посещения:
+
+
+
+
+
+
+
diff --git a/TourCompanyClientApp/Views/Home/Gid.cshtml b/TourCompanyClientApp/Views/Home/Gid.cshtml new file mode 100644 index 0000000..c32ccb2 --- /dev/null +++ b/TourCompanyClientApp/Views/Home/Gid.cshtml @@ -0,0 +1,66 @@ +@using TourCompanyContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Gid"; +} + +
+

Гиды

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать Гида +

+ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + } + +
+ Номер + + Цель экскурсии + + Дата экскурсии + + длительность экскурсии + + Туры +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.Experion) + + @Html.DisplayFor(modelItem => item.GidFIO) + + +
+ } +
diff --git a/TourCompanyClientApp/Views/Home/PlaceVisit.cshtml b/TourCompanyClientApp/Views/Home/PlaceVisit.cshtml new file mode 100644 index 0000000..2905c2a --- /dev/null +++ b/TourCompanyClientApp/Views/Home/PlaceVisit.cshtml @@ -0,0 +1,70 @@ +@using TourCompanyContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "PlaceVisit"; +} + +
+

Места посещения

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать Места посещения +

+ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер + + Место посещения + + Дата посещения + + Тур Группа + + Поездка +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.PlaceVisitName) + + @Html.DisplayFor(modelItem => item.DatePlaceVisit) + + @Html.DisplayFor(modelItem => item.TourGroupName) + + +
+ } +
+ diff --git a/TourCompanyClientApp/Views/Home/TourGroup.cshtml b/TourCompanyClientApp/Views/Home/TourGroup.cshtml new file mode 100644 index 0000000..515d39f --- /dev/null +++ b/TourCompanyClientApp/Views/Home/TourGroup.cshtml @@ -0,0 +1,64 @@ +@using TourCompanyContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "TourGroup"; +} + +
+

Тур группа

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать Тур группу +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + } + +
+ Номер + + Название тур группы + + Дата экскурсии + + Туры +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.TourGroupName) + + @Html.DisplayFor(modelItem => item.Type) + + +
+ } +
+ diff --git a/TourCompanyClientApp/Views/Home/Trip.cshtml b/TourCompanyClientApp/Views/Home/Trip.cshtml new file mode 100644 index 0000000..a0228d5 --- /dev/null +++ b/TourCompanyClientApp/Views/Home/Trip.cshtml @@ -0,0 +1,60 @@ +@using TourCompanyContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Trip"; +} + +
+

Поездка

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать поездку +

+ + + + + + + + + + @foreach (var item in Model) + { + + + + + + + } + +
+ Номер + + Поездка + + Дата Поездки +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.TripName) + + @Html.DisplayFor(modelItem => item.DateTrip) + + @Html.DisplayFor(modelItem => item.GidFIO) +
+ } +
diff --git a/TourCompanyClientApp/Views/Shared/_Layout.cshtml b/TourCompanyClientApp/Views/Shared/_Layout.cshtml index a0173a9..cbb8385 100644 --- a/TourCompanyClientApp/Views/Shared/_Layout.cshtml +++ b/TourCompanyClientApp/Views/Shared/_Layout.cshtml @@ -31,6 +31,18 @@ + + + + diff --git a/TourCompanyContracts/BindingModels/GidBindingModel.cs b/TourCompanyContracts/BindingModels/GidBindingModel.cs new file mode 100644 index 0000000..8e63b68 --- /dev/null +++ b/TourCompanyContracts/BindingModels/GidBindingModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.BindingModels +{ + public class GidBindingModel : IGidModel + { + public int Id { get; set; } + + public string GidFIO { get; set; } = string.Empty; + + public int Experion { get; set; } + public Dictionary GidExecurtions { get; set; } = new(); + + } +} diff --git a/TourCompanyContracts/BindingModels/PlaceVisitBindingModel.cs b/TourCompanyContracts/BindingModels/PlaceVisitBindingModel.cs index 684e8b5..427b80a 100644 --- a/TourCompanyContracts/BindingModels/PlaceVisitBindingModel.cs +++ b/TourCompanyContracts/BindingModels/PlaceVisitBindingModel.cs @@ -19,5 +19,6 @@ namespace TourCompanyContracts.BindingModels public int TourGroupId { get; set; } public string TourGroupName { get; set; } = string.Empty; - } + public Dictionary PlaceVisitTrips { get; set; } = new(); + } } diff --git a/TourCompanyContracts/BindingModels/TripBindingModel.cs b/TourCompanyContracts/BindingModels/TripBindingModel.cs new file mode 100644 index 0000000..9f5a0b9 --- /dev/null +++ b/TourCompanyContracts/BindingModels/TripBindingModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.BindingModels +{ + public class TripBindingModel : ITripModel + { + public int Id { get; set; } + + public string TripName { get; set; } + + public DateTime DateTrip { get; set; } + public int GidId { get; set; } + public string GidFIO { get; set; } + + } +} diff --git a/TourCompanyContracts/BusinessLogicsContracts/IGidLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/IGidLogic.cs new file mode 100644 index 0000000..7fdb661 --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/IGidLogic.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.ViewModels; + +namespace TourCompanyContracts.BusinessLogicsContracts +{ + public interface IGidLogic + { + List? ReadList(GidSearchModel? model); + GidViewModel? ReadElement(GidSearchModel model); + bool Create(GidBindingModel model); + bool Update(GidBindingModel model); + bool Delete(GidBindingModel model); + } +} diff --git a/TourCompanyContracts/BusinessLogicsContracts/ITripLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/ITripLogic.cs new file mode 100644 index 0000000..3bcb540 --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/ITripLogic.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.ViewModels; + +namespace TourCompanyContracts.BusinessLogicsContracts +{ + public interface ITripLogic + { + List? ReadList(TripSearchModel? model); + TripViewModel? ReadElement(TripSearchModel model); + bool Create(TripBindingModel model); + bool Update(TripBindingModel model); + bool Delete(TripBindingModel model); + } +} diff --git a/TourCompanyContracts/SearchModels/GidSearchModel.cs b/TourCompanyContracts/SearchModels/GidSearchModel.cs new file mode 100644 index 0000000..12b81b1 --- /dev/null +++ b/TourCompanyContracts/SearchModels/GidSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.SearchModels +{ + public class GidSearchModel + { + public int? Id { get; set; } + + public string? GidFIO { get; set; } + } +} diff --git a/TourCompanyContracts/SearchModels/TripSearchModel.cs b/TourCompanyContracts/SearchModels/TripSearchModel.cs new file mode 100644 index 0000000..205c66d --- /dev/null +++ b/TourCompanyContracts/SearchModels/TripSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.SearchModels +{ + public class TripSearchModel + { + public int? Id { get; set; } + public int? GidId { get; set; } + } +} diff --git a/TourCompanyContracts/StoragesContracts/IGidStorage.cs b/TourCompanyContracts/StoragesContracts/IGidStorage.cs new file mode 100644 index 0000000..4e8edd5 --- /dev/null +++ b/TourCompanyContracts/StoragesContracts/IGidStorage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.ViewModels; + +namespace TourCompanyContracts.StoragesContracts +{ + public interface IGidStorage + { + List GetFullList(); + List GetFilteredList(GidSearchModel model); + GidViewModel? GetElement(GidSearchModel model); + GidViewModel? Insert(GidBindingModel model); + GidViewModel? Update(GidBindingModel model); + GidViewModel? Delete(GidBindingModel model); + } +} diff --git a/TourCompanyContracts/StoragesContracts/ITripStorage.cs b/TourCompanyContracts/StoragesContracts/ITripStorage.cs new file mode 100644 index 0000000..fc4a494 --- /dev/null +++ b/TourCompanyContracts/StoragesContracts/ITripStorage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.ViewModels; + +namespace TourCompanyContracts.StoragesContracts +{ + public interface ITripStorage + { + List GetFullList(); + List GetFilteredList(TripSearchModel model); + TripViewModel? GetElement(TripSearchModel model); + TripViewModel? Insert(TripBindingModel model); + TripViewModel? Update(TripBindingModel model); + TripViewModel? Delete(TripBindingModel model); + } +} diff --git a/TourCompanyContracts/ViewModels/GidViewModel.cs b/TourCompanyContracts/ViewModels/GidViewModel.cs new file mode 100644 index 0000000..9900bc1 --- /dev/null +++ b/TourCompanyContracts/ViewModels/GidViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.ViewModels +{ + public class GidViewModel : IGidModel + { + public int Id { get; set; } + + public string GidFIO { get; set; } = string.Empty; + + public int Experion { get; set; } + public Dictionary GidExecurtions { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/ViewModels/PlaceVisitViewModel.cs b/TourCompanyContracts/ViewModels/PlaceVisitViewModel.cs index 07d0c5e..3f56274 100644 --- a/TourCompanyContracts/ViewModels/PlaceVisitViewModel.cs +++ b/TourCompanyContracts/ViewModels/PlaceVisitViewModel.cs @@ -19,5 +19,6 @@ namespace TourCompanyContracts.ViewModels public int TourGroupId { get; set; } public string TourGroupName { get; set; } = string.Empty; - } + public Dictionary PlaceVisitTrips { get; set; } = new(); + } } diff --git a/TourCompanyContracts/ViewModels/TripViewModel.cs b/TourCompanyContracts/ViewModels/TripViewModel.cs new file mode 100644 index 0000000..a950e9f --- /dev/null +++ b/TourCompanyContracts/ViewModels/TripViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.ViewModels +{ + public class TripViewModel : ITripModel + { + public int Id { get; set; } + + public string TripName { get; set; } + + public DateTime DateTrip { get; set; } + public int GidId { get; set; } + public string GidFIO { get; set; } + } +} diff --git a/TourCompanyDataModels/Models/IGidModel.cs b/TourCompanyDataModels/Models/IGidModel.cs new file mode 100644 index 0000000..c3b9ef4 --- /dev/null +++ b/TourCompanyDataModels/Models/IGidModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyDataModels.Models +{ + public interface IGidModel : IId + { + public string GidFIO { get;} + + public int Experion { get;} + + public Dictionary GidExecurtions { get; } + } +} diff --git a/TourCompanyDataModels/Models/IPlaceVisitModel.cs b/TourCompanyDataModels/Models/IPlaceVisitModel.cs index fa54f28..82cb5b1 100644 --- a/TourCompanyDataModels/Models/IPlaceVisitModel.cs +++ b/TourCompanyDataModels/Models/IPlaceVisitModel.cs @@ -17,6 +17,7 @@ namespace TourCompanyDataModels.Models public int TourGroupId { get; } - public string TourGroupName { get; } - } + public string TourGroupName { get; } + public Dictionary PlaceVisitTrips { get; } + } } diff --git a/TourCompanyDataModels/Models/ITripModel.cs b/TourCompanyDataModels/Models/ITripModel.cs new file mode 100644 index 0000000..5a6e466 --- /dev/null +++ b/TourCompanyDataModels/Models/ITripModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyDataModels.Models +{ + public interface ITripModel : IId + { + public string TripName { get; } + + public DateTime DateTrip { get; } + public int GidId { get; } + public string GidFIO { get; } + } +} diff --git a/TourCompanyDatabaseImplement/Implements/GidStorage.cs b/TourCompanyDatabaseImplement/Implements/GidStorage.cs new file mode 100644 index 0000000..9411fcd --- /dev/null +++ b/TourCompanyDatabaseImplement/Implements/GidStorage.cs @@ -0,0 +1,110 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.StoragesContracts; +using TourCompanyContracts.ViewModels; +using TourCompanyDatabaseImplement.Models; + +namespace TourCompanyDatabaseImplement.Implements +{ + public class GidStorage : IGidStorage + { + public List GetFullList() + { + using var context = new TourCompanyDatabase(); + return context.Gids + .Include(x => x.Execurtions) + .ThenInclude(x => x.Execurtion) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList(GidSearchModel model) + { + if (string.IsNullOrEmpty(model.GidFIO)) + { + return new(); + } + using var context = new TourCompanyDatabase(); + return context.Gids + .Include(x => x.Execurtions) + .ThenInclude(x => x.Execurtion) + .Where(x => x.GidFIO.Contains(model.GidFIO)) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public GidViewModel? GetElement(GidSearchModel model) + { + if (string.IsNullOrEmpty(model.GidFIO) && !model.Id.HasValue) + { + return null; + } + using var context = new TourCompanyDatabase(); + return context.Gids + .Include(x => x.Execurtions) + .ThenInclude(x => x.Execurtion) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.GidFIO) && x.GidFIO == model.GidFIO) || (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public GidViewModel? Insert(GidBindingModel model) + { + using var context = new TourCompanyDatabase(); + var newGid = Gid.Create(context, model); + if (newGid == null) + { + return null; + } + context.Gids.Add(newGid); + context.SaveChanges(); + return newGid.GetViewModel; + } + + public GidViewModel? Update(GidBindingModel model) + { + using var context = new TourCompanyDatabase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var execurtion = context.Gids.FirstOrDefault(rec => rec.Id == model.Id); + if (execurtion == null) + { + return null; + } + execurtion.Update(model); + context.SaveChanges(); + execurtion.UpdateExecurtions(context, model); + transaction.Commit(); + return execurtion.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + + public GidViewModel? Delete(GidBindingModel model) + { + using var context = new TourCompanyDatabase(); + var element = context.Gids + .Include(x => x.Execurtions) + .FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Gids.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/TourCompanyDatabaseImplement/Implements/PlaceVisitStorage.cs b/TourCompanyDatabaseImplement/Implements/PlaceVisitStorage.cs index 8ce5242..52a5c50 100644 --- a/TourCompanyDatabaseImplement/Implements/PlaceVisitStorage.cs +++ b/TourCompanyDatabaseImplement/Implements/PlaceVisitStorage.cs @@ -70,8 +70,10 @@ namespace TourCompanyDatabaseImplement.Implements } return queryWhere - .Include(x => x.TourGroup) - .Select(x => x.GetViewModel) + .Include(x => x.Trips) + .ThenInclude(x => x.Trip) + .ToList() + .Select(x => x.GetViewModel) .ToList(); } @@ -80,21 +82,23 @@ namespace TourCompanyDatabaseImplement.Implements using var context = new TourCompanyDatabase(); return context.PlaceVisits - .Include(x => x.TourGroup) - .Select(x => x.GetViewModel).ToList(); + .Include(x => x.Trips) + .ThenInclude(x => x.Trip) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); } public PlaceVisitViewModel? Insert(PlaceVisitBindingModel model) { - var newPlaceVisit = PlaceVisit.Create(model); + using var context = new TourCompanyDatabase(); + var newPlaceVisit = PlaceVisit.Create(context, model); if (newPlaceVisit == null) { return null; } - using var context = new TourCompanyDatabase(); - context.PlaceVisits.Add(newPlaceVisit); context.SaveChanges(); diff --git a/TourCompanyDatabaseImplement/Implements/TripStorage.cs b/TourCompanyDatabaseImplement/Implements/TripStorage.cs new file mode 100644 index 0000000..91863b8 --- /dev/null +++ b/TourCompanyDatabaseImplement/Implements/TripStorage.cs @@ -0,0 +1,125 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.StoragesContracts; +using TourCompanyContracts.ViewModels; +using TourCompanyDatabaseImplement.Models; + +namespace TourCompanyDatabaseImplement.Implements +{ + public class TripStorage : ITripStorage + { + public TripViewModel? Delete(TripBindingModel model) + { + using var context = new TourCompanyDatabase(); + + var element = context.Trips + .Include(x => x.Gid) + .FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Trips.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public TripViewModel? GetElement(TripSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + + using var context = new TourCompanyDatabase(); + + return context.Trips + .Include(x => x.Gid) + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; + } + + public List GetFilteredList(TripSearchModel model) + { + if (model.Id.HasValue) + { + var result = GetElement(model); + return result != null ? new() { result } : new(); + } + + using var context = new TourCompanyDatabase(); + IQueryable? queryWhere = null; + + if (model.GidId.HasValue) + { + queryWhere = context.Trips.Where(x => x.GidId == model.GidId); + } + else + { + return new(); + } + + return queryWhere + .Include(x => x.Gid) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new TourCompanyDatabase(); + + return context.Trips + .Include(x => x.Gid) + .Select(x => x.GetViewModel).ToList(); + } + + public TripViewModel? Insert(TripBindingModel model) + { + var newTrip = Trip.Create(model); + + if (newTrip == null) + { + return null; + } + + using var context = new TourCompanyDatabase(); + + context.Trips.Add(newTrip); + context.SaveChanges(); + + return context.Trips + .Include(x => x.Gid) + .FirstOrDefault(x => x.Id == newTrip.Id) + ?.GetViewModel; + } + + public TripViewModel? Update(TripBindingModel model) + { + using var context = new TourCompanyDatabase(); + + var trip = context.Trips + .Include(x => x.Gid) + .FirstOrDefault(x => x.Id == model.Id); + + if (trip == null) + { + return null; + } + + trip.Update(model); + context.SaveChanges(); + + return trip.GetViewModel; + } + } +} diff --git a/TourCompanyDatabaseImplement/Migrations/20230519192042_InitialCreate.Designer.cs b/TourCompanyDatabaseImplement/Migrations/20230519231349_InitialCreate.Designer.cs similarity index 62% rename from TourCompanyDatabaseImplement/Migrations/20230519192042_InitialCreate.Designer.cs rename to TourCompanyDatabaseImplement/Migrations/20230519231349_InitialCreate.Designer.cs index 7cfa4d6..a9c69b6 100644 --- a/TourCompanyDatabaseImplement/Migrations/20230519192042_InitialCreate.Designer.cs +++ b/TourCompanyDatabaseImplement/Migrations/20230519231349_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using TourCompanyDatabaseImplement; namespace TourCompanyDatabaseImplement.Migrations { [DbContext(typeof(TourCompanyDatabase))] - [Migration("20230519192042_InitialCreate")] + [Migration("20230519231349_InitialCreate")] partial class InitialCreate { /// @@ -71,6 +71,52 @@ namespace TourCompanyDatabaseImplement.Migrations b.ToTable("ExecurtionTours"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Gid", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Experion") + .HasColumnType("int"); + + b.Property("GidFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Gids"); + }); + + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.GidExecurtion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExecurtionId") + .HasColumnType("int"); + + b.Property("GidId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ExecurtionId"); + + b.HasIndex("GidId"); + + b.ToTable("GidExecurtions"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisit", b => { b.Property("Id") @@ -100,6 +146,29 @@ namespace TourCompanyDatabaseImplement.Migrations b.ToTable("PlaceVisits"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisitTrip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PlaceVisitId") + .HasColumnType("int"); + + b.Property("TripId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PlaceVisitId"); + + b.HasIndex("TripId"); + + b.ToTable("PlaceVisitTrips"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Tour", b => { b.Property("Id") @@ -168,6 +237,35 @@ namespace TourCompanyDatabaseImplement.Migrations b.ToTable("TourGroupTours"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Trip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DateTrip") + .HasColumnType("datetime2"); + + b.Property("GidFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GidId") + .HasColumnType("int"); + + b.Property("TripName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GidId"); + + b.ToTable("Trips"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.User", b => { b.Property("Id") @@ -212,6 +310,25 @@ namespace TourCompanyDatabaseImplement.Migrations b.Navigation("Tour"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.GidExecurtion", b => + { + b.HasOne("TourCompanyDatabaseImplement.Models.Execurtion", "Execurtion") + .WithMany() + .HasForeignKey("ExecurtionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TourCompanyDatabaseImplement.Models.Gid", "Gid") + .WithMany("Execurtions") + .HasForeignKey("GidId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Execurtion"); + + b.Navigation("Gid"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisit", b => { b.HasOne("TourCompanyDatabaseImplement.Models.TourGroup", "TourGroup") @@ -223,6 +340,25 @@ namespace TourCompanyDatabaseImplement.Migrations b.Navigation("TourGroup"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisitTrip", b => + { + b.HasOne("TourCompanyDatabaseImplement.Models.PlaceVisit", "PlaceVisit") + .WithMany("Trips") + .HasForeignKey("PlaceVisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TourCompanyDatabaseImplement.Models.Trip", "Trip") + .WithMany() + .HasForeignKey("TripId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PlaceVisit"); + + b.Navigation("Trip"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Tour", b => { b.HasOne("TourCompanyDatabaseImplement.Models.User", "User") @@ -253,11 +389,32 @@ namespace TourCompanyDatabaseImplement.Migrations b.Navigation("TourGroup"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Trip", b => + { + b.HasOne("TourCompanyDatabaseImplement.Models.Gid", "Gid") + .WithMany() + .HasForeignKey("GidId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Gid"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Execurtion", b => { b.Navigation("Tours"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Gid", b => + { + b.Navigation("Execurtions"); + }); + + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisit", b => + { + b.Navigation("Trips"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.TourGroup", b => { b.Navigation("Tours"); diff --git a/TourCompanyDatabaseImplement/Migrations/20230519192042_InitialCreate.cs b/TourCompanyDatabaseImplement/Migrations/20230519231349_InitialCreate.cs similarity index 61% rename from TourCompanyDatabaseImplement/Migrations/20230519192042_InitialCreate.cs rename to TourCompanyDatabaseImplement/Migrations/20230519231349_InitialCreate.cs index cf58c41..91ea228 100644 --- a/TourCompanyDatabaseImplement/Migrations/20230519192042_InitialCreate.cs +++ b/TourCompanyDatabaseImplement/Migrations/20230519231349_InitialCreate.cs @@ -26,6 +26,21 @@ namespace TourCompanyDatabaseImplement.Migrations table.PrimaryKey("PK_Execurtions", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Gids", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + GidFIO = table.Column(type: "nvarchar(max)", nullable: false), + Experion = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Gids", x => x.Id); + }); + migrationBuilder.CreateTable( name: "TourGroups", columns: table => new @@ -55,6 +70,54 @@ namespace TourCompanyDatabaseImplement.Migrations table.PrimaryKey("PK_Users", x => x.Id); }); + migrationBuilder.CreateTable( + name: "GidExecurtions", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ExecurtionId = table.Column(type: "int", nullable: false), + GidId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GidExecurtions", x => x.Id); + table.ForeignKey( + name: "FK_GidExecurtions_Execurtions_ExecurtionId", + column: x => x.ExecurtionId, + principalTable: "Execurtions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GidExecurtions_Gids_GidId", + column: x => x.GidId, + principalTable: "Gids", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Trips", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TripName = table.Column(type: "nvarchar(max)", nullable: false), + DateTrip = table.Column(type: "datetime2", nullable: false), + GidId = table.Column(type: "int", nullable: false), + GidFIO = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Trips", x => x.Id); + table.ForeignKey( + name: "FK_Trips_Gids_GidId", + column: x => x.GidId, + principalTable: "Gids", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "PlaceVisits", columns: table => new @@ -98,6 +161,32 @@ namespace TourCompanyDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "PlaceVisitTrips", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PlaceVisitId = table.Column(type: "int", nullable: false), + TripId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PlaceVisitTrips", x => x.Id); + table.ForeignKey( + name: "FK_PlaceVisitTrips_PlaceVisits_PlaceVisitId", + column: x => x.PlaceVisitId, + principalTable: "PlaceVisits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PlaceVisitTrips_Trips_TripId", + column: x => x.TripId, + principalTable: "Trips", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "ExecurtionTours", columns: table => new @@ -160,11 +249,31 @@ namespace TourCompanyDatabaseImplement.Migrations table: "ExecurtionTours", column: "TourId"); + migrationBuilder.CreateIndex( + name: "IX_GidExecurtions_ExecurtionId", + table: "GidExecurtions", + column: "ExecurtionId"); + + migrationBuilder.CreateIndex( + name: "IX_GidExecurtions_GidId", + table: "GidExecurtions", + column: "GidId"); + migrationBuilder.CreateIndex( name: "IX_PlaceVisits_TourGroupId", table: "PlaceVisits", column: "TourGroupId"); + migrationBuilder.CreateIndex( + name: "IX_PlaceVisitTrips_PlaceVisitId", + table: "PlaceVisitTrips", + column: "PlaceVisitId"); + + migrationBuilder.CreateIndex( + name: "IX_PlaceVisitTrips_TripId", + table: "PlaceVisitTrips", + column: "TripId"); + migrationBuilder.CreateIndex( name: "IX_TourGroupTours_TourGroupId", table: "TourGroupTours", @@ -179,6 +288,11 @@ namespace TourCompanyDatabaseImplement.Migrations name: "IX_Tours_UserId", table: "Tours", column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Trips_GidId", + table: "Trips", + column: "GidId"); } /// @@ -188,7 +302,10 @@ namespace TourCompanyDatabaseImplement.Migrations name: "ExecurtionTours"); migrationBuilder.DropTable( - name: "PlaceVisits"); + name: "GidExecurtions"); + + migrationBuilder.DropTable( + name: "PlaceVisitTrips"); migrationBuilder.DropTable( name: "TourGroupTours"); @@ -197,11 +314,20 @@ namespace TourCompanyDatabaseImplement.Migrations name: "Execurtions"); migrationBuilder.DropTable( - name: "TourGroups"); + name: "PlaceVisits"); + + migrationBuilder.DropTable( + name: "Trips"); migrationBuilder.DropTable( name: "Tours"); + migrationBuilder.DropTable( + name: "TourGroups"); + + migrationBuilder.DropTable( + name: "Gids"); + migrationBuilder.DropTable( name: "Users"); } diff --git a/TourCompanyDatabaseImplement/Migrations/TourCompanyDatabaseModelSnapshot.cs b/TourCompanyDatabaseImplement/Migrations/TourCompanyDatabaseModelSnapshot.cs index aaf70cf..9587d1a 100644 --- a/TourCompanyDatabaseImplement/Migrations/TourCompanyDatabaseModelSnapshot.cs +++ b/TourCompanyDatabaseImplement/Migrations/TourCompanyDatabaseModelSnapshot.cs @@ -68,6 +68,52 @@ namespace TourCompanyDatabaseImplement.Migrations b.ToTable("ExecurtionTours"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Gid", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Experion") + .HasColumnType("int"); + + b.Property("GidFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Gids"); + }); + + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.GidExecurtion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExecurtionId") + .HasColumnType("int"); + + b.Property("GidId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ExecurtionId"); + + b.HasIndex("GidId"); + + b.ToTable("GidExecurtions"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisit", b => { b.Property("Id") @@ -97,6 +143,29 @@ namespace TourCompanyDatabaseImplement.Migrations b.ToTable("PlaceVisits"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisitTrip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PlaceVisitId") + .HasColumnType("int"); + + b.Property("TripId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PlaceVisitId"); + + b.HasIndex("TripId"); + + b.ToTable("PlaceVisitTrips"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Tour", b => { b.Property("Id") @@ -165,6 +234,35 @@ namespace TourCompanyDatabaseImplement.Migrations b.ToTable("TourGroupTours"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Trip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DateTrip") + .HasColumnType("datetime2"); + + b.Property("GidFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GidId") + .HasColumnType("int"); + + b.Property("TripName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GidId"); + + b.ToTable("Trips"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.User", b => { b.Property("Id") @@ -209,6 +307,25 @@ namespace TourCompanyDatabaseImplement.Migrations b.Navigation("Tour"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.GidExecurtion", b => + { + b.HasOne("TourCompanyDatabaseImplement.Models.Execurtion", "Execurtion") + .WithMany() + .HasForeignKey("ExecurtionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TourCompanyDatabaseImplement.Models.Gid", "Gid") + .WithMany("Execurtions") + .HasForeignKey("GidId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Execurtion"); + + b.Navigation("Gid"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisit", b => { b.HasOne("TourCompanyDatabaseImplement.Models.TourGroup", "TourGroup") @@ -220,6 +337,25 @@ namespace TourCompanyDatabaseImplement.Migrations b.Navigation("TourGroup"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisitTrip", b => + { + b.HasOne("TourCompanyDatabaseImplement.Models.PlaceVisit", "PlaceVisit") + .WithMany("Trips") + .HasForeignKey("PlaceVisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TourCompanyDatabaseImplement.Models.Trip", "Trip") + .WithMany() + .HasForeignKey("TripId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PlaceVisit"); + + b.Navigation("Trip"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Tour", b => { b.HasOne("TourCompanyDatabaseImplement.Models.User", "User") @@ -250,11 +386,32 @@ namespace TourCompanyDatabaseImplement.Migrations b.Navigation("TourGroup"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Trip", b => + { + b.HasOne("TourCompanyDatabaseImplement.Models.Gid", "Gid") + .WithMany() + .HasForeignKey("GidId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Gid"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Execurtion", b => { b.Navigation("Tours"); }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Gid", b => + { + b.Navigation("Execurtions"); + }); + + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.PlaceVisit", b => + { + b.Navigation("Trips"); + }); + modelBuilder.Entity("TourCompanyDatabaseImplement.Models.TourGroup", b => { b.Navigation("Tours"); diff --git a/TourCompanyDatabaseImplement/Models/Gid.cs b/TourCompanyDatabaseImplement/Models/Gid.cs new file mode 100644 index 0000000..a0432be --- /dev/null +++ b/TourCompanyDatabaseImplement/Models/Gid.cs @@ -0,0 +1,96 @@ +using TourCompanyDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.ViewModels; +using TourCompanyDataModels.Models; + +namespace TourCompanyDatabaseImplement.Models +{ + public class Gid : IGidModel + { + public int Id { get; set; } + + public string GidFIO { get; set; } = string.Empty; + + public int Experion { get; set; } + + public int UserId { get; set; } + public Dictionary? _gidExecurtions = null; + public virtual List Execurtions { get; set; } = new(); + public Dictionary GidExecurtions + { + get + { + if (_gidExecurtions == null) + { + _gidExecurtions = Execurtions + .ToDictionary(recPC => recPC.ExecurtionId, recPC => (recPC.Execurtion as IExecurtionModel)); + } + return _gidExecurtions; + } + } + public static Gid Create(TourCompanyDatabase context, GidBindingModel model) + { + return new Gid() + { + Id = model.Id, + GidFIO = model.GidFIO, + Experion = model.Experion, + Execurtions = model.GidExecurtions.Select(x => new GidExecurtion + { + Execurtion = context.Execurtions.First(y => y.Id == x.Key), + }).ToList() + }; + } + public void Update(GidBindingModel model) + { + GidFIO = model.GidFIO; + Experion = model.Experion; + } + public GidViewModel GetViewModel + { + get + { + using var context = new TourCompanyDatabase(); + return new GidViewModel + { + Id = Id, + GidFIO = GidFIO, + Experion = Experion, + GidExecurtions = GidExecurtions + }; + } + } + public void UpdateExecurtions(TourCompanyDatabase context, GidBindingModel model) + { + var gidExecurtions = context.GidExecurtions.Where(rec => rec.GidId == model.Id).ToList(); + if (gidExecurtions != null) + { // удалили те, которых нет в модели + context.GidExecurtions.RemoveRange(gidExecurtions.Where(rec => !model.GidExecurtions.ContainsKey(rec.ExecurtionId))); + context.SaveChanges(); + // обновили количество у существующих записей + foreach (var UpdateExecurtion in gidExecurtions) + { + model.GidExecurtions.Remove(UpdateExecurtion.Id); + } + context.SaveChanges(); + } + var gid = context.Gids.First(x => x.Id == Id); + foreach (var pc in model.GidExecurtions) + { + context.GidExecurtions.Add(new GidExecurtion + { + Gid = gid, + Execurtion = context.Execurtions.First(x => x.Id == pc.Key), + }); + context.SaveChanges(); + } + _gidExecurtions = null; + } + + } +} diff --git a/TourCompanyDatabaseImplement/Models/GidExecurtion.cs b/TourCompanyDatabaseImplement/Models/GidExecurtion.cs new file mode 100644 index 0000000..3233d2c --- /dev/null +++ b/TourCompanyDatabaseImplement/Models/GidExecurtion.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyDatabaseImplement.Models +{ + public class GidExecurtion + { + public int Id { get; set; } + + [Required] + public int ExecurtionId { get; set; } + + [Required] + public int GidId { get; set; } + public virtual Execurtion Execurtion { get; set; } = new(); + + public virtual Gid Gid { get; set; } = new(); + } +} diff --git a/TourCompanyDatabaseImplement/Models/PlaceVisit.cs b/TourCompanyDatabaseImplement/Models/PlaceVisit.cs index d7d223f..e8d1ec3 100644 --- a/TourCompanyDatabaseImplement/Models/PlaceVisit.cs +++ b/TourCompanyDatabaseImplement/Models/PlaceVisit.cs @@ -22,7 +22,22 @@ namespace TourCompanyDatabaseImplement.Models public string TourGroupName { get; set; } public TourGroup TourGroup { get; set; } - public static PlaceVisit? Create(PlaceVisitBindingModel? model) + public Dictionary? _placeVisitTrips = null; + public virtual List Trips { get; set; } = new(); + + public Dictionary PlaceVisitTrips + { + get + { + if (_placeVisitTrips == null) + { + _placeVisitTrips = Trips + .ToDictionary(recPC => recPC.TripId, recPC => recPC.Trip as ITripModel); + } + return _placeVisitTrips; + } + } + public static PlaceVisit? Create(TourCompanyDatabase context, PlaceVisitBindingModel? model) { return new PlaceVisit() { @@ -30,8 +45,12 @@ namespace TourCompanyDatabaseImplement.Models PlaceVisitName = model.PlaceVisitName, DatePlaceVisit = model.DatePlaceVisit, TourGroupId = model.TourGroupId, - TourGroupName = model.TourGroupName - }; + TourGroupName = model.TourGroupName, + Trips = model.PlaceVisitTrips.Select(x => new PlaceVisitTrip + { + Trip = context.Trips.First(y => y.Id == x.Key) + }).ToList() + }; } public void Update(PlaceVisitBindingModel model) { @@ -49,9 +68,36 @@ namespace TourCompanyDatabaseImplement.Models PlaceVisitName = PlaceVisitName, DatePlaceVisit = DatePlaceVisit, TourGroupId = TourGroupId, - TourGroupName = context.TourGroups.FirstOrDefault(x => x.Id == TourGroupId)?.TourGroupName ?? string.Empty + TourGroupName = context.TourGroups.FirstOrDefault(x => x.Id == TourGroupId)?.TourGroupName ?? string.Empty, + PlaceVisitTrips = PlaceVisitTrips }; } } + public void UpdateTrips(TourCompanyDatabase context, PlaceVisitBindingModel model) + { + var placeVisitTrips = context.PlaceVisitTrips.Where(rec => rec.PlaceVisitId == model.Id).ToList(); + if (placeVisitTrips != null) + { // удалили те, которых нет в модели + context.PlaceVisitTrips.RemoveRange(placeVisitTrips.Where(rec => !model.PlaceVisitTrips.ContainsKey(rec.TripId))); + context.SaveChanges(); + // обновили количество у существующих записей + foreach (var updateTour in placeVisitTrips) + { + model.PlaceVisitTrips.Remove(updateTour.TripId); + } + context.SaveChanges(); + } + var placeVisit = context.PlaceVisits.First(x => x.Id == Id); + foreach (var pc in model.PlaceVisitTrips) + { + context.PlaceVisitTrips.Add(new PlaceVisitTrip + { + PlaceVisit = placeVisit, + Trip = context.Trips.First(x => x.Id == pc.Key), + }); + context.SaveChanges(); + } + _placeVisitTrips = null; + } } } diff --git a/TourCompanyDatabaseImplement/Models/PlaceVisitTrip.cs b/TourCompanyDatabaseImplement/Models/PlaceVisitTrip.cs new file mode 100644 index 0000000..9c52027 --- /dev/null +++ b/TourCompanyDatabaseImplement/Models/PlaceVisitTrip.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyDatabaseImplement.Models +{ + public class PlaceVisitTrip + { + public int Id { get; set; } + + [Required] + public int PlaceVisitId { get; set; } + + [Required] + public int TripId { get; set; } + public virtual PlaceVisit PlaceVisit { get; set; } = new(); + + public virtual Trip Trip { get; set; } = new(); + } +} diff --git a/TourCompanyDatabaseImplement/Models/Trip.cs b/TourCompanyDatabaseImplement/Models/Trip.cs new file mode 100644 index 0000000..ddc69da --- /dev/null +++ b/TourCompanyDatabaseImplement/Models/Trip.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BindingModels; +using TourCompanyContracts.ViewModels; +using TourCompanyDataModels.Models; + +namespace TourCompanyDatabaseImplement.Models +{ + public class Trip : ITripModel + { + public int Id { get; set; } + + public string TripName { get; set; } + + public DateTime DateTrip { get; set; } + + public int GidId { get; set; } + public string GidFIO { get; set; } + public virtual Gid Gid { get; set; } + public static Trip? Create(TripBindingModel? model) + { + return new Trip() + { + Id = model.Id, + TripName = model.TripName, + DateTrip = model.DateTrip, + GidId = model.GidId, + GidFIO = model.GidFIO + }; + } + public void Update(TripBindingModel model) + { + TripName = model.TripName; + DateTrip = model.DateTrip; + } + public TripViewModel GetViewModel + { + get + { + using var context = new TourCompanyDatabase(); + return new TripViewModel + { + Id = Id, + TripName = TripName, + DateTrip = DateTrip, + GidId = GidId, + GidFIO = context.Gids.FirstOrDefault(x => x.Id == GidId)?.GidFIO ?? string.Empty, + }; + } + } + } +} diff --git a/TourCompanyDatabaseImplement/TourCompanyDatabase.cs b/TourCompanyDatabaseImplement/TourCompanyDatabase.cs index 08983e6..c1b1c2a 100644 --- a/TourCompanyDatabaseImplement/TourCompanyDatabase.cs +++ b/TourCompanyDatabaseImplement/TourCompanyDatabase.cs @@ -21,8 +21,12 @@ namespace TourCompanyDatabaseImplement public virtual DbSet Execurtions { set; get; } public virtual DbSet PlaceVisits { set; get; } public virtual DbSet TourGroups { set; get; } + public virtual DbSet Trips { set; get; } + public virtual DbSet Gids { set; get; } public virtual DbSet ExecurtionTours { set; get; } public virtual DbSet TourGroupTours { set; get; } + public virtual DbSet PlaceVisitTrips { set; get; } + public virtual DbSet GidExecurtions { set; get; } } } \ No newline at end of file diff --git a/TourCompanyDatabaseImplement/TourCompanyDatabaseImplement.csproj b/TourCompanyDatabaseImplement/TourCompanyDatabaseImplement.csproj index 9adcbcd..3feafee 100644 --- a/TourCompanyDatabaseImplement/TourCompanyDatabaseImplement.csproj +++ b/TourCompanyDatabaseImplement/TourCompanyDatabaseImplement.csproj @@ -6,10 +6,6 @@ enable - - - -