diff --git a/TourCompany.sln b/TourCompany.sln new file mode 100644 index 0000000..3a470b5 --- /dev/null +++ b/TourCompany.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TourCompanyContracts", "TourCompanyContracts\TourCompanyContracts.csproj", "{1C9D15EE-1E71-459A-B41A-FEA3D8E54C09}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TourCompanyDataModels", "TourCompanyDataModels\TourCompanyDataModels.csproj", "{D207F1E7-0345-42EC-B132-22B02245EC8B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TourCompanyBusinessLogic", "TourCompanyBusinessLogic\TourCompanyBusinessLogic.csproj", "{BFE0F3CB-9786-4F6D-92FC-481FE679AD86}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TourCompanyDatabaseImplement", "TourCompanyDatabaseImplement\TourCompanyDatabaseImplement.csproj", "{A4E4547E-B6F7-467F-AB69-2BB335684BA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1C9D15EE-1E71-459A-B41A-FEA3D8E54C09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C9D15EE-1E71-459A-B41A-FEA3D8E54C09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C9D15EE-1E71-459A-B41A-FEA3D8E54C09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C9D15EE-1E71-459A-B41A-FEA3D8E54C09}.Release|Any CPU.Build.0 = Release|Any CPU + {D207F1E7-0345-42EC-B132-22B02245EC8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D207F1E7-0345-42EC-B132-22B02245EC8B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D207F1E7-0345-42EC-B132-22B02245EC8B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D207F1E7-0345-42EC-B132-22B02245EC8B}.Release|Any CPU.Build.0 = Release|Any CPU + {BFE0F3CB-9786-4F6D-92FC-481FE679AD86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFE0F3CB-9786-4F6D-92FC-481FE679AD86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFE0F3CB-9786-4F6D-92FC-481FE679AD86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFE0F3CB-9786-4F6D-92FC-481FE679AD86}.Release|Any CPU.Build.0 = Release|Any CPU + {A4E4547E-B6F7-467F-AB69-2BB335684BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4E4547E-B6F7-467F-AB69-2BB335684BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4E4547E-B6F7-467F-AB69-2BB335684BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4E4547E-B6F7-467F-AB69-2BB335684BA2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4AD4809C-075B-453F-B1E2-A6EA4597F3B2} + EndGlobalSection +EndGlobal diff --git a/TourCompanyBusinessLogic/BusinessLogics/ExecurtionLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/ExecurtionLogic.cs new file mode 100644 index 0000000..bd250be --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/ExecurtionLogic.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using TourCompanyContracts.BusinessLogicsContracts; +using TourCompanyContracts.BindingModels; + +using TourCompanyContracts.SearchModels; +using TourCompanyContracts.StoragesContracts; +using TourCompanyContracts.ViewModels; + +namespace TourCompanyBusinessLogic.BusinessLogics +{ + internal class ExecurtionLogic : IExecurtionLogic + { + private readonly ILogger _logger; + private readonly IExecurtionStorage _execurtionStorage; + public ExecurtionLogic(ILogger logger, IExecurtionStorage execurtionStorage) + { + _logger = logger; + _execurtionStorage = execurtionStorage; + } + public List? ReadList(ExecurtionSearchModel? model) + { + _logger.LogInformation("ReadList. Purpose:{Purpose}. Id:{ Id}", model?.Purpose, model?.Id); + var list = model == null ? _execurtionStorage.GetFullList() : _execurtionStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ExecurtionViewModel? ReadElement(ExecurtionSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Purpose:{Purpose}. Id:{ Id}", model.Purpose, model.Id); + var element = _execurtionStorage.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(ExecurtionBindingModel model) + { + CheckModel(model); + if (_execurtionStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ExecurtionBindingModel model) + { + CheckModel(model); + if (_execurtionStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ExecurtionBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_execurtionStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ExecurtionBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Purpose)) + { + throw new ArgumentNullException("Нет цели экскурсии", nameof(model.Purpose)); + } + _logger.LogInformation("Execurtion. Purpose:{Purpose}. Id: { Id}", model.Purpose, model.Id); + var element = _execurtionStorage.GetElement(new ExecurtionSearchModel + { + Purpose = model.Purpose + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/GidLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/GidLogic.cs new file mode 100644 index 0000000..f04ad6f --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/GidLogic.cs @@ -0,0 +1,119 @@ +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 +{ + internal 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. UserId:{UserId}. ExecurtionId:{ExecurtionId}. TripId:{TripId}. Id: { Id}", model?.UserId, model?.ExecurtionId, model?.TripId, 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.UserId:{UserId}. ExecurtionId:{ExecurtionId}. TripId:{TripId}. Id: { Id}", model.UserId, model.ExecurtionId, model.TripId, 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; + } + if (model.TripId == null) + { + throw new ArgumentNullException("нет внешнего ключа поездки", nameof(model.TripId)); + } + if (model.UserId == null) + { + throw new ArgumentNullException("нет внешнего ключа пользователя", nameof(model.UserId)); + } + if (model.ExecurtionId == null) + { + throw new ArgumentNullException("нет внешнего ключа экскурсии", nameof(model.ExecurtionId)); + } + _logger.LogInformation("Gid. UserId:{UserId}. ExecurtionId:{ExecurtionId}. TripId:{TripId}. Id: { Id}", model.UserId, model.ExecurtionId, model.TripId, model.Id); + var element = _gidStorage.GetElement(new GidSearchModel + { + TripId = model.TripId, + UserId = model.UserId, + ExecurtionId = model.ExecurtionId + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/PlaceVisitLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/PlaceVisitLogic.cs new file mode 100644 index 0000000..59fe65e --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/PlaceVisitLogic.cs @@ -0,0 +1,114 @@ +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 +{ + internal class PlaceVisitLogic : IPlaceVisitLogic + { + private readonly ILogger _logger; + private readonly IPlaceVisitStorage _placeVisitStorage; + public PlaceVisitLogic(ILogger logger, IPlaceVisitStorage placeVisitStorage) + { + _logger = logger; + _placeVisitStorage = placeVisitStorage; + } + public List? ReadList(PlaceVisitSearchModel? model) + { + _logger.LogInformation("ReadList. UserId:{UserId}. TourGroupId:{TourGroupId}. Id: { Id}", model?.UserId, model?.TourGroupId, model?.Id); + var list = model == null ? _placeVisitStorage.GetFullList() : _placeVisitStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public PlaceVisitViewModel? ReadElement(PlaceVisitSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement.UserId:{UserId}. TourGroupId:{TourGroupId}. Id: { Id}", model.UserId, model.TourGroupId, model.Id); + var element = _placeVisitStorage.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(PlaceVisitBindingModel model) + { + CheckModel(model); + if (_placeVisitStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(PlaceVisitBindingModel model) + { + CheckModel(model); + if (_placeVisitStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(PlaceVisitBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_placeVisitStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(PlaceVisitBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.UserId == null) + { + throw new ArgumentNullException("нет внешнего ключа пользователя", nameof(model.UserId)); + } + if (model.TourGroupId == null) + { + throw new ArgumentNullException("нет внешнего ключа тур группы", nameof(model.TourGroupId)); + } + _logger.LogInformation("PlaceVisit. UserId:{UserId}. TourGroupId:{TourGroupId}. Id: { Id}", model.UserId, model.TourGroupId, model.Id); + var element = _placeVisitStorage.GetElement(new PlaceVisitSearchModel + { + UserId = model.UserId, + TourGroupId = model.TourGroupId + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/ReportLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/ReportLogic.cs new file mode 100644 index 0000000..b6701fc --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/ReportLogic.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyContracts.BusinessLogicsContracts; + +namespace TourCompanyBusinessLogic.BusinessLogics +{ + internal class ReportLogic //: IReportLogic + { + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/TourGroupLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/TourGroupLogic.cs new file mode 100644 index 0000000..0afb70e --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/TourGroupLogic.cs @@ -0,0 +1,110 @@ +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 +{ + internal class TourGroupLogic : ITourGroupLogic + { + private readonly ILogger _logger; + private readonly ITourGroupStorage _tourGroupStorage; + public TourGroupLogic(ILogger logger, ITourGroupStorage tourGroupStorage) + { + _logger = logger; + _tourGroupStorage = tourGroupStorage; + } + public List? ReadList(TourGroupSearchModel? model) + { + _logger.LogInformation("ReadList. UserId:{UserId}. Id: { Id}", model?.UserId, model?.Id); + var list = model == null ? _tourGroupStorage.GetFullList() : _tourGroupStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public TourGroupViewModel? ReadElement(TourGroupSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement.UserId:{UserId}. Id: { Id}", model.UserId, model.Id); + var element = _tourGroupStorage.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(TourGroupBindingModel model) + { + CheckModel(model); + if (_tourGroupStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(TourGroupBindingModel model) + { + CheckModel(model); + if (_tourGroupStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(TourGroupBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_tourGroupStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(TourGroupBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.UserId == null) + { + throw new ArgumentNullException("нет внешнего ключа пользователя", nameof(model.UserId)); + } + + _logger.LogInformation("TourGroup. UserId:{UserId}. Id: { Id}", model.UserId, model.Id); + var element = _tourGroupStorage.GetElement(new TourGroupSearchModel + { + UserId = model.UserId + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/TourLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/TourLogic.cs new file mode 100644 index 0000000..cee0ae9 --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/TourLogic.cs @@ -0,0 +1,110 @@ +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 +{ + internal class TourLogic : ITourLogic + { + private readonly ILogger _logger; + private readonly ITourStorage _tourStorage; + public TourLogic(ILogger logger, ITourStorage tourStorage) + { + _logger = logger; + _tourStorage = tourStorage; + } + public List? ReadList(TourSearchModel? model) + { + _logger.LogInformation("ReadList. UserId:{UserId}. Id: { Id}", model?.UserId, model?.Id); + var list = model == null ? _tourStorage.GetFullList() : _tourStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public TourViewModel? ReadElement(TourSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement.UserId:{UserId}. Id: { Id}", model.UserId, model.Id); + var element = _tourStorage.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(TourBindingModel model) + { + CheckModel(model); + if (_tourStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(TourBindingModel model) + { + CheckModel(model); + if (_tourStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(TourBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_tourStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(TourBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.UserId == null) + { + throw new ArgumentNullException("нет внешнего ключа пользователя", nameof(model.UserId)); + } + + _logger.LogInformation("Tour. UserId:{UserId}. Id: { Id}", model.UserId, model.Id); + var element = _tourStorage.GetElement(new TourSearchModel + { + UserId = model.UserId + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/TripLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/TripLogic.cs new file mode 100644 index 0000000..7b4882b --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/TripLogic.cs @@ -0,0 +1,110 @@ +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 +{ + internal 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. UserId:{UserId}. Id: { Id}", model?.UserId, 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.UserId:{UserId}. Id: { Id}", model.UserId, 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; + } + if (model.UserId == null) + { + throw new ArgumentNullException("нет внешнего ключа пользователя", nameof(model.UserId)); + } + + _logger.LogInformation("Trip. UserId:{UserId}. Id: { Id}", model.UserId, model.Id); + var element = _tripStorage.GetElement(new TripSearchModel + { + UserId = model.UserId + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/BusinessLogics/UserLogic.cs b/TourCompanyBusinessLogic/BusinessLogics/UserLogic.cs new file mode 100644 index 0000000..d93c3a0 --- /dev/null +++ b/TourCompanyBusinessLogic/BusinessLogics/UserLogic.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 +{ + internal class UserLogic : IUserLogic + { + private readonly ILogger _logger; + private readonly IUserStorage _userStorage; + public UserLogic(ILogger logger, IUserStorage userStorage) + { + _logger = logger; + _userStorage = userStorage; + } + public List? ReadList(UserSearchModel? model) + { + _logger.LogInformation("ReadList. FIO:{FIO}. Id: { Id}", model?.FIO, model?.Id); + var list = model == null ? _userStorage.GetFullList() : _userStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public UserViewModel? ReadElement(UserSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement.FIO:{FIO}. Id: { Id}", model.FIO, model.Id); + var element = _userStorage.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(UserBindingModel model) + { + CheckModel(model); + if (_userStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(UserBindingModel model) + { + CheckModel(model); + if (_userStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(UserBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. FIO:{FIO}. Id: { Id}", model.FIO, model.Id); + if (_userStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(UserBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + _logger.LogInformation("User. FIO:{FIO}. Id: { Id}", model.FIO, model.Id); + var element = _userStorage.GetElement(new UserSearchModel + { + FIO = model.FIO + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Пользователь уже есть"); + } + } + } +} diff --git a/TourCompanyBusinessLogic/Class1.cs b/TourCompanyBusinessLogic/Class1.cs new file mode 100644 index 0000000..3d3a6f4 --- /dev/null +++ b/TourCompanyBusinessLogic/Class1.cs @@ -0,0 +1,7 @@ +namespace TourCompanyBusinessLogic +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/TourCompanyBusinessLogic/TourCompanyBusinessLogic.csproj b/TourCompanyBusinessLogic/TourCompanyBusinessLogic.csproj new file mode 100644 index 0000000..39c344e --- /dev/null +++ b/TourCompanyBusinessLogic/TourCompanyBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/TourCompanyContracts/BindingModels/ExecurtionBindingModel.cs b/TourCompanyContracts/BindingModels/ExecurtionBindingModel.cs new file mode 100644 index 0000000..6b9685e --- /dev/null +++ b/TourCompanyContracts/BindingModels/ExecurtionBindingModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.BindingModels +{ + public class ExecurtionBindingModel + { + public int Id { get; set; } + + public string Purpose { get; set; } = string.Empty; + + public DateTime Date { get; set; } + + public int GidId { get; set; } + + public int UserId { get; set; } + + public string TourName { get; set; } = string.Empty; + + public Dictionary ExecurtionTours { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/BindingModels/GidBindingModel.cs b/TourCompanyContracts/BindingModels/GidBindingModel.cs new file mode 100644 index 0000000..a0a3568 --- /dev/null +++ b/TourCompanyContracts/BindingModels/GidBindingModel.cs @@ -0,0 +1,25 @@ +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 + { + public int Id { get; set; } + + public string FIO { get; set; } = string.Empty; + + public int Experion { get; set; } + + public int TripId { get; set; } + public string TripName { get; set; } = string.Empty; + + public int UserId { get; set; } + + public int ExecurtionId { get; set; } + } +} diff --git a/TourCompanyContracts/BindingModels/PlaceVisitBindingModel.cs b/TourCompanyContracts/BindingModels/PlaceVisitBindingModel.cs new file mode 100644 index 0000000..7221cdd --- /dev/null +++ b/TourCompanyContracts/BindingModels/PlaceVisitBindingModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.BindingModels +{ + public class PlaceVisitBindingModel + { + public int Id { get; set; } + + public string PlaceVisitName { get; set; } = string.Empty; + + public DateTime Date { get; set; } + + public int TourGroupId { get; set; } + + public int UserId { get; set; } + + // Dictionary + public Dictionary PlaceVisitTrips { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/BindingModels/ReportBindingModel.cs b/TourCompanyContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..74dc7a1 --- /dev/null +++ b/TourCompanyContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.BindingModels +{ + public class ReportBindingModel + { + public int Id { get; set; } + public string Name { get; set; } = String.Empty; + } +} diff --git a/TourCompanyContracts/BindingModels/TourBindingModel.cs b/TourCompanyContracts/BindingModels/TourBindingModel.cs new file mode 100644 index 0000000..401c1a3 --- /dev/null +++ b/TourCompanyContracts/BindingModels/TourBindingModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.BindingModels +{ + public class TourBindingModel + { + public int Id { get; set; } + + public string TourName { get; set; } = string.Empty; + + public decimal Price { get; set; } + + public int UserId { get; set; } + + public Dictionary ExecurtionTours { get; set; } = new(); + + public Dictionary TourGroups { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/BindingModels/TourGroupBindingModel.cs b/TourCompanyContracts/BindingModels/TourGroupBindingModel.cs new file mode 100644 index 0000000..e81be22 --- /dev/null +++ b/TourCompanyContracts/BindingModels/TourGroupBindingModel.cs @@ -0,0 +1,22 @@ +using TourCompanyDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.BindingModels +{ + public class TourGroupBindingModel + { + public int Id { get; set; } + + public string Number { get; set; } = string.Empty; + + public TourType Type { get; set; } + + public int UserId { get; set; } + public Dictionary TourGroupTours { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/BindingModels/TripBindingModel.cs b/TourCompanyContracts/BindingModels/TripBindingModel.cs new file mode 100644 index 0000000..1b3a519 --- /dev/null +++ b/TourCompanyContracts/BindingModels/TripBindingModel.cs @@ -0,0 +1,27 @@ +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 + { + public int Id { get; set; } + + public string TripName { get; set; } = string.Empty; + + public decimal Price { get; set; } + + public DateTime Date { get; set; } + + public int UserId { get; set; } + public Dictionary TripPlaceVisits + { + get; + set; + } = new(); + } +} diff --git a/TourCompanyContracts/BindingModels/UserBindingModel.cs b/TourCompanyContracts/BindingModels/UserBindingModel.cs new file mode 100644 index 0000000..1b36069 --- /dev/null +++ b/TourCompanyContracts/BindingModels/UserBindingModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.BindingModels +{ + public class UserBindingModel + { + public int Id { get; set; } + + public string FIO { get; set; } = string.Empty; + + public string Email { get; set; } = string.Empty; + + public string Password { get; set; } = string.Empty; + + } +} diff --git a/TourCompanyContracts/BusinessLogicsContracts/IExecurtionLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/IExecurtionLogic.cs new file mode 100644 index 0000000..86fd176 --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/IExecurtionLogic.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 IExecurtionLogic + { + List? ReadList(ExecurtionSearchModel? model); + ExecurtionViewModel? ReadElement(ExecurtionSearchModel model); + bool Create(ExecurtionBindingModel model); + bool Update(ExecurtionBindingModel model); + bool Delete(ExecurtionBindingModel model); + } +} 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/IPlaceVisitLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/IPlaceVisitLogic.cs new file mode 100644 index 0000000..daebcf0 --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/IPlaceVisitLogic.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 IPlaceVisitLogic + { + List? ReadList(PlaceVisitSearchModel? model); + PlaceVisitViewModel? ReadElement(PlaceVisitSearchModel model); + bool Create(PlaceVisitBindingModel model); + bool Update(PlaceVisitBindingModel model); + bool Delete(PlaceVisitBindingModel model); + } +} diff --git a/TourCompanyContracts/BusinessLogicsContracts/IReportLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/IReportLogic.cs new file mode 100644 index 0000000..a1fc7aa --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/IReportLogic.cs @@ -0,0 +1,23 @@ +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 IReportLogic + { + + List GetTour(ReportBindingModel model); + + void SavePlaceVisitsToWordFile(ReportBindingModel model); + + void SavePlaceVisitToExcelFile(ReportBindingModel model); + + void SaveTourToPdfFile(ReportBindingModel model); + } +} diff --git a/TourCompanyContracts/BusinessLogicsContracts/ITourGroupLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/ITourGroupLogic.cs new file mode 100644 index 0000000..50f98cf --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/ITourGroupLogic.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 ITourGroupLogic + { + List? ReadList(TourGroupSearchModel? model); + TourGroupViewModel? ReadElement(TourGroupSearchModel model); + bool Create(TourGroupBindingModel model); + bool Update(TourGroupBindingModel model); + bool Delete(TourGroupBindingModel model); + } +} diff --git a/TourCompanyContracts/BusinessLogicsContracts/ITourLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/ITourLogic.cs new file mode 100644 index 0000000..f12d43e --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/ITourLogic.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 ITourLogic + { + List? ReadList(TourSearchModel? model); + TourViewModel? ReadElement(TourSearchModel model); + bool Create(TourBindingModel model); + bool Update(TourBindingModel model); + bool Delete(TourBindingModel 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/BusinessLogicsContracts/IUserLogic.cs b/TourCompanyContracts/BusinessLogicsContracts/IUserLogic.cs new file mode 100644 index 0000000..82820c8 --- /dev/null +++ b/TourCompanyContracts/BusinessLogicsContracts/IUserLogic.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 IUserLogic + { + List? ReadList(UserSearchModel? model); + UserViewModel? ReadElement(UserSearchModel model); + bool Create(UserBindingModel model); + bool Update(UserBindingModel model); + bool Delete(UserBindingModel model); + } +} diff --git a/TourCompanyContracts/Class1.cs b/TourCompanyContracts/Class1.cs new file mode 100644 index 0000000..0d68a43 --- /dev/null +++ b/TourCompanyContracts/Class1.cs @@ -0,0 +1,7 @@ +namespace TourCompanyContracts +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/TourCompanyContracts/SearchModels/ExecurtionSearchModel.cs b/TourCompanyContracts/SearchModels/ExecurtionSearchModel.cs new file mode 100644 index 0000000..21db2f7 --- /dev/null +++ b/TourCompanyContracts/SearchModels/ExecurtionSearchModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.SearchModels +{ + public class ExecurtionSearchModel + { + public int? Id { get; set; } + public string? Purpose { get; set; } = string.Empty; + + public int? GidId { get; set; } + + public int? UserId { get; set; } + public DateTime? DateFrom { get; set; } + + public DateTime? DateTo { get; set; } + } +} diff --git a/TourCompanyContracts/SearchModels/GidSearchModel.cs b/TourCompanyContracts/SearchModels/GidSearchModel.cs new file mode 100644 index 0000000..0e941f2 --- /dev/null +++ b/TourCompanyContracts/SearchModels/GidSearchModel.cs @@ -0,0 +1,19 @@ +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 int? TripId { get; set; } + + public int? UserId { get; set; } + + public int? ExecurtionId { get; set; } + } +} diff --git a/TourCompanyContracts/SearchModels/PlaceVisitSearchModel.cs b/TourCompanyContracts/SearchModels/PlaceVisitSearchModel.cs new file mode 100644 index 0000000..a6b9ea7 --- /dev/null +++ b/TourCompanyContracts/SearchModels/PlaceVisitSearchModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.SearchModels +{ + public class PlaceVisitSearchModel + { + public int? Id { get; set; } + + public int? TourGroupId { get; set; } + + public int? UserId { get; set; } + public DateTime? DateFrom { get; set; } + + public DateTime? DateTo { get; set; } + } +} diff --git a/TourCompanyContracts/SearchModels/TourGroupSearchModel.cs b/TourCompanyContracts/SearchModels/TourGroupSearchModel.cs new file mode 100644 index 0000000..60d241d --- /dev/null +++ b/TourCompanyContracts/SearchModels/TourGroupSearchModel.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 TourGroupSearchModel + { + public int? Id { get; set; } + public int? UserId { get; set; } + } +} diff --git a/TourCompanyContracts/SearchModels/TourSearchModel.cs b/TourCompanyContracts/SearchModels/TourSearchModel.cs new file mode 100644 index 0000000..09c5f32 --- /dev/null +++ b/TourCompanyContracts/SearchModels/TourSearchModel.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 TourSearchModel + { + public int? Id { get; set; } + public int? UserId { get; set; } + } +} diff --git a/TourCompanyContracts/SearchModels/TripSearchModel.cs b/TourCompanyContracts/SearchModels/TripSearchModel.cs new file mode 100644 index 0000000..ff60b96 --- /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? UserId { get; set; } + } +} diff --git a/TourCompanyContracts/SearchModels/UserSearchModel.cs b/TourCompanyContracts/SearchModels/UserSearchModel.cs new file mode 100644 index 0000000..e7b3075 --- /dev/null +++ b/TourCompanyContracts/SearchModels/UserSearchModel.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 UserSearchModel + { + public int? Id { get; set; } + public string? FIO { get; set; } = string.Empty; + public string? Password { get; set; } = string.Empty; + } +} diff --git a/TourCompanyContracts/StoragesContracts/IExecurtionStorage.cs b/TourCompanyContracts/StoragesContracts/IExecurtionStorage.cs new file mode 100644 index 0000000..ffaf278 --- /dev/null +++ b/TourCompanyContracts/StoragesContracts/IExecurtionStorage.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 IExecurtionStorage + { + List GetFullList(); + List GetFilteredList(ExecurtionSearchModel model); + ExecurtionViewModel? GetElement(ExecurtionSearchModel model); + ExecurtionViewModel? Insert(ExecurtionBindingModel model); + ExecurtionViewModel? Update(ExecurtionBindingModel model); + ExecurtionViewModel? Delete(ExecurtionBindingModel model); + } +} 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/IPlaceVisitStorage.cs b/TourCompanyContracts/StoragesContracts/IPlaceVisitStorage.cs new file mode 100644 index 0000000..6e06dab --- /dev/null +++ b/TourCompanyContracts/StoragesContracts/IPlaceVisitStorage.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 IPlaceVisitStorage + { + List GetFullList(); + List GetFilteredList(PlaceVisitSearchModel model); + PlaceVisitViewModel? GetElement(PlaceVisitSearchModel model); + PlaceVisitViewModel? Insert(PlaceVisitBindingModel model); + PlaceVisitViewModel? Update(PlaceVisitBindingModel model); + PlaceVisitViewModel? Delete(PlaceVisitBindingModel model); + } +} diff --git a/TourCompanyContracts/StoragesContracts/ITourGroupStorage.cs b/TourCompanyContracts/StoragesContracts/ITourGroupStorage.cs new file mode 100644 index 0000000..56d08fc --- /dev/null +++ b/TourCompanyContracts/StoragesContracts/ITourGroupStorage.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 ITourGroupStorage + { + List GetFullList(); + List GetFilteredList(TourGroupSearchModel model); + TourGroupViewModel? GetElement(TourGroupSearchModel model); + TourGroupViewModel? Insert(TourGroupBindingModel model); + TourGroupViewModel? Update(TourGroupBindingModel model); + TourGroupViewModel? Delete(TourGroupBindingModel model); + } +} diff --git a/TourCompanyContracts/StoragesContracts/ITourStorage.cs b/TourCompanyContracts/StoragesContracts/ITourStorage.cs new file mode 100644 index 0000000..e09580a --- /dev/null +++ b/TourCompanyContracts/StoragesContracts/ITourStorage.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 ITourStorage + { + List GetFullList(); + List GetFilteredList(TourSearchModel model); + TourViewModel? GetElement(TourSearchModel model); + TourViewModel? Insert(TourBindingModel model); + TourViewModel? Update(TourBindingModel model); + TourViewModel? Delete(TourBindingModel 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/StoragesContracts/IUserStorage.cs b/TourCompanyContracts/StoragesContracts/IUserStorage.cs new file mode 100644 index 0000000..d5712ef --- /dev/null +++ b/TourCompanyContracts/StoragesContracts/IUserStorage.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 IUserStorage + { + List GetFullList(); + List GetFilteredList(UserSearchModel model); + UserViewModel? GetElement(UserSearchModel model); + UserViewModel? Insert(UserBindingModel model); + UserViewModel? Update(UserBindingModel model); + UserViewModel? Delete(UserBindingModel model); + } +} diff --git a/TourCompanyContracts/TourCompanyContracts.csproj b/TourCompanyContracts/TourCompanyContracts.csproj new file mode 100644 index 0000000..68b2331 --- /dev/null +++ b/TourCompanyContracts/TourCompanyContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/TourCompanyContracts/ViewModels/ExecurtionViewModel.cs b/TourCompanyContracts/ViewModels/ExecurtionViewModel.cs new file mode 100644 index 0000000..1bc46b3 --- /dev/null +++ b/TourCompanyContracts/ViewModels/ExecurtionViewModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.ViewModels +{ + public class ExecurtionViewModel + { + public int Id { get; set; } + + public string Purpose { get; set; } = string.Empty; + + public DateTime Date { get; set; } + + public int Duration { get; set; } + + public int GidId { get; set; } + + public int UserId { get; set; } + + public Dictionary ExecurtionTours { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/ViewModels/GidViewModel.cs b/TourCompanyContracts/ViewModels/GidViewModel.cs new file mode 100644 index 0000000..0ba800a --- /dev/null +++ b/TourCompanyContracts/ViewModels/GidViewModel.cs @@ -0,0 +1,25 @@ +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 + { + public int Id { get; set; } + + public string FIO { get; set; } = string.Empty; + + public int Experion { get; set; } + + public int TripId { get; set; } + public string TripName { get; set; } = string.Empty; + + public int UserId { get; set; } + + public int ExecurtionId { get; set; } + } +} diff --git a/TourCompanyContracts/ViewModels/PlaceVisitViewModel.cs b/TourCompanyContracts/ViewModels/PlaceVisitViewModel.cs new file mode 100644 index 0000000..f1fb5ed --- /dev/null +++ b/TourCompanyContracts/ViewModels/PlaceVisitViewModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.ViewModels +{ + public class PlaceVisitViewModel + { + public int Id { get; set; } + + public string PlaceVisitName { get; set; } = string.Empty; + + public DateTime Date { get; set; } + + public int TourGroupId { get; set; } + + public int UserId { get; set; } + + // Dictionary + public Dictionary PlaceVisitTrips { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/ViewModels/ReportViewModel.cs b/TourCompanyContracts/ViewModels/ReportViewModel.cs new file mode 100644 index 0000000..4ae16ca --- /dev/null +++ b/TourCompanyContracts/ViewModels/ReportViewModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.ViewModels +{ + public class ReportViewModel + { + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + } +} diff --git a/TourCompanyContracts/ViewModels/TourGroupViewModel.cs b/TourCompanyContracts/ViewModels/TourGroupViewModel.cs new file mode 100644 index 0000000..5c7ff2a --- /dev/null +++ b/TourCompanyContracts/ViewModels/TourGroupViewModel.cs @@ -0,0 +1,22 @@ +using TourCompanyDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.ViewModels +{ + public class TourGroupViewModel + { + public int Id { get; set; } + + public string Number { get; set; } = string.Empty; + + public TourType Type { get; set; } + + public int UserId { get; set; } + public Dictionary TourGroupTours { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/ViewModels/TourViewModel.cs b/TourCompanyContracts/ViewModels/TourViewModel.cs new file mode 100644 index 0000000..7ffa696 --- /dev/null +++ b/TourCompanyContracts/ViewModels/TourViewModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Models; + +namespace TourCompanyContracts.ViewModels +{ + public class TourViewModel + { + public int Id { get; set; } + + public string TourName { get; set; } = string.Empty; + + public decimal Price { get; set; } + + public int UserId { get; set; } + + public Dictionary ExecurtionTours { get; set; } = new(); + + public Dictionary TourGroups { get; set; } = new(); + } +} diff --git a/TourCompanyContracts/ViewModels/TripViewModel.cs b/TourCompanyContracts/ViewModels/TripViewModel.cs new file mode 100644 index 0000000..2d2245a --- /dev/null +++ b/TourCompanyContracts/ViewModels/TripViewModel.cs @@ -0,0 +1,27 @@ +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 + { + public int Id { get; set; } + + public string TripName { get; set; } + + public decimal Price { get; set; } + + public DateTime Date { get; set; } + + public int UserId { get; set; } + public Dictionary TripPlaceVisits + { + get; + set; + } = new(); + } +} diff --git a/TourCompanyContracts/ViewModels/UserViewModel.cs b/TourCompanyContracts/ViewModels/UserViewModel.cs new file mode 100644 index 0000000..6de6040 --- /dev/null +++ b/TourCompanyContracts/ViewModels/UserViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyContracts.ViewModels +{ + public class UserViewModel + { + public int Id { get; set; } + + public string FIO { get; set; } + + public string Email { get; set; } + + public string Password { get; set; } + + } +} diff --git a/TourCompanyDataModels/Enums/TourType.cs b/TourCompanyDataModels/Enums/TourType.cs new file mode 100644 index 0000000..c8e3680 --- /dev/null +++ b/TourCompanyDataModels/Enums/TourType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TourCompanyDataModels.Enums +{ + public enum TourType + { + Учебный = 0, + Гражданский = 1 + + } +} diff --git a/TourCompanyDataModels/IId.cs b/TourCompanyDataModels/IId.cs new file mode 100644 index 0000000..8d9f8d1 --- /dev/null +++ b/TourCompanyDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace TourCompanyDataModels +{ + public interface IId + { + int Id { get; } + } +} \ No newline at end of file diff --git a/TourCompanyDataModels/Models/IExecurtionModel.cs b/TourCompanyDataModels/Models/IExecurtionModel.cs new file mode 100644 index 0000000..ff43621 --- /dev/null +++ b/TourCompanyDataModels/Models/IExecurtionModel.cs @@ -0,0 +1,26 @@ +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 IExecurtionModel : IId + { + public string Purpose { get;} + + public DateTime Date { get; } + + public int Duration { get; } + + public int GidId { get; } + + public int UserId { get; } + + public string TourName { get; } + + public Dictionary Tours { get; } + } +} diff --git a/TourCompanyDataModels/Models/IGidModel.cs b/TourCompanyDataModels/Models/IGidModel.cs new file mode 100644 index 0000000..16ddf03 --- /dev/null +++ b/TourCompanyDataModels/Models/IGidModel.cs @@ -0,0 +1,23 @@ +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 FIO { get;} + + public int Experion { get; } + + public int TripId { get; } + public string TripName { get; } + + public int UserId { get; } + + public int ExecurtionId { get; } + } +} diff --git a/TourCompanyDataModels/Models/IPlaceVisitModel.cs b/TourCompanyDataModels/Models/IPlaceVisitModel.cs new file mode 100644 index 0000000..3fbee56 --- /dev/null +++ b/TourCompanyDataModels/Models/IPlaceVisitModel.cs @@ -0,0 +1,22 @@ +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 IPlaceVisitModel : IId + { + public string PlaceVisitName { get; } + + public DateTime Date { get;} + + public int TourGroupId { get; } + + public int UserId { get; } + + public Dictionary Trips { get; } + } +} diff --git a/TourCompanyDataModels/Models/ITourGroupModel.cs b/TourCompanyDataModels/Models/ITourGroupModel.cs new file mode 100644 index 0000000..9a40aa3 --- /dev/null +++ b/TourCompanyDataModels/Models/ITourGroupModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using TourCompanyDataModels.Enums; + +namespace TourCompanyDataModels.Models +{ + public interface ITourGroupModel : IId + { + + public string Number { get; } + + public TourType Type { get; } + + public int UserId { get; } + public Dictionary Tours { get; } + } +} diff --git a/TourCompanyDataModels/Models/ITourModel.cs b/TourCompanyDataModels/Models/ITourModel.cs new file mode 100644 index 0000000..1525a7a --- /dev/null +++ b/TourCompanyDataModels/Models/ITourModel.cs @@ -0,0 +1,23 @@ +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 ITourModel : IId + { + + public string TourName { get; } + + public decimal Price { get; set; } + + public int UserId { get; set; } + + public Dictionary Execurtions { get; } + + public Dictionary TourGroups { get; } + } +} diff --git a/TourCompanyDataModels/Models/ITripModel.cs b/TourCompanyDataModels/Models/ITripModel.cs new file mode 100644 index 0000000..6891ad4 --- /dev/null +++ b/TourCompanyDataModels/Models/ITripModel.cs @@ -0,0 +1,21 @@ +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 decimal Price { get; } + + public DateTime Date { get; } + + public int UserId { get; } + public Dictionary TripPlaceVisits{ get; } + } +} diff --git a/TourCompanyDataModels/Models/IUserModel.cs b/TourCompanyDataModels/Models/IUserModel.cs new file mode 100644 index 0000000..c9aaa6f --- /dev/null +++ b/TourCompanyDataModels/Models/IUserModel.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 IUserModel : IId + { + public string FIO { get; } + + public string Email { get; } + + public string Password { get; } + } +} diff --git a/TourCompanyDataModels/TourCompanyDataModels.csproj b/TourCompanyDataModels/TourCompanyDataModels.csproj new file mode 100644 index 0000000..27ac386 --- /dev/null +++ b/TourCompanyDataModels/TourCompanyDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/TourCompanyDatabaseImplement/Class1.cs b/TourCompanyDatabaseImplement/Class1.cs new file mode 100644 index 0000000..0e233da --- /dev/null +++ b/TourCompanyDatabaseImplement/Class1.cs @@ -0,0 +1,7 @@ +namespace TourCompanyDatabaseImplement +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/TourCompanyDatabaseImplement/TourCompanyDatabaseImplement.csproj b/TourCompanyDatabaseImplement/TourCompanyDatabaseImplement.csproj new file mode 100644 index 0000000..98e270e --- /dev/null +++ b/TourCompanyDatabaseImplement/TourCompanyDatabaseImplement.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + +