This commit is contained in:
parent
bea9a1b241
commit
c0f13a287a
164
TourCompanyBusinessLogic/BusinessLogics/ReportLogic.cs
Normal file
164
TourCompanyBusinessLogic/BusinessLogics/ReportLogic.cs
Normal file
@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TourCompanyBusinessLogic.OfficePackage;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperModels;
|
||||
using TourCompanyContracts.BindingModels;
|
||||
using TourCompanyContracts.BusinessLogicsContracts;
|
||||
using TourCompanyContracts.SearchModels;
|
||||
using TourCompanyContracts.StoragesContracts;
|
||||
using TourCompanyContracts.ViewModels;
|
||||
|
||||
namespace TourCompanyBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
private readonly ITourStorage _tourStorage;
|
||||
private readonly ITourGroupStorage _tourGroupStorage;
|
||||
private readonly IExecurtionStorage _execurtionStorage;
|
||||
private readonly IPlaceVisitStorage _placeVisitStorage;
|
||||
private readonly AbstractSaveToExcelUser _saveToExcelUser;
|
||||
|
||||
private readonly AbstractSaveToWordUser _saveToWordUser;
|
||||
private readonly AbstractSaveToPdfUser _saveToPdfUser;
|
||||
public ReportLogic(ITourStorage tourStorage, ITourGroupStorage tourGroupStorage, IExecurtionStorage execurtionStorage, IPlaceVisitStorage placeVisitStorage, AbstractSaveToExcelUser saveToExcelUser, AbstractSaveToWordUser saveToWordUser, AbstractSaveToPdfUser saveToPdfUser)
|
||||
{
|
||||
|
||||
_tourStorage = tourStorage;
|
||||
_tourGroupStorage = tourGroupStorage;
|
||||
_execurtionStorage = execurtionStorage;
|
||||
_placeVisitStorage = placeVisitStorage;
|
||||
_saveToExcelUser = saveToExcelUser;
|
||||
_saveToWordUser = saveToWordUser;
|
||||
_saveToPdfUser = saveToPdfUser;
|
||||
}
|
||||
|
||||
|
||||
public List<ReportTourPlaceVisitViewModel> GetTourPlaceVisit(ReportBindingModel model)
|
||||
{
|
||||
var tourGroups = _tourGroupStorage.GetFullList();
|
||||
var placeVisits = _placeVisitStorage.GetFullList();
|
||||
var list = new List<ReportTourPlaceVisitViewModel>();
|
||||
foreach (TourViewModel tour in model.Tours)
|
||||
{
|
||||
var record = new ReportTourPlaceVisitViewModel
|
||||
{
|
||||
TourName = tour.TourName
|
||||
};
|
||||
foreach (TourGroupViewModel tourGroup in tourGroups)
|
||||
{
|
||||
if (tourGroup.TourGroupTours.ContainsKey(tour.Id))
|
||||
{
|
||||
foreach (PlaceVisitViewModel placeVisit in placeVisits)
|
||||
{
|
||||
if (placeVisit.TourGroupId == tourGroup.Id)
|
||||
{
|
||||
record.PlaceVisits.Add(placeVisit.PlaceVisitName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportTourViewModel> GetTours(ReportBindingModel model)
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
var tours = _tourStorage.GetFilteredList(new TourSearchModel
|
||||
{
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
var tourGroups = _tourGroupStorage.GetFullList();
|
||||
var execurtions = _execurtionStorage.GetFullList();
|
||||
var list = new List<ReportTourViewModel>();
|
||||
foreach (TourGroupViewModel tourGroup in tourGroups)
|
||||
{
|
||||
|
||||
foreach (ExecurtionViewModel execurtion in execurtions)
|
||||
{
|
||||
|
||||
foreach (int tourTourGroup in tourGroup.TourGroupTours.Keys)
|
||||
{
|
||||
if (execurtion.ExecurtionTours.ContainsKey(tourTourGroup))
|
||||
{
|
||||
try
|
||||
{
|
||||
var tourname = tours.FirstOrDefault(x => x.Id == tourTourGroup)?.TourName ?? string.Empty;
|
||||
if (!tourname.Equals(""))
|
||||
{
|
||||
list.Add(new ReportTourViewModel
|
||||
{
|
||||
TourName = tourname,
|
||||
TourGroupName = tourGroup.TourGroupName,
|
||||
ExecurtionName = execurtion.Purpose,
|
||||
DateTour = tours.FirstOrDefault(x => x.Id == tourTourGroup).DateTour,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
/*
|
||||
public List<ReportTourViewModel>? GetTours(ReportBindingModel model)
|
||||
{
|
||||
return _tourStorage.GetFilteredList(new TourSearchModel
|
||||
{
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
}).Select(x => new ReportTourViewModel
|
||||
{
|
||||
TourName = x.TourName,
|
||||
DateTour = x.DateTour
|
||||
}).ToList();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void SaveTourPlaceVisitToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcelUser.CreateReport(new ExcelInfoUser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список занятий по интресам",
|
||||
TourPlaceVisits = GetTourPlaceVisit(model)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveTourPlaceVisitToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWordUser.CreateDoc(new WordInfoUser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список занятий по интресам",
|
||||
TourPlaceVisits = GetTourPlaceVisit(model)
|
||||
});
|
||||
}
|
||||
public void SaveToursToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdfUser.CreateDoc(new PdfInfoUser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список туров",
|
||||
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
||||
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
||||
Tours = GetTours(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcelUser
|
||||
{
|
||||
/// <summary>
|
||||
/// Создание отчета
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
public void CreateReport(ExcelInfoUser info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
|
||||
MergeCells(new ExcelMergeParameters
|
||||
{
|
||||
CellFromName = "A1",
|
||||
CellToName = "C1"
|
||||
});
|
||||
|
||||
uint rowIndex = 2;
|
||||
foreach (var pc in info.TourPlaceVisits)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.TourName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
|
||||
foreach (var placeVisit in pc.PlaceVisits)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = placeVisit,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание excel-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreateExcel(ExcelInfoUser info);
|
||||
|
||||
/// <summary>
|
||||
/// Добавляем новую ячейку в лист
|
||||
/// </summary>
|
||||
/// <param name="cellParameters"></param>
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
|
||||
/// <summary>
|
||||
/// Объединение ячеек
|
||||
/// </summary>
|
||||
/// <param name="mergeParameters"></param>
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SaveExcel(ExcelInfoUser info);
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdfUser
|
||||
{
|
||||
public void CreateDoc(PdfInfoUser info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
CreateTable(new List<string> { "4cm", "4cm", "4cm", "6cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> {"Тур", "Тур Группа", "Экскурсия", "Дата" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var tour in info.Tours)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { tour.TourName,tour.TourGroupName, tour.ExecurtionName, tour.DateTour.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreatePdf(PdfInfoUser info);
|
||||
|
||||
/// <summary>
|
||||
/// Создание параграфа с текстом
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
|
||||
/// <summary>
|
||||
/// Создание таблицы
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
|
||||
/// <summary>
|
||||
/// Создание и заполнение строки
|
||||
/// </summary>
|
||||
/// <param name="rowParameters"></param>
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SavePdf(PdfInfoUser info);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToWordUser
|
||||
{
|
||||
public void CreateDoc(WordInfoUser info)
|
||||
{
|
||||
CreateWord(info);
|
||||
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var tour in info.TourPlaceVisits)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (tour.TourName, new WordTextProperties { Size = "24", Bold=true,})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
foreach (var placeVisit in tour.PlaceVisits)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (placeVisit, new WordTextProperties { Size = "20", Bold=false,})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreateWord(WordInfoUser info);
|
||||
|
||||
/// <summary>
|
||||
/// Создание абзаца с текстом
|
||||
/// </summary>
|
||||
/// <param name="paragraph"></param>
|
||||
/// <returns></returns>
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SaveWord(WordInfoUser info);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
Title,
|
||||
|
||||
Text,
|
||||
|
||||
TextWithBroder
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
|
||||
Left,
|
||||
|
||||
Rigth
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum WordJustificationType
|
||||
{
|
||||
Center,
|
||||
|
||||
Both
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelCellParameters
|
||||
{
|
||||
public string ColumnName { get; set; } = string.Empty;
|
||||
|
||||
public uint RowIndex { get; set; }
|
||||
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||
|
||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
|
||||
using TourCompanyContracts.ViewModels;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfoUser
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportTourPlaceVisitViewModel> TourPlaceVisits { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelMergeParameters
|
||||
{
|
||||
public string CellFromName { get; set; } = string.Empty;
|
||||
|
||||
public string CellToName { get; set; } = string.Empty;
|
||||
|
||||
public string Merge => $"{CellFromName}:{CellToName}";
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using TourCompanyContracts.ViewModels;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfoUser
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateFrom { get; set; }
|
||||
|
||||
public DateTime DateTo { get; set; }
|
||||
|
||||
public List<ReportTourViewModel> Tours { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfParagraph
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
public string Style { get; set; } = string.Empty;
|
||||
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
|
||||
public string Style { get; set; } = string.Empty;
|
||||
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using TourCompanyContracts.ViewModels;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfoUser
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportTourPlaceVisitViewModel> TourPlaceVisits { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordParagraph
|
||||
{
|
||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||
|
||||
public WordTextProperties? TextProperties { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTextProperties
|
||||
{
|
||||
public string Size { get; set; } = string.Empty;
|
||||
|
||||
public bool Bold { get; set; }
|
||||
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,291 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToExcelUser : AbstractSaveToExcelUser
|
||||
{
|
||||
private SpreadsheetDocument? _spreadsheetDocument;
|
||||
|
||||
private SharedStringTablePart? _shareStringPart;
|
||||
|
||||
private Worksheet? _worksheet;
|
||||
|
||||
/// <summary>
|
||||
/// Настройка стилей для файла
|
||||
/// </summary>
|
||||
/// <param name="workbookpart"></param>
|
||||
private static void CreateStyles(WorkbookPart workbookpart)
|
||||
{
|
||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||
sp.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||
|
||||
var fontUsual = new Font();
|
||||
fontUsual.Append(new FontSize() { Val = 12D });
|
||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
var fontTitle = new Font();
|
||||
fontTitle.Append(new Bold());
|
||||
fontTitle.Append(new FontSize() { Val = 14D });
|
||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
fonts.Append(fontUsual);
|
||||
fonts.Append(fontTitle);
|
||||
|
||||
var fills = new Fills() { Count = 2U };
|
||||
|
||||
var fill1 = new Fill();
|
||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
|
||||
var fill2 = new Fill();
|
||||
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||
|
||||
fills.Append(fill1);
|
||||
fills.Append(fill2);
|
||||
|
||||
var borders = new Borders() { Count = 2U };
|
||||
|
||||
var borderNoBorder = new Border();
|
||||
borderNoBorder.Append(new LeftBorder());
|
||||
borderNoBorder.Append(new RightBorder());
|
||||
borderNoBorder.Append(new TopBorder());
|
||||
borderNoBorder.Append(new BottomBorder());
|
||||
borderNoBorder.Append(new DiagonalBorder());
|
||||
|
||||
var borderThin = new Border();
|
||||
|
||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
borderThin.Append(leftBorder);
|
||||
borderThin.Append(rightBorder);
|
||||
borderThin.Append(topBorder);
|
||||
borderThin.Append(bottomBorder);
|
||||
borderThin.Append(new DiagonalBorder());
|
||||
|
||||
borders.Append(borderNoBorder);
|
||||
borders.Append(borderThin);
|
||||
|
||||
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
||||
var cellFormatStyle = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U };
|
||||
|
||||
cellStyleFormats.Append(cellFormatStyle);
|
||||
|
||||
var cellFormats = new CellFormats() { Count = 3U };
|
||||
var cellFormatFont = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true };
|
||||
var cellFormatFontAndBorder = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 1U, FormatId = 0U, ApplyFont = true, ApplyBorder = true };
|
||||
var cellFormatTitle = new CellFormat() { NumberFormatId = 0U, FontId = 1U, FillId = 0U, BorderId = 0U, FormatId = 0U, Alignment = new Alignment() { Vertical = VerticalAlignmentValues.Center, WrapText = true, Horizontal = HorizontalAlignmentValues.Center }, ApplyFont = true };
|
||||
|
||||
cellFormats.Append(cellFormatFont);
|
||||
cellFormats.Append(cellFormatFontAndBorder);
|
||||
cellFormats.Append(cellFormatTitle);
|
||||
|
||||
var cellStyles = new CellStyles() { Count = 1U };
|
||||
|
||||
cellStyles.Append(new CellStyle() { Name = "Normal", FormatId = 0U, BuiltinId = 0U });
|
||||
|
||||
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() { Count = 0U };
|
||||
|
||||
var tableStyles = new TableStyles() { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" };
|
||||
|
||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||
|
||||
var stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" };
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" });
|
||||
|
||||
var stylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" };
|
||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
stylesheetExtension2.Append(new TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" });
|
||||
|
||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||
|
||||
sp.Stylesheet.Append(fonts);
|
||||
sp.Stylesheet.Append(fills);
|
||||
sp.Stylesheet.Append(borders);
|
||||
sp.Stylesheet.Append(cellStyleFormats);
|
||||
sp.Stylesheet.Append(cellFormats);
|
||||
sp.Stylesheet.Append(cellStyles);
|
||||
sp.Stylesheet.Append(differentialFormats);
|
||||
sp.Stylesheet.Append(tableStyles);
|
||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение номера стиля из типа
|
||||
/// </summary>
|
||||
/// <param name="styleInfo"></param>
|
||||
/// <returns></returns>
|
||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||
{
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void CreateExcel(ExcelInfoUser info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook();
|
||||
|
||||
CreateStyles(workbookpart);
|
||||
|
||||
|
||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
||||
? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||
: _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
|
||||
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
|
||||
|
||||
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
|
||||
_worksheet = worksheetPart.Worksheet;
|
||||
}
|
||||
|
||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null || _shareStringPart == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||
if (sheetData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Row row;
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||
{
|
||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||
sheetData.Append(row);
|
||||
}
|
||||
|
||||
|
||||
Cell cell;
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Cell? refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
||||
{
|
||||
refCell = rowCell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var newCell = new Cell() { CellReference = excelParams.CellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
|
||||
cell = newCell;
|
||||
}
|
||||
|
||||
|
||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||
_shareStringPart.SharedStringTable.Save();
|
||||
|
||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||
}
|
||||
|
||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells mergeCells;
|
||||
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
|
||||
var mergeCell = new MergeCell()
|
||||
{
|
||||
Reference = new StringValue(excelParams.Merge)
|
||||
};
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
|
||||
protected override void SaveExcel(ExcelInfoUser info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||
_spreadsheetDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using TourCompanyBusinessLogic.OfficePackage;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdfUser : AbstractSaveToPdfUser
|
||||
{
|
||||
private Document? _document;
|
||||
|
||||
private Section? _section;
|
||||
|
||||
private Table? _table;
|
||||
|
||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
|
||||
protected override void CreatePdf(PdfInfoUser info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
|
||||
Unit borderWidth = 0.5;
|
||||
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SavePdf(PdfInfoUser info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperEnums;
|
||||
using TourCompanyBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace TourCompanyBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWordUser : AbstractSaveToWordUser
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
|
||||
private Body? _docBody;
|
||||
|
||||
/// <summary>
|
||||
/// Получение типа выравнивания
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center,
|
||||
_ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Настройки страницы
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var properties = new SectionProperties();
|
||||
|
||||
var pageSize = new PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
|
||||
properties.AppendChild(pageSize);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Задание форматирования для абзаца
|
||||
/// </summary>
|
||||
/// <param name="paragraphProperties"></param>
|
||||
/// <returns></returns>
|
||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var properties = new ParagraphProperties();
|
||||
|
||||
properties.AppendChild(new Justification()
|
||||
{
|
||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||
});
|
||||
|
||||
properties.AppendChild(new SpacingBetweenLines
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
|
||||
properties.AppendChild(new Indentation());
|
||||
|
||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
||||
}
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
protected override void CreateWord(WordInfoUser info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
protected override void CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (_docBody == null || paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
var docRun = new Run();
|
||||
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
if (run.Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
|
||||
_docBody.AppendChild(docParagraph);
|
||||
}
|
||||
|
||||
protected override void SaveWord(WordInfoUser info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
|
||||
_wordDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,17 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc" Version="1.50.5147" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TourCompanyContracts\TourCompanyContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="OfficePackage\HelperEnums\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Diagnostics;
|
||||
using TourCompanyClientApp.Models;
|
||||
using TourCompanyContracts.BindingModels;
|
||||
@ -26,7 +28,9 @@ namespace TourCompanyClientApp.Controllers
|
||||
private readonly IGidLogic _gid;
|
||||
private readonly ITripLogic _trip;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger , IExecurtionLogic execurtion, ITourLogic tour, IUserLogic user, ITourGroupLogic tourGroup, IPlaceVisitLogic placeVisitLogic, IGidLogic gid, ITripLogic trip)
|
||||
private readonly IReportLogic _report;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger , IExecurtionLogic execurtion, ITourLogic tour, IUserLogic user, ITourGroupLogic tourGroup, IPlaceVisitLogic placeVisitLogic, IGidLogic gid, ITripLogic trip, IReportLogic report)
|
||||
{
|
||||
_logger = logger;
|
||||
_execurtion = execurtion;
|
||||
@ -36,6 +40,7 @@ namespace TourCompanyClientApp.Controllers
|
||||
_placeVisitLogic = placeVisitLogic;
|
||||
_gid = gid;
|
||||
_trip = trip;
|
||||
_report = report;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -135,6 +140,10 @@ namespace TourCompanyClientApp.Controllers
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
/// <summary>
|
||||
/// tour
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult CreateTour()
|
||||
{
|
||||
@ -156,6 +165,44 @@ namespace TourCompanyClientApp.Controllers
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult TourSetting(int id)
|
||||
{
|
||||
return View(_tour.ReadElement(new TourSearchModel { Id = id }));
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateTour(int id, string tourName, DateTime tourDate)
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(tourName))
|
||||
{
|
||||
throw new Exception("Нет названия");
|
||||
}
|
||||
_tour.Update(new TourBindingModel
|
||||
{
|
||||
Id = id,
|
||||
TourName = tourName,
|
||||
DateTour = tourDate,
|
||||
UserId = APIClient.User.Id,
|
||||
|
||||
});
|
||||
Response.Redirect("/Home/Tour");
|
||||
}
|
||||
|
||||
public void DeleteTour(int id)
|
||||
{
|
||||
|
||||
_tour.Delete(new TourBindingModel
|
||||
{
|
||||
Id = id,
|
||||
});
|
||||
Response.Redirect("/Home/Tour");
|
||||
}
|
||||
/// <summary>
|
||||
/// execurtions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Execurtion()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
@ -189,12 +236,70 @@ namespace TourCompanyClientApp.Controllers
|
||||
Purpose = purpose,
|
||||
DateExecurtion = dateExecurtion,
|
||||
ExecurtionDuratation = execurtionDuratation,
|
||||
UserId = APIClient.User.Id,
|
||||
ExecurtionTours = execurtionTours
|
||||
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ExecurtionSetting(int id)
|
||||
{
|
||||
var execurtion = _execurtion.ReadElement(new ExecurtionSearchModel { Id = id });
|
||||
var tours = _tour.ReadList(new TourSearchModel { UserId = APIClient.User.Id }).Select(x => new { TourId = x.Id, TourName = x.TourName }).ToList();
|
||||
var selectedTours = execurtion.ExecurtionTours.Select(x => x.Key).ToArray();
|
||||
ViewBag.Tours = new MultiSelectList(tours, "TourId", "TourName", selectedTours);
|
||||
return View(execurtion);
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateExecurtion(int idExecurtion, string purpose, int execurtionDuratation, DateTime dateExecurtion, int[] tours)
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(purpose))
|
||||
{
|
||||
throw new Exception("Нет названия");
|
||||
}
|
||||
if (execurtionDuratation == null)
|
||||
{
|
||||
throw new Exception("Нет длительности экскурсии");
|
||||
}
|
||||
if (dateExecurtion == null)
|
||||
{
|
||||
throw new Exception("Нет даты");
|
||||
}
|
||||
|
||||
Dictionary<int, ITourModel> execurtionTours = new Dictionary<int, ITourModel>();
|
||||
foreach (int id in tours)
|
||||
{
|
||||
execurtionTours.Add(id, _tour.ReadElement(new TourSearchModel { Id = id }));
|
||||
}
|
||||
_execurtion.Update(new ExecurtionBindingModel
|
||||
{
|
||||
Id = idExecurtion,
|
||||
Purpose = purpose,
|
||||
ExecurtionDuratation = execurtionDuratation,
|
||||
DateExecurtion = dateExecurtion,
|
||||
ExecurtionTours = execurtionTours
|
||||
|
||||
});
|
||||
Response.Redirect("/Home/Execurtion");
|
||||
}
|
||||
|
||||
public void DeleteExecurtion(int id)
|
||||
{
|
||||
|
||||
_execurtion.Delete(new ExecurtionBindingModel
|
||||
{
|
||||
Id = id,
|
||||
});
|
||||
Response.Redirect("/Home/Execurtion");
|
||||
}
|
||||
/// <summary>
|
||||
/// Tour Group
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult TourGroup()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
@ -212,7 +317,7 @@ namespace TourCompanyClientApp.Controllers
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateTourGroup(string tourGroupName, int typekey, int[] tours)
|
||||
public void CreateTourGroup(string tourGroupName, int type, int[] tours)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
@ -223,25 +328,69 @@ namespace TourCompanyClientApp.Controllers
|
||||
{
|
||||
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,
|
||||
Type = (TourType)type,
|
||||
UserId = APIClient.User.Id,
|
||||
TourGroupTours = tourGroupTours
|
||||
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult TourGroupSetting(int id)
|
||||
{
|
||||
var tourGroup = _tourGroup.ReadElement(new TourGroupSearchModel { Id = id });
|
||||
var tours = _tour.ReadList(new TourSearchModel { UserId = APIClient.User.Id }).Select(x => new { TourId = x.Id, TourName = x.TourName }).ToList();
|
||||
var selectedTours = tourGroup.TourGroupTours.Select(x => x.Key).ToArray();
|
||||
ViewBag.Tours = new MultiSelectList(tours, "TourId", "TourName", selectedTours);
|
||||
return View(tourGroup);
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateTourGroup(int idTourGroup, string tourGroupName, int type, int[] tours)
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(tourGroupName))
|
||||
{
|
||||
throw new Exception("Нет названия");
|
||||
}
|
||||
if (type == null)
|
||||
{
|
||||
throw new Exception("Нет типа");
|
||||
}
|
||||
|
||||
Dictionary<int, ITourModel> tourGroupTours = new Dictionary<int, ITourModel>();
|
||||
foreach (int id in tours)
|
||||
{
|
||||
tourGroupTours.Add(id, _tour.ReadElement(new TourSearchModel { Id = id }));
|
||||
}
|
||||
_tourGroup.Update(new TourGroupBindingModel
|
||||
{
|
||||
Id = idTourGroup,
|
||||
TourGroupName = tourGroupName,
|
||||
Type = (TourType)type,
|
||||
TourGroupTours = tourGroupTours
|
||||
|
||||
});
|
||||
Response.Redirect("/Home/TourGroup");
|
||||
}
|
||||
|
||||
public void DeleteTourGroup(int id)
|
||||
{
|
||||
|
||||
_tourGroup.Delete(new TourGroupBindingModel
|
||||
{
|
||||
Id = id,
|
||||
});
|
||||
Response.Redirect("/Home/TourGroup");
|
||||
}
|
||||
/// <summary>
|
||||
/// Place Visit
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult PlaceVisit()
|
||||
{
|
||||
|
||||
@ -280,6 +429,7 @@ namespace TourCompanyClientApp.Controllers
|
||||
DatePlaceVisit = datePlaceVisit,
|
||||
TourGroupId = tourGroup,
|
||||
TourGroupName = prod.TourGroupName,
|
||||
UserId = APIClient.User.Id,
|
||||
PlaceVisitTrips = placeVisitTrips
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
@ -323,6 +473,7 @@ namespace TourCompanyClientApp.Controllers
|
||||
{
|
||||
Experion = experion,
|
||||
GidFIO = GidFio,
|
||||
UserId = APIClient.User.Id,
|
||||
GidExecurtions = gidExecurtions
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
@ -361,9 +512,68 @@ namespace TourCompanyClientApp.Controllers
|
||||
TripName = tripName,
|
||||
DateTrip = dateTrip,
|
||||
GidId = gid,
|
||||
UserId = APIClient.User.Id,
|
||||
GidFIO = prod.GidFIO
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
///
|
||||
/// Отчёты
|
||||
///
|
||||
|
||||
public IActionResult Report()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
public IActionResult GetPartial(int[] tours, string mode)
|
||||
{
|
||||
var list = tours.Select(x => _tour.ReadElement(new TourSearchModel { Id = x })).ToList();
|
||||
if (mode.Equals("Excel"))
|
||||
{
|
||||
_report.SaveTourPlaceVisitToExcelFile
|
||||
(new ReportBindingModel { FileName = $"C:\\Reports\\{APIClient.User.Email}-{DateTime.Now.ToString("dd/MM/yyyy")}.xlsx", Tours = list, UserId = APIClient.User.Id });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_report.SaveTourPlaceVisitToWordFile
|
||||
(new ReportBindingModel { FileName = $"C:\\Reports\\{APIClient.User.Email}-{DateTime.Now.ToString("dd/MM/yyyy")}.docx", Tours = list, UserId = APIClient.User.Id });
|
||||
|
||||
}
|
||||
var items = _report.GetTourPlaceVisit(new ReportBindingModel { Tours = list, UserId = APIClient.User.Id });
|
||||
return PartialView("PlaceVisitPartial", items);
|
||||
}
|
||||
public IActionResult ReportPdf()
|
||||
{
|
||||
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();
|
||||
}
|
||||
public IActionResult GetPartialForPDF(int[] tours, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
var _dateFrom = dateFrom;
|
||||
var _dateTo = dateTo;
|
||||
if (_dateFrom > _dateTo)
|
||||
{
|
||||
throw new Exception("Не верные даты");
|
||||
}
|
||||
string path = $"C:\\Reports\\{APIClient.User.UserFIO} от {_dateFrom.ToString("dd/MM/yyyy")}.pdf";
|
||||
_report.SaveToursToPdfFile
|
||||
(new ReportBindingModel
|
||||
{
|
||||
FileName = path,
|
||||
DateFrom = _dateFrom,
|
||||
DateTo = _dateTo,
|
||||
UserId = APIClient.User.Id
|
||||
});
|
||||
|
||||
var items = _report.GetTours(new ReportBindingModel { DateFrom = _dateFrom, DateTo = _dateTo, UserId = APIClient.User.Id });
|
||||
return PartialView("TourPartial", items);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using TourCompanyBusinessLogic.BusinessLogics;
|
||||
using TourCompanyBusinessLogic.OfficePackage;
|
||||
using TourCompanyBusinessLogic.OfficePackage.Implements;
|
||||
using TourCompanyClientApp;
|
||||
using TourCompanyContracts.BusinessLogicsContracts;
|
||||
using TourCompanyContracts.StoragesContracts;
|
||||
@ -14,6 +16,7 @@ builder.Services.AddTransient<ITourGroupStorage, TourGroupStorage>();
|
||||
builder.Services.AddTransient<IPlaceVisitStorage, PlaceVisitStorage>();
|
||||
builder.Services.AddTransient<IGidStorage, GidStorage>();
|
||||
builder.Services.AddTransient<ITripStorage, TripStorage>();
|
||||
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
builder.Services.AddTransient<ITourLogic, TourLogic>();
|
||||
builder.Services.AddTransient<IExecurtionLogic, ExecurtionLogic>();
|
||||
@ -21,6 +24,11 @@ builder.Services.AddTransient<ITourGroupLogic, TourGroupLogic>();
|
||||
builder.Services.AddTransient<IPlaceVisitLogic, PlaceVisitLogic>();
|
||||
builder.Services.AddTransient<IGidLogic, GidLogic>();
|
||||
builder.Services.AddTransient<ITripLogic,TripLogic>();
|
||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToExcelUser, SaveToExcelUser>();
|
||||
builder.Services.AddTransient<AbstractSaveToWordUser, SaveToWordUser>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfUser, SaveToPdfUser>();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
@ -12,11 +12,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Место посещения:</div>
|
||||
<div class="col-4">Название Поездки:</div>
|
||||
<div class="col-8"><input type="text" name="tripName" id="tripName" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата посещения:</div>
|
||||
<div class="col-4">Дата поездки:</div>
|
||||
<div class="col-8"><input type="datetime-local" id="dateTrip" name="dateTrip" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -40,6 +40,9 @@
|
||||
<th>
|
||||
Туры
|
||||
</th>
|
||||
<th>
|
||||
Действие
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -61,6 +64,10 @@
|
||||
<td>
|
||||
<select asp-items="@(new SelectList(item.ExecurtionTours,"Key", "Value.TourName"))"></select>
|
||||
</td>
|
||||
<td>
|
||||
<a href="@Url.Action("ExecurtionSetting","Home", new {id=item.Id })"
|
||||
class="btn btn-primary btn-lg">Update/Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
36
TourCompanyClientApp/Views/Home/ExecurtionSetting.cshtml
Normal file
36
TourCompanyClientApp/Views/Home/ExecurtionSetting.cshtml
Normal file
@ -0,0 +1,36 @@
|
||||
@using TourCompanyContracts.ViewModels;
|
||||
|
||||
@model ExecurtionViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Setting";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@Model.Purpose</h2>
|
||||
</div>
|
||||
<form method="post" action="@Url.Action("UpdateExecurtion", "Home", new{idExecurtion=Model.Id, purpose="#purpose",execurtionDuratation="#execurtionDuratation", dateExecurtion="#dateExecurtion", tours="#tours"})">
|
||||
<div class="row m-3">
|
||||
<div class="col-8">
|
||||
<input type="submit" value="Обновить" class="col-md-4 btn btn-primary" />
|
||||
<input type="button" class="col-md-4 ms-auto btn btn-danger" value="Удалить" onclick="location.href='@Url.Action("DeleteExecurtion","Home", new {id=Model.Id })'" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-3">
|
||||
<div class="col-4">Цель экскурсии:</div>
|
||||
<div class="col-8"><input type="text" name="purpose" id="purpose" value="@Model.Purpose" /></div>
|
||||
</div>
|
||||
<div class="row m-3">
|
||||
<div class="col-4">Даты экскурсии:</div>
|
||||
<div class="col-8"><input type="datetime-local" name="dateExecurtion" id="dateExecurtion" value="@Model.DateExecurtion" /></div>
|
||||
</div>
|
||||
<div class="row m-3">
|
||||
<div class="col-4">Длительность экскурсии:</div>
|
||||
<div class="col-8"><input type="number" id="execurtionDuratation" name="execurtionDuratation">@Model.ExecurtionDuratation/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Туры:</div>
|
||||
<div class="col-8">
|
||||
@Html.ListBox("tours", (MultiSelectList)ViewBag.Tours)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
@ -29,16 +29,13 @@
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Цель экскурсии
|
||||
Опыт
|
||||
</th>
|
||||
<th>
|
||||
Дата экскурсии
|
||||
ФИО
|
||||
</th>
|
||||
<th>
|
||||
длительность экскурсии
|
||||
</th>
|
||||
<th>
|
||||
Туры
|
||||
Экскурсии
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
23
TourCompanyClientApp/Views/Home/Report.cshtml
Normal file
23
TourCompanyClientApp/Views/Home/Report.cshtml
Normal file
@ -0,0 +1,23 @@
|
||||
@{
|
||||
ViewData["Title"] = "Report";
|
||||
}
|
||||
<form id="my_form" asp-action="Reports" method="get" data-ajax="true" data-ajax-method="get" data-ajax-update="#panel" data-ajax-mode='replace' data-ajax-url="@Url.Action("GetPartial","Home")">
|
||||
<select id="mode" name="mode">
|
||||
<option>Excel</option>
|
||||
<option>Word</option>
|
||||
</select>
|
||||
<div class="row">
|
||||
<div class="col-4">туры:</div>
|
||||
<div class="col-8">
|
||||
@Html.ListBox("tours", (MultiSelectList)ViewBag.Tours)
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="row pr-3 pl-3" id="panel">
|
||||
@section scripts{
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>
|
||||
}
|
28
TourCompanyClientApp/Views/Home/ReportPdf.cshtml
Normal file
28
TourCompanyClientApp/Views/Home/ReportPdf.cshtml
Normal file
@ -0,0 +1,28 @@
|
||||
@{
|
||||
ViewData["Title"] = "ReportPdf";
|
||||
}
|
||||
<form id="my_form" asp-action="SendingEmail" method="get" data-ajax="true" data-ajax-method="get" data-ajax-update="#panel" data-ajax-mode='replace' data-ajax-url="@Url.Action("GetPartialForPDF","Home")">
|
||||
div class="row">
|
||||
<div class="col-4">От:</div>
|
||||
<div class="col-8"><input type="datetime-local" name="dateFrom" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">До:</div>
|
||||
<div class="col-8"><input type="datetime-local" name="dateTo" /></div>
|
||||
</div>
|
||||
</select>
|
||||
<div class="row">
|
||||
<div class="col-4">туры:</div>
|
||||
<div class="col-8">
|
||||
@Html.ListBox("tours", (MultiSelectList)ViewBag.Tours)
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="row pr-3 pl-3" id="panel">
|
||||
@section scripts{
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>
|
||||
}
|
@ -34,6 +34,9 @@
|
||||
<th>
|
||||
Дата Тура
|
||||
</th>
|
||||
<th>
|
||||
Действие над выбранным туром
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -49,6 +52,11 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateTour)
|
||||
</td>
|
||||
<td>
|
||||
<a href="@Url.Action("TourSetting","Home", new {id=item.Id })"
|
||||
class="btn btn-primary btn-lg">Update/Delete</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
@ -37,6 +37,9 @@
|
||||
<th>
|
||||
Туры
|
||||
</th>
|
||||
<th>
|
||||
действие над тур группой
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -55,6 +58,10 @@
|
||||
<td>
|
||||
<select asp-items="@(new SelectList(item.TourGroupTours,"Key", "Value.TourName"))"></select>
|
||||
</td>
|
||||
<td>
|
||||
<a href="@Url.Action("TourGroupSetting","Home", new {id=item.Id })"
|
||||
class="btn btn-primary btn-lg">Update/Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
32
TourCompanyClientApp/Views/Home/TourGroupSetting.cshtml
Normal file
32
TourCompanyClientApp/Views/Home/TourGroupSetting.cshtml
Normal file
@ -0,0 +1,32 @@
|
||||
@using TourCompanyContracts.ViewModels;
|
||||
|
||||
@model TourGroupViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Setting";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@Model.TourGroupName</h2>
|
||||
</div>
|
||||
<form method="post" action="@Url.Action("UpdateTourGroup", "Home", new{idTourGroup=Model.Id,tourGroupName="#tourGroupName",type="#type", tours="#tours"})">
|
||||
<div class="row m-3">
|
||||
<div class="col-8">
|
||||
<input type="submit" value="Обновить" class="col-md-4 btn btn-primary" />
|
||||
<input type="button" class="col-md-4 ms-auto btn btn-danger" value="Удалить" onclick="location.href='@Url.Action("DeleteTourGroup","Home", new {id=Model.Id })'" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-3">
|
||||
<div class="col-4">Название тур группы:</div>
|
||||
<div class="col-8"><input type="text" name="tourGroupName" id="tourGroupName" value="@Model.TourGroupName" /></div>
|
||||
</div>
|
||||
<div class="row m-3">
|
||||
<div class="col-4">Тип группы:</div>
|
||||
<div class="col-8"><input type="number" min="0" max="1" id="type" name="type" rows="5">@Model.Type/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Туры:</div>
|
||||
<div class="col-8">
|
||||
@Html.ListBox("tours", (MultiSelectList)ViewBag.Tours)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
48
TourCompanyClientApp/Views/Home/TourPartial.cshtml
Normal file
48
TourCompanyClientApp/Views/Home/TourPartial.cshtml
Normal file
@ -0,0 +1,48 @@
|
||||
@using TourCompanyContracts.ViewModels;
|
||||
@model List<ReportTourViewModel>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
тур
|
||||
</th>
|
||||
<th>
|
||||
тур группа
|
||||
</th>
|
||||
|
||||
<th>
|
||||
экскурсия
|
||||
</th>
|
||||
<th>
|
||||
Дата создания экс
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TourName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TourGroupName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ExecurtionName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateTour)
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
24
TourCompanyClientApp/Views/Home/TourSetting.cshtml
Normal file
24
TourCompanyClientApp/Views/Home/TourSetting.cshtml
Normal file
@ -0,0 +1,24 @@
|
||||
@using TourCompanyContracts.ViewModels
|
||||
@model TourViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Setting";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@Model.TourName</h2>
|
||||
</div>
|
||||
<form method="post" action="@Url.Action("UpdateTour", "Home", new{id=Model.Id,tourName="#tourName",tourDate="#tourDate"})">
|
||||
<div class="row m-3">
|
||||
<div class="col-8">
|
||||
<input type="submit" value="Обновить" class="col-md-4 btn btn-primary" />
|
||||
<input type="button" class="col-md-4 ms-auto btn btn-danger" value="Удалить" onclick="location.href='@Url.Action("DeleteTour","Home", new {id=Model.Id })'" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-3">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="tourName" id="tourName" value="@Model.TourName" /></div>
|
||||
</div>
|
||||
<div class="row m-3">
|
||||
<div class="col-4">Дата Тура:</div>
|
||||
<div class="col-8"><input type="datetime-local" id="tourDate" name="tourDate" value="@Model.DateTour" /></div>
|
||||
</div>
|
||||
</form>
|
@ -34,6 +34,9 @@
|
||||
<th>
|
||||
Дата Поездки
|
||||
</th>
|
||||
<th>
|
||||
Гид
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -35,13 +35,19 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="TourGroup">ТурГруппа</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PlaceVisit">PlaceVisit</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Gid">Gid</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчеты Word Excel</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Trip">Trip</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportPdf">Отчеты Pdf</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PlaceVisit">Места посещения</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Gid">Гиды</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Trip">Поездки</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
|
@ -15,7 +15,7 @@ namespace TourCompanyContracts.BindingModels
|
||||
|
||||
public DateTime DateExecurtion { get; set; }
|
||||
public int ExecurtionDuratation { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public Dictionary<int, ITourModel> ExecurtionTours { get; set; } = new();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace TourCompanyContracts.BindingModels
|
||||
public string GidFIO { get; set; } = string.Empty;
|
||||
|
||||
public int Experion { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, IExecurtionModel> GidExecurtions { get; set; } = new();
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ namespace TourCompanyContracts.BindingModels
|
||||
public int TourGroupId { get; set; }
|
||||
|
||||
public string TourGroupName { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, ITripModel> PlaceVisitTrips { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
24
TourCompanyContracts/BindingModels/ReportBindingModel.cs
Normal file
24
TourCompanyContracts/BindingModels/ReportBindingModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TourCompanyContracts.ViewModels;
|
||||
|
||||
namespace TourCompanyContracts.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public List<TripViewModel>? Trips { get; set; }
|
||||
|
||||
public List<TourViewModel>? Tours { get; set; }
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
@ -15,7 +15,8 @@ namespace TourCompanyContracts.BindingModels
|
||||
public string TourGroupName { get; set; } = string.Empty;
|
||||
|
||||
public TourType Type { get; set; }
|
||||
public int UserId { get; set; }
|
||||
|
||||
public Dictionary<int, ITourModel> TourGroupTours { get; set; } = new();
|
||||
public Dictionary<int, ITourModel> TourGroupTours { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace TourCompanyContracts.BindingModels
|
||||
|
||||
public DateTime DateTrip { get; set; }
|
||||
public int GidId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string GidFIO { get; set; }
|
||||
|
||||
}
|
||||
|
27
TourCompanyContracts/BusinessLogicsContracts/IReportLogic.cs
Normal file
27
TourCompanyContracts/BusinessLogicsContracts/IReportLogic.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using TourCompanyContracts.BindingModels;
|
||||
using TourCompanyContracts.ViewModels;
|
||||
|
||||
namespace TourCompanyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
List<ReportTourPlaceVisitViewModel> GetTourPlaceVisit(ReportBindingModel model);
|
||||
|
||||
|
||||
List<ReportTourViewModel> GetTours(ReportBindingModel model);
|
||||
|
||||
|
||||
|
||||
void SaveTourPlaceVisitToWordFile(ReportBindingModel model);
|
||||
|
||||
|
||||
void SaveTourPlaceVisitToExcelFile(ReportBindingModel model);
|
||||
void SaveToursToPdfFile(ReportBindingModel model);
|
||||
|
||||
}
|
||||
}
|
@ -11,7 +11,10 @@ namespace TourCompanyContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? Purpose { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public string? TourName { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public DateTime? DateExecurtion { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ namespace TourCompanyContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? GidFIO { get; set; }
|
||||
}
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ namespace TourCompanyContracts.SearchModels
|
||||
|
||||
public int? TourGroupId { get; set; }
|
||||
public string? PlaceVisitName { get; set; }
|
||||
}
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,5 +10,9 @@ namespace TourCompanyContracts.SearchModels
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? TourGroupName { get; set; }
|
||||
}
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ namespace TourCompanyContracts.SearchModels
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? GidId { get; set; }
|
||||
}
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace TourCompanyContracts.ViewModels
|
||||
|
||||
public DateTime DateExecurtion { get; set; }
|
||||
public int ExecurtionDuratation { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, ITourModel> ExecurtionTours { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace TourCompanyContracts.ViewModels
|
||||
public string GidFIO { get; set; } = string.Empty;
|
||||
|
||||
public int Experion { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, IExecurtionModel> GidExecurtions { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ namespace TourCompanyContracts.ViewModels
|
||||
public int TourGroupId { get; set; }
|
||||
|
||||
public string TourGroupName { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, ITripModel> PlaceVisitTrips { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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 ReportTourPlaceVisitViewModel
|
||||
{
|
||||
public string TourName { get; set; } = string.Empty;
|
||||
public List<string> PlaceVisits { get; set; } = new();
|
||||
}
|
||||
}
|
18
TourCompanyContracts/ViewModels/ReportTourViewModel.cs
Normal file
18
TourCompanyContracts/ViewModels/ReportTourViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TourCompanyContracts.ViewModels
|
||||
{
|
||||
public class ReportTourViewModel
|
||||
{
|
||||
//public int /*OperationId*/ TourGroupId { get; set; }
|
||||
|
||||
public string TourName { get; set; } = string.Empty;
|
||||
public string TourGroupName { get; set; } = string.Empty;
|
||||
public string ExecurtionName { get; set; } = string.Empty;
|
||||
public DateTime? DateTour { get; set; }
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ namespace TourCompanyContracts.ViewModels
|
||||
public string TourGroupName { get; set; } = string.Empty;
|
||||
|
||||
public TourType Type { get; set; }
|
||||
public Dictionary<int, ITourModel> TourGroupTours { get; set; } = new();
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, ITourModel> TourGroupTours { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -16,5 +16,6 @@ namespace TourCompanyContracts.ViewModels
|
||||
public DateTime DateTrip { get; set; }
|
||||
public int GidId { get; set; }
|
||||
public string GidFIO { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace TourCompanyDataModels.Models
|
||||
|
||||
public DateTime DateExecurtion { get; }
|
||||
public int ExecurtionDuratation { get; }
|
||||
public int UserId { get; }
|
||||
public Dictionary<int, ITourModel> ExecurtionTours { get; }
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ namespace TourCompanyDataModels.Models
|
||||
public string GidFIO { get;}
|
||||
|
||||
public int Experion { get;}
|
||||
public int UserId { get; }
|
||||
|
||||
public Dictionary<int, IExecurtionModel> GidExecurtions { get; }
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace TourCompanyDataModels.Models
|
||||
public int TourGroupId { get; }
|
||||
|
||||
public string TourGroupName { get; }
|
||||
public int UserId { get;}
|
||||
public Dictionary<int, ITripModel> PlaceVisitTrips { get; }
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ namespace TourCompanyDataModels.Models
|
||||
public string TourGroupName { get; }
|
||||
|
||||
public TourType Type { get; }
|
||||
public int UserId { get; }
|
||||
|
||||
public Dictionary<int, ITourModel> TourGroupTours { get; }
|
||||
public Dictionary<int, ITourModel> TourGroupTours { get; }
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,6 @@ namespace TourCompanyDataModels.Models
|
||||
public DateTime DateTrip { get; }
|
||||
public int GidId { get; }
|
||||
public string GidFIO { get; }
|
||||
}
|
||||
public int UserId { get;}
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,25 @@ namespace TourCompanyDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new TourCompanyDatabase();
|
||||
IQueryable<Execurtion>? queryWhere = null;
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
queryWhere = context.Execurtions
|
||||
.Where(x => model.DateFrom <= x.DateExecurtion &&
|
||||
x.DateExecurtion <= model.DateTo);
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.TourName))
|
||||
{
|
||||
return context.Execurtions
|
||||
.Include(x => x.Tours)
|
||||
.ThenInclude(x => x.Tour)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Execurtions
|
||||
.Include(x => x.Tours)
|
||||
.ThenInclude(x => x.Tour)
|
||||
.Where(x => x.Purpose.Contains(model.Purpose))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
@ -32,7 +32,13 @@ namespace TourCompanyDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new TourCompanyDatabase();
|
||||
return context.Gids
|
||||
IQueryable<Gid>? queryWhere = null;
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
queryWhere = context.Gids
|
||||
.Where(x => x.UserId == model.UserId);
|
||||
}
|
||||
return queryWhere
|
||||
.Include(x => x.Execurtions)
|
||||
.ThenInclude(x => x.Execurtion)
|
||||
.Where(x => x.GidFIO.Contains(model.GidFIO))
|
||||
|
@ -12,7 +12,7 @@ using TourCompanyDatabaseImplement;
|
||||
namespace TourCompanyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(TourCompanyDatabase))]
|
||||
[Migration("20230519231349_InitialCreate")]
|
||||
[Migration("20230520054543_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -43,6 +43,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Execurtions");
|
||||
@ -91,6 +94,8 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Gids");
|
||||
});
|
||||
|
||||
@ -139,6 +144,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TourGroupId");
|
||||
@ -209,6 +217,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("TourGroups");
|
||||
@ -259,6 +270,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GidId");
|
||||
@ -310,6 +324,17 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
b.Navigation("Tour");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Gid", b =>
|
||||
{
|
||||
b.HasOne("TourCompanyDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TourCompanyDatabaseImplement.Models.GidExecurtion", b =>
|
||||
{
|
||||
b.HasOne("TourCompanyDatabaseImplement.Models.Execurtion", "Execurtion")
|
@ -19,26 +19,12 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Purpose = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateExecurtion = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ExecurtionDuratation = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Execurtions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Gids",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
GidFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Experion = table.Column<int>(type: "int", nullable: false),
|
||||
ExecurtionDuratation = table.Column<int>(type: "int", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Gids", x => x.Id);
|
||||
table.PrimaryKey("PK_Execurtions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -48,7 +34,8 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TourGroupName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Type = table.Column<int>(type: "int", nullable: false)
|
||||
Type = table.Column<int>(type: "int", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -70,6 +57,71 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlaceVisits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PlaceVisitName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DatePlaceVisit = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
TourGroupId = table.Column<int>(type: "int", nullable: false),
|
||||
TourGroupName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PlaceVisits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PlaceVisits_TourGroups_TourGroupId",
|
||||
column: x => x.TourGroupId,
|
||||
principalTable: "TourGroups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Gids",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
GidFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Experion = table.Column<int>(type: "int", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Gids", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Gids_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Tours",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TourName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateTour = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Tours", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Tours_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GidExecurtions",
|
||||
columns: table => new
|
||||
@ -105,7 +157,8 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
TripName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateTrip = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
GidId = table.Column<int>(type: "int", nullable: false),
|
||||
GidFIO = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
GidFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -118,75 +171,6 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlaceVisits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PlaceVisitName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DatePlaceVisit = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
TourGroupId = table.Column<int>(type: "int", nullable: false),
|
||||
TourGroupName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PlaceVisits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PlaceVisits_TourGroups_TourGroupId",
|
||||
column: x => x.TourGroupId,
|
||||
principalTable: "TourGroups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Tours",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TourName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateTour = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Tours", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Tours_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlaceVisitTrips",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PlaceVisitId = table.Column<int>(type: "int", nullable: false),
|
||||
TripId = table.Column<int>(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
|
||||
@ -239,6 +223,32 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlaceVisitTrips",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PlaceVisitId = table.Column<int>(type: "int", nullable: false),
|
||||
TripId = table.Column<int>(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.CreateIndex(
|
||||
name: "IX_ExecurtionTours_ExecurtionId",
|
||||
table: "ExecurtionTours",
|
||||
@ -259,6 +269,11 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
table: "GidExecurtions",
|
||||
column: "GidId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Gids_UserId",
|
||||
table: "Gids",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PlaceVisits_TourGroupId",
|
||||
table: "PlaceVisits",
|
@ -40,6 +40,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Execurtions");
|
||||
@ -88,6 +91,8 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Gids");
|
||||
});
|
||||
|
||||
@ -136,6 +141,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TourGroupId");
|
||||
@ -206,6 +214,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("TourGroups");
|
||||
@ -256,6 +267,9 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GidId");
|
||||
@ -307,6 +321,17 @@ namespace TourCompanyDatabaseImplement.Migrations
|
||||
b.Navigation("Tour");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TourCompanyDatabaseImplement.Models.Gid", b =>
|
||||
{
|
||||
b.HasOne("TourCompanyDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TourCompanyDatabaseImplement.Models.GidExecurtion", b =>
|
||||
{
|
||||
b.HasOne("TourCompanyDatabaseImplement.Models.Execurtion", "Execurtion")
|
||||
|
@ -20,6 +20,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
|
||||
public DateTime DateExecurtion { get; set; }
|
||||
public int ExecurtionDuratation { get; set; }
|
||||
public int UserId { get; set; }
|
||||
|
||||
public Dictionary<int, ITourModel>? _execurtionTours = null;
|
||||
public virtual List<ExecurtionTour> Tours { get; set; } = new();
|
||||
@ -44,6 +45,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
Purpose = model.Purpose,
|
||||
DateExecurtion = model.DateExecurtion,
|
||||
ExecurtionDuratation = model.ExecurtionDuratation,
|
||||
UserId = model.UserId,
|
||||
Tours = model.ExecurtionTours.Select(x => new ExecurtionTour
|
||||
{
|
||||
Tour = context.Tours.First(y => y.Id == x.Key)
|
||||
|
@ -19,6 +19,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
public int Experion { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
public Dictionary<int, IExecurtionModel>? _gidExecurtions = null;
|
||||
public virtual List<GidExecurtion> Execurtions { get; set; } = new();
|
||||
public Dictionary<int, IExecurtionModel> GidExecurtions
|
||||
@ -40,6 +41,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
GidFIO = model.GidFIO,
|
||||
Experion = model.Experion,
|
||||
UserId = model.UserId,
|
||||
Execurtions = model.GidExecurtions.Select(x => new GidExecurtion
|
||||
{
|
||||
Execurtion = context.Execurtions.First(y => y.Id == x.Key),
|
||||
@ -61,6 +63,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
Id = Id,
|
||||
GidFIO = GidFIO,
|
||||
Experion = Experion,
|
||||
UserId = UserId,
|
||||
GidExecurtions = GidExecurtions
|
||||
};
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
|
||||
public string TourGroupName { get; set; }
|
||||
public TourGroup TourGroup { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, ITripModel>? _placeVisitTrips = null;
|
||||
public virtual List<PlaceVisitTrip> Trips { get; set; } = new();
|
||||
|
||||
@ -46,6 +47,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
DatePlaceVisit = model.DatePlaceVisit,
|
||||
TourGroupId = model.TourGroupId,
|
||||
TourGroupName = model.TourGroupName,
|
||||
UserId = model.UserId,
|
||||
Trips = model.PlaceVisitTrips.Select(x => new PlaceVisitTrip
|
||||
{
|
||||
Trip = context.Trips.First(y => y.Id == x.Key)
|
||||
@ -69,6 +71,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
DatePlaceVisit = DatePlaceVisit,
|
||||
TourGroupId = TourGroupId,
|
||||
TourGroupName = context.TourGroups.FirstOrDefault(x => x.Id == TourGroupId)?.TourGroupName ?? string.Empty,
|
||||
UserId = UserId,
|
||||
PlaceVisitTrips = PlaceVisitTrips
|
||||
};
|
||||
}
|
||||
|
@ -19,8 +19,9 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
public string TourGroupName { get; set; }
|
||||
|
||||
public TourType Type { get; set; }
|
||||
public int UserId { get; set; }
|
||||
|
||||
public Dictionary<int, ITourModel>? _tourGroupTours = null;
|
||||
public Dictionary<int, ITourModel>? _tourGroupTours = null;
|
||||
public virtual List<TourGroupTour> Tours { get; set; } = new();
|
||||
public Dictionary<int, ITourModel> TourGroupTours
|
||||
{
|
||||
@ -41,7 +42,8 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
TourGroupName = model.TourGroupName,
|
||||
Type = model.Type,
|
||||
Tours = model.TourGroupTours.Select(x => new TourGroupTour{
|
||||
UserId = model.UserId,
|
||||
Tours = model.TourGroupTours.Select(x => new TourGroupTour{
|
||||
Tour = context.Tours.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
@ -56,6 +58,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
Id = Id,
|
||||
TourGroupName = TourGroupName,
|
||||
Type = Type,
|
||||
UserId = UserId,
|
||||
TourGroupTours = TourGroupTours
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
public int GidId { get; set; }
|
||||
public string GidFIO { get; set; }
|
||||
public virtual Gid Gid { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public static Trip? Create(TripBindingModel? model)
|
||||
{
|
||||
return new Trip()
|
||||
@ -27,6 +28,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
TripName = model.TripName,
|
||||
DateTrip = model.DateTrip,
|
||||
UserId = model.UserId,
|
||||
GidId = model.GidId,
|
||||
GidFIO = model.GidFIO
|
||||
};
|
||||
@ -46,6 +48,7 @@ namespace TourCompanyDatabaseImplement.Models
|
||||
Id = Id,
|
||||
TripName = TripName,
|
||||
DateTrip = DateTrip,
|
||||
UserId = UserId,
|
||||
GidId = GidId,
|
||||
GidFIO = context.Gids.FirstOrDefault(x => x.Id == GidId)?.GidFIO ?? string.Empty,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user