конец

This commit is contained in:
Kate 2023-06-24 04:08:10 +03:00
parent eb7c8c93b1
commit 39ecbd7fc3
17 changed files with 36 additions and 616 deletions

View File

@ -121,8 +121,7 @@ namespace TravelCompanyBusinessLogic.BusinessLogics
var traveles = travelStorage.GetFilteredList(new TravelSearchModel
{
TouristId = model.TouristId
})/*.Where(x => model.TouristId.Contains(x.TouristId))*/.ToList();
})
foreach (var travel in traveles)
{
@ -151,42 +150,6 @@ namespace TravelCompanyBusinessLogic.BusinessLogics
}
return list;
}
/* private List<ReportExcursionView> GetExcursionsByTours(ReportBindingModel model)
{
var list = new List<ReportExcursionView>();
var tours = tourStorage.GetFilteredList(null).Where(x => model.TourId.Contains(x.Id));
foreach (var tour in tours)
{
var record = new ReportExcursionView
{
Tour = tour,
Excursions = new List<ExcursionViewModel>()
};
var tourGuide = tour.Gui.Keys.ToList();
foreach (var guideId in tourGuide)
{
var excursions = excursionStorage.GetExcursionGuidesList(new ExcursionSearchModel { GuideId = guideId });
excursions.ForEach(x =>
{
if (record.Excursions.Find(y => y.Id == x.Id) == null) record.Excursions.Add(x);
});
}
list.Add(record);
}
return list;
}*/
//public void saveTravelesToPdfFile(ReportBindingModel model)
//{
// saveToPdf.CreateTravelDoc(new PdfInfo
// {
// Title = "Список обедов",
// DateAfter = model.DateAfter.Value,
// DateBefore = model.DateBefore.Value,
// Traveles = GetTravelsPCView(model)
//});
//}
public void saveGuidesToPdfFile(ReportBindingModel model)
{
saveToPdf.CreateGuideDoc(new PdfInfo
@ -206,14 +169,6 @@ namespace TravelCompanyBusinessLogic.BusinessLogics
Guides = GetGuidesByTravels(model)
});
}
/* public void saveExcursionsToExcel(ReportBindingModel model)
{
saveToExcel.CreateExcursionsReport(new ExcelInfo()
{
Title = "Список заказов:",
Excursions = GetExcursionsByTours(model)
});
}*/
public void saveGuidesToWord(ReportBindingModel model)
{
saveToWord.CreateGuidesDoc(new WordInfo()
@ -222,13 +177,5 @@ namespace TravelCompanyBusinessLogic.BusinessLogics
Guides = GetGuidesByTravels(model)
});
}
/* public void saveExcursionsToWord(ReportBindingModel model)
{
saveToWord.CreateExcursionsDoc(new WordInfo()
{
Title = "Список заказов",
Excursions = GetExcursionsByTours(model)
});
}*/
}
}

View File

@ -12,11 +12,8 @@ namespace TravelCompanyBusinessLogic.MailWorker
protected string _popHost = string.Empty;
protected int _popPort;
// private readonly ILogger _logger;
public AbstractMailWorker()
{
{
}
public void MailConfig(MailConfigBindingModel config)
@ -28,7 +25,6 @@ namespace TravelCompanyBusinessLogic.MailWorker
_popHost = config.PopHost;
_popPort = config.PopPort;
// _logger.LogDebug("Config: {login}, {password}, {clientHost},{ clientPOrt}, { popHost}, { popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
}
public async void MailSendAsync(MailSendInfoBindingModel info)
@ -47,8 +43,6 @@ namespace TravelCompanyBusinessLogic.MailWorker
{
return;
}
// _logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
await SendMailAsync(info);
}

View File

@ -1,87 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using TravelCompanyContracts.BindingModels.TouristBindingModels;
using TravelCompanyContracts.BusinessLogicsContracts.TouristBusinessLogicsContracts;
using TravelCompanyContracts.SearchModels.TouristSearchModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;
[Route("api/[controller]/[action]")]
[ApiController]
public class ExcursionController : Controller
{
private readonly ILogger _logger;
private readonly IExcursionLogic _logic;
public ExcursionController(ILogger<ExcursionController> logger, IExcursionLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<ExcursionViewModel>? GetExcursions(int touristId)
{
try
{
return _logic.ReadList(new ExcursionSearchModel { TouristId = touristId });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка экскурсий клиента id={Id}", touristId);
throw;
}
}
[HttpGet]
public ExcursionViewModel? GetExcursion(int touristId, int id)
{
try
{
return _logic.ReadElement(new ExcursionSearchModel { TouristId = touristId, Id=id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения экскурсии клиента id={Id}", touristId);
throw;
}
}
[HttpPost]
public void CreateExcursion(ExcursionBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания экскурсий");
throw;
}
}
[HttpPost]
public void UpdateExcursion(ExcursionBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления экскурсии");
throw;
}
}
[HttpPost]
public void DeleteExcursion(ExcursionBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления экскурсии");
throw;
}
}
}

View File

@ -1,79 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using TravelCompanyContracts.BindingModels.OperatorBindingModels;
using TravelCompanyContracts.BindingModels.TouristBindingModels;
using TravelCompanyContracts.BusinessLogicsContracts.OperatorBusinessLogicsContracts;
using TravelCompanyContracts.BusinessLogicsContracts.TouristBusinessLogicsContracts;
using TravelCompanyContracts.SearchModels.OperatorSearchModels;
using TravelCompanyContracts.SearchModels.TouristSearchModels;
using TravelCompanyContracts.ViewModels.OperatorViewModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;
[Route("api/[controller]/[action]")]
[ApiController]
public class OperatorController : Controller
{
private readonly ILogger _logger;
private readonly IOperatorLogic _logic;
public OperatorController(ILogger<OperatorController> logger, IOperatorLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<OperatorViewModel>? GetOperators()
{
try
{
return _logic.ReadList(new OperatorSearchModel { });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка ");
throw;
}
}
[HttpGet]
public OperatorViewModel? GetOperator(int touristId, int id)
{
try
{
return _logic.ReadElement(new OperatorSearchModel { Id=id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения экскурсии клиента id={Id}", touristId);
throw;
}
}
[HttpPost]
public void CreateOperator(OperatorBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания экскурсий");
throw;
}
}
[HttpPost]
public void UpdateOperator(OperatorBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления экскурсии");
throw;
}
}
}

View File

@ -1,74 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using TravelCompanyContracts.BindingModels.TouristBindingModels;
using TravelCompanyContracts.BusinessLogicsContracts.TouristBusinessLogicsContracts;
using TravelCompanyContracts.SearchModels.TouristSearchModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;
[Route("api/[controller]/[action]")]
[ApiController]
public class PlaceController : Controller
{
private readonly ILogger _logger;
private readonly IPlaceLogic _logic;
public PlaceController(ILogger<PlaceController> logger, IPlaceLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<PlaceViewModel>? GetPlaces(int touristId)
{
try
{
return _logic.ReadList(new PlaceSearchModel { TouristId = touristId });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка мест клиента id={Id}", touristId);
throw;
}
}
[HttpPost]
public void CreatePlace(PlaceBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания мест");
throw;
}
}
[HttpPost]
public void UpdatePlace(PlaceBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления мест");
throw;
}
}
[HttpPost]
public void DeletePlace(PlaceBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления мест");
throw;
}
}
}

View File

@ -1,79 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using TravelCompanyContracts.BindingModels.OperatorBindingModels;
using TravelCompanyContracts.BindingModels.TouristBindingModels;
using TravelCompanyContracts.BusinessLogicsContracts.OperatorBusinessLogicsContracts;
using TravelCompanyContracts.BusinessLogicsContracts.TouristBusinessLogicsContracts;
using TravelCompanyContracts.SearchModels.OperatorSearchModels;
using TravelCompanyContracts.SearchModels.TouristSearchModels;
using TravelCompanyContracts.ViewModels.OperatorViewModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;
[Route("api/[controller]/[action]")]
[ApiController]
public class TourController : Controller
{
private readonly ILogger _logger;
private readonly ITourLogic _logic;
public TourController(ILogger<TourController> logger, ITourLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<TourViewModel>? GetTours()
{
try
{
return _logic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка туров");
throw;
}
}
[HttpGet]
public TourViewModel? GetTour(int id)
{
try
{
return _logic.ReadElement(new TourSearchModel { Id=id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения тура");
throw;
}
}
[HttpPost]
public void CreateTour(TourBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания тура");
throw;
}
}
[HttpPost]
public void DeleteTour(TourBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления тура");
throw;
}
}
}

View File

@ -1,67 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using TravelCompanyContracts.BindingModels.TouristBindingModels;
using TravelCompanyContracts.BusinessLogicsContracts.TouristBusinessLogicsContracts;
using TravelCompanyContracts.SearchModels.TouristSearchModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;
[Route("api/[controller]/[action]")]
[ApiController]
public class TouristController : Controller
{
private readonly ILogger _logger;
private readonly ITouristLogic _logic;
public TouristController(ILogger<TouristController> logger, ITouristLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public TouristViewModel? Login(string login, string password)
{
try
{
return _logic.ReadElement(new TouristSearchModel
{
Login = login,
Password = password
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
return null;
}
}
[HttpPost]
public void Register(TouristBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка регистрации");
throw;
}
}
[HttpPost]
public void UpdateData(TouristBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления данных");
throw;
}
}
}

View File

@ -1,74 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using TravelCompanyContracts.BindingModels.TouristBindingModels;
using TravelCompanyContracts.BusinessLogicsContracts.TouristBusinessLogicsContracts;
using TravelCompanyContracts.SearchModels.TouristSearchModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;
[Route("api/[controller]/[action]")]
[ApiController]
public class TravelController : Controller
{
private readonly ILogger _logger;
private readonly ITravelLogic _logic;
public TravelController(ILogger<TravelController> logger, ITravelLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<TravelViewModel>? GetTravels(int touristId)
{
try
{
return _logic.ReadList(new TravelSearchModel { TouristId = touristId });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка путешествий клиента id={Id}", touristId);
throw;
}
}
[HttpPost]
public void CreateTravel(TravelBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания путешествия");
throw;
}
}
[HttpPost]
public void UpdateTravel(TravelBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления путешествия");
throw;
}
}
[HttpPost]
public void DeleteTravel(TravelBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления путешествия");
throw;
}
}
}

View File

@ -40,6 +40,15 @@ namespace TravelCompanyClientApp.Controllers
_reportlogic = reportLogic;
_touristLogic = touristLogic;
}
[HttpGet]
public IActionResult MainPage()
{
if (APIClient.Tourist == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.Tourist);
}
[HttpGet]
public IActionResult Privacy()
@ -86,7 +95,6 @@ namespace TravelCompanyClientApp.Controllers
[HttpGet]
public IActionResult Enter()
{
return View();
}
@ -106,7 +114,7 @@ namespace TravelCompanyClientApp.Controllers
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Privacy");
Response.Redirect("MainPage");
}
[HttpGet]

View File

@ -21,4 +21,11 @@
<ProjectReference Include="..\TravelCompanyDataModels\TravelCompanyDataModels.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="Views\Home\MainPage.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>

View File

@ -0,0 +1,10 @@
@using TravelCompanyContracts.ViewModels.TouristViewModels;
@model TouristViewModel
@{
ViewData["Title"] = "MainPage";
}
<div class="text-center">
<h2 class="display-4">Туристическая фирма "Иван Сусанин"</h2>
</div>

View File

@ -113,69 +113,4 @@
</tbody>
</table>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="~/js/site.js"></script>
}
<script>
$(document).ready(function () {
$('#show-button').click(function () {
var model = {
"DateBefore": document.getElementById("DateBefore").value,
"DateAfter": document.getElementById("DateAfter").value
};
//console.log(model);
var jsonData = JSON.stringify(model);
// Отправка AJAX-запроса на сервер
$.ajax({
url: `/home/ReportPdf`,
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(model),
success: function (data) {
var tableBody = $('#cooks-table tbody');
tableBody.empty();
$.each(data, function (index, lunch) {
var rowLunch = $('<tr></tr>');
var dateCell = $('<td></td>').text(lunch.dateCreate);
rowLunch.append(dateCell);
var lunchIdCell = $('<td></td>').text(lunch.sum);
rowLunch.append(lunchIdCell);
tableBody.append(rowLunch);
$.each(lunch.orders, function (index, order) {
var rowOrder = $('<tr></tr>');
var orderCell = $('<td></td>').text(order.id);
rowOrder.append($('<td></td>').text(""));
rowOrder.append($('<td></td>').text(""));
rowOrder.append(orderCell);
tableBody.append(rowOrder);
$.each(order.orderCooks, function (index, cook) {
var rowCook = $('<tr></tr>');
var cookCell = $('<td></td>').text(cook.fio);
rowCook.append($('<td></td>').text(""));
rowCook.append($('<td></td>').text(""));
rowCook.append($('<td></td>').text(""));
rowCook.append(cookCell);
tableBody.append(rowCook);
});
});
});
},
error: function () {
console.log('Произошла ошибка при получении данных');
}
});
});
});
</script>
}

View File

@ -15,15 +15,9 @@
<div class="col-2">Адрес:</div>
<div class="col-4"><input type="text" name="address" id="address" /></div>
</div>
<div class="row" style="margin-top:20px">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-2">Экскурсия:</div>
</div>
<div class="row">
<div class="col-4">
<select name="excursion" class="form-control" id="excursion">
@foreach (var excursion in ViewBag.Excursions)
@ -33,5 +27,9 @@
</select>
</div>
</div>
<div class="row" style="margin-top:20px">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -12,7 +12,7 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Travel" asp-action="Travel">Турфирма</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="MainPage">Турфирма</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -13,11 +13,8 @@ namespace TravelCompanyContracts.BusinessLogicsContracts
public List<ReportGuideView> GetGuidesByTravels(ReportBindingModel model);
List<ReportTravelsPCView> GetTravelsPCView(ReportBindingModel model);
List<ReportGuidesPCView> GetGuidesPCView(ReportBindingModel model);
// void saveTravelsToPdfFile(ReportBindingModel model);
void saveGuidesToPdfFile(ReportBindingModel model);
void saveGuidesToWord(ReportBindingModel model);
void saveGuidesToExcel(ReportBindingModel model);
// public void saveExcursionsToExcel(ReportBindingModel model);
// public void saveExcursionsToWord(ReportBindingModel model);
}
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TravelCompanyContracts.ViewModels.OperatorViewModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;
namespace TravelCompanyContracts.ViewModels
{
public class ReportExcursionView
{
public List<ExcursionViewModel> Excursions { get; set; }//2
public TourViewModel Tour { get; set; }//5
}
}