WIP ПИбд-23. Максимов А.П. Лабораторная работа №2 #2
@ -14,8 +14,8 @@ public class Check
|
||||
public int Price { get; private set; }
|
||||
public int TripId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public static Check CreateCheck(int id, string title, DateTime purchaseDate, int price, int tripId, int clientId)
|
||||
public static Check CreateCheck(int id, DateTime purchaseDate, int price, int tripId, int clientId)
|
||||
{
|
||||
return new Check() { Id = id, Title = title, PurchaseDate = purchaseDate, Price = price, TripId = tripId, ClientId = clientId };
|
||||
return new Check() { Id = id, PurchaseDate = purchaseDate, Price = price, TripId = tripId, ClientId = clientId };
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,6 @@
|
||||
label1 = new Label();
|
||||
numericUpDownPrice = new NumericUpDown();
|
||||
label2 = new Label();
|
||||
textBoxTitle = new TextBox();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
comboBoxTrip = new ComboBox();
|
||||
@ -46,7 +44,7 @@
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.BackColor = Color.IndianRed;
|
||||
buttonCancel.Location = new Point(221, 260);
|
||||
buttonCancel.Location = new Point(220, 207);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(135, 51);
|
||||
buttonCancel.TabIndex = 31;
|
||||
@ -57,7 +55,7 @@
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.BackColor = Color.LimeGreen;
|
||||
buttonSave.Location = new Point(367, 260);
|
||||
buttonSave.Location = new Point(366, 207);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(135, 51);
|
||||
buttonSave.TabIndex = 30;
|
||||
@ -67,7 +65,7 @@
|
||||
//
|
||||
// dateTimePickerPurchaseDate
|
||||
//
|
||||
dateTimePickerPurchaseDate.Location = new Point(282, 66);
|
||||
dateTimePickerPurchaseDate.Location = new Point(281, 13);
|
||||
dateTimePickerPurchaseDate.Name = "dateTimePickerPurchaseDate";
|
||||
dateTimePickerPurchaseDate.Size = new Size(220, 27);
|
||||
dateTimePickerPurchaseDate.TabIndex = 25;
|
||||
@ -75,7 +73,7 @@
|
||||
// labelStartDate
|
||||
//
|
||||
labelStartDate.AutoSize = true;
|
||||
labelStartDate.Location = new Point(45, 71);
|
||||
labelStartDate.Location = new Point(44, 18);
|
||||
labelStartDate.Name = "labelStartDate";
|
||||
labelStartDate.Size = new Size(92, 20);
|
||||
labelStartDate.TabIndex = 18;
|
||||
@ -84,7 +82,7 @@
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(64, 117);
|
||||
label1.Location = new Point(63, 64);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(45, 20);
|
||||
label1.TabIndex = 34;
|
||||
@ -92,7 +90,7 @@
|
||||
//
|
||||
// numericUpDownPrice
|
||||
//
|
||||
numericUpDownPrice.Location = new Point(284, 110);
|
||||
numericUpDownPrice.Location = new Point(283, 57);
|
||||
numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
|
||||
numericUpDownPrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||
@ -103,32 +101,16 @@
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(45, 163);
|
||||
label2.Location = new Point(44, 110);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(101, 20);
|
||||
label2.TabIndex = 36;
|
||||
label2.Text = "ФИО клиента";
|
||||
//
|
||||
// textBoxTitle
|
||||
//
|
||||
textBoxTitle.Location = new Point(282, 22);
|
||||
textBoxTitle.Name = "textBoxTitle";
|
||||
textBoxTitle.Size = new Size(220, 27);
|
||||
textBoxTitle.TabIndex = 38;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(45, 22);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(135, 20);
|
||||
label3.TabIndex = 37;
|
||||
label3.Text = "Название путевки";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(45, 208);
|
||||
label4.Location = new Point(44, 155);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(64, 20);
|
||||
label4.TabIndex = 39;
|
||||
@ -138,7 +120,7 @@
|
||||
//
|
||||
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(282, 163);
|
||||
comboBoxClient.Location = new Point(281, 110);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(217, 28);
|
||||
comboBoxClient.TabIndex = 41;
|
||||
@ -147,7 +129,7 @@
|
||||
//
|
||||
comboBoxTrip.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTrip.FormattingEnabled = true;
|
||||
comboBoxTrip.Location = new Point(282, 208);
|
||||
comboBoxTrip.Location = new Point(281, 155);
|
||||
comboBoxTrip.Name = "comboBoxTrip";
|
||||
comboBoxTrip.Size = new Size(217, 28);
|
||||
comboBoxTrip.TabIndex = 42;
|
||||
@ -156,12 +138,10 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(513, 322);
|
||||
ClientSize = new Size(513, 272);
|
||||
Controls.Add(comboBoxTrip);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(textBoxTitle);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(numericUpDownPrice);
|
||||
Controls.Add(label1);
|
||||
@ -186,8 +166,6 @@
|
||||
private Label label1;
|
||||
private NumericUpDown numericUpDownPrice;
|
||||
private Label label2;
|
||||
private TextBox textBoxTitle;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private ComboBox comboBoxClient;
|
||||
private ComboBox comboBoxTrip;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using ProjectTourismCompany.Entities;
|
||||
using ProjectTourismCompany.Repositories;
|
||||
using ProjectTourismCompany.Repositories.Implementations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -29,11 +30,11 @@ public partial class FormCheck : Form
|
||||
throw new
|
||||
InvalidDataException(nameof(check));
|
||||
}
|
||||
textBoxTitle.Text = check.Title;
|
||||
dateTimePickerPurchaseDate.Value = check.PurchaseDate;
|
||||
numericUpDownPrice.Value = check.Price;
|
||||
|
||||
comboBoxClient.SelectedItem = check.ClientId;
|
||||
comboBoxTrip.SelectedItem = check.Title;
|
||||
|
||||
|
||||
comboBoxTrip.SelectedItem = check.TripId;
|
||||
_checkId = value;
|
||||
@ -45,7 +46,7 @@ public partial class FormCheck : Form
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormCheck(ICheckRepository checkRepository, IClientRepository clientRepository)
|
||||
public FormCheck(ICheckRepository checkRepository, IClientRepository clientRepository, ITripRepository tripRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_checkRepository = checkRepository ?? throw new ArgumentNullException(nameof(checkRepository));
|
||||
@ -56,20 +57,21 @@ public partial class FormCheck : Form
|
||||
|
||||
comboBoxTrip.DisplayMember = "Title";
|
||||
comboBoxTrip.ValueMember = "Id";
|
||||
comboBoxTrip.DataSource = tripRepository.ReadTrips();
|
||||
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxTitle.Text) ||
|
||||
comboBoxTrip.SelectedIndex < 0 ||
|
||||
if (comboBoxTrip.SelectedIndex < 0 ||
|
||||
comboBoxClient.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_checkRepository.CreateCheck(Check.CreateCheck(_checkId, textBoxTitle.Text, dateTimePickerPurchaseDate.Value,
|
||||
(int)numericUpDownPrice.Value, (int)comboBoxTrip.SelectedItem!,
|
||||
(int)comboBoxClient.SelectedItem!));
|
||||
_checkRepository.CreateCheck(Check.CreateCheck(_checkId, dateTimePickerPurchaseDate.Value,
|
||||
(int)numericUpDownPrice.Value, (int)comboBoxTrip.SelectedIndex!,
|
||||
(int)comboBoxClient.SelectedIndex!));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -71,7 +71,7 @@ Enum.GetValues(typeof(ClientStatus));
|
||||
}
|
||||
else
|
||||
{
|
||||
_clientRepository.UpdateClient(CreateClient(0));
|
||||
_clientRepository.CreateClient(CreateClient(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
@ -83,6 +83,10 @@
|
||||
//
|
||||
// dataGridViewClient
|
||||
//
|
||||
dataGridViewClient.AllowUserToAddRows = false;
|
||||
dataGridViewClient.AllowUserToDeleteRows = false;
|
||||
dataGridViewClient.AllowUserToResizeColumns = false;
|
||||
dataGridViewClient.AllowUserToResizeRows = false;
|
||||
dataGridViewClient.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewClient.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewClient.Dock = DockStyle.Fill;
|
||||
|
@ -34,10 +34,10 @@
|
||||
buttonSave = new Button();
|
||||
groupBox1 = new GroupBox();
|
||||
dataGridView1 = new DataGridView();
|
||||
ColumnTitle = new DataGridViewComboBoxColumn();
|
||||
ColumnAdditionalPrice = new DataGridViewButtonColumn();
|
||||
comboBoxCountry = new ComboBox();
|
||||
label2 = new Label();
|
||||
ColumnTitle = new DataGridViewComboBoxColumn();
|
||||
ColumnAdditionalPrice = new DataGridViewTextBoxColumn();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -107,19 +107,6 @@
|
||||
dataGridView1.Size = new Size(292, 280);
|
||||
dataGridView1.TabIndex = 0;
|
||||
//
|
||||
// ColumnTitle
|
||||
//
|
||||
ColumnTitle.HeaderText = "Название путевки";
|
||||
ColumnTitle.MinimumWidth = 6;
|
||||
ColumnTitle.Name = "ColumnTitle";
|
||||
//
|
||||
// ColumnAdditionalPrice
|
||||
//
|
||||
ColumnAdditionalPrice.HeaderText = "Надбавка фирмы";
|
||||
ColumnAdditionalPrice.MinimumWidth = 6;
|
||||
ColumnAdditionalPrice.Name = "ColumnAdditionalPrice";
|
||||
ColumnAdditionalPrice.Resizable = DataGridViewTriState.True;
|
||||
//
|
||||
// comboBoxCountry
|
||||
//
|
||||
comboBoxCountry.FormattingEnabled = true;
|
||||
@ -137,6 +124,19 @@
|
||||
label2.TabIndex = 21;
|
||||
label2.Text = "Страна";
|
||||
//
|
||||
// ColumnTitle
|
||||
//
|
||||
ColumnTitle.HeaderText = "Название путевки";
|
||||
ColumnTitle.MinimumWidth = 6;
|
||||
ColumnTitle.Name = "ColumnTitle";
|
||||
//
|
||||
// ColumnAdditionalPrice
|
||||
//
|
||||
ColumnAdditionalPrice.HeaderText = "Надбавка фирмы";
|
||||
ColumnAdditionalPrice.MinimumWidth = 6;
|
||||
ColumnAdditionalPrice.Name = "ColumnAdditionalPrice";
|
||||
ColumnAdditionalPrice.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||
//
|
||||
// FormCompany
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -166,9 +166,9 @@
|
||||
private Button buttonSave;
|
||||
private GroupBox groupBox1;
|
||||
private DataGridView dataGridView1;
|
||||
private DataGridViewComboBoxColumn ColumnTitle;
|
||||
private DataGridViewButtonColumn ColumnAdditionalPrice;
|
||||
private ComboBox comboBoxCountry;
|
||||
private Label label2;
|
||||
private DataGridViewComboBoxColumn ColumnTitle;
|
||||
private DataGridViewTextBoxColumn ColumnAdditionalPrice;
|
||||
}
|
||||
}
|
@ -55,7 +55,7 @@ public partial class FormCompany : Form
|
||||
_companyRepository = companyRepository ??
|
||||
throw new ArgumentNullException(nameof(companyRepository));
|
||||
comboBoxCountry.DataSource = countryRepository.ReadCountries();
|
||||
comboBoxCountry.DisplayMember = "Name";
|
||||
comboBoxCountry.DisplayMember = "CountryName";
|
||||
comboBoxCountry.ValueMember = "Id";
|
||||
|
||||
ColumnTitle.DataSource = tripRepository.ReadTrips();
|
||||
@ -73,7 +73,7 @@ public partial class FormCompany : Form
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_companyRepository.CreateCompany(Company.CreateCompany(0, textBoxName.Text, (int)comboBoxCountry.SelectedItem!, CreateListCompanyTripFromDataGrid()));
|
||||
_companyRepository.CreateCompany(Company.CreateCompany(0, textBoxName.Text, (int)comboBoxCountry.SelectedIndex!, CreateListCompanyTripFromDataGrid()));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -51,6 +51,7 @@
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.ReadOnly = true;
|
||||
dataGridView1.RowHeadersVisible = false;
|
||||
dataGridView1.RowHeadersWidth = 51;
|
||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.Size = new Size(800, 450);
|
||||
|
@ -61,7 +61,7 @@ public partial class FormCountry : Form
|
||||
}
|
||||
else
|
||||
{
|
||||
_countryRepository.UpdateCountry(CreateCountry(0));
|
||||
_countryRepository.CreateCountry(CreateCountry(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ Enum.GetValues(typeof(TravelType)))
|
||||
{
|
||||
tr |= (TravelType)elem;
|
||||
}
|
||||
return Trip.CreateOpeartion(0, textBoxTitle.Text, (int)numericUpDownPrice.Value,
|
||||
return Trip.CreateOpeartion(id, textBoxTitle.Text, (int)numericUpDownPrice.Value,
|
||||
(int)numericUpDownHumanCapacity.Value, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value,
|
||||
textBoxStartCity.Text, textBoxEndCity.Text, tr);
|
||||
}
|
||||
|
@ -43,31 +43,31 @@
|
||||
dataGridView1.AllowUserToResizeRows = false;
|
||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.ColumnHeadersVisible = false;
|
||||
dataGridView1.Dock = DockStyle.Fill;
|
||||
dataGridView1.Location = new Point(0, 0);
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.ReadOnly = true;
|
||||
dataGridView1.RowHeadersVisible = false;
|
||||
dataGridView1.RowHeadersWidth = 51;
|
||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.Size = new Size(800, 450);
|
||||
dataGridView1.Size = new Size(1098, 538);
|
||||
dataGridView1.TabIndex = 0;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonAddTrip);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(645, 0);
|
||||
panel1.Location = new Point(970, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(155, 450);
|
||||
panel1.Size = new Size(128, 538);
|
||||
panel1.TabIndex = 1;
|
||||
//
|
||||
// buttonAddTrip
|
||||
//
|
||||
buttonAddTrip.BackgroundImage = Properties.Resources.plus;
|
||||
buttonAddTrip.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAddTrip.Location = new Point(34, 31);
|
||||
buttonAddTrip.Location = new Point(23, 29);
|
||||
buttonAddTrip.Name = "buttonAddTrip";
|
||||
buttonAddTrip.Size = new Size(94, 80);
|
||||
buttonAddTrip.TabIndex = 5;
|
||||
@ -78,7 +78,7 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
ClientSize = new Size(1098, 538);
|
||||
Controls.Add(panel1);
|
||||
Controls.Add(dataGridView1);
|
||||
Name = "FormTrips";
|
||||
|
@ -3,6 +3,10 @@ using Unity;
|
||||
using ProjectTourismCompany.Repositories;
|
||||
using ProjectTourismCompany.Repositories.Implementations;
|
||||
using ProjectTourismCompany;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using Unity.Microsoft.Logging;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
@ -19,12 +23,28 @@ internal static class Program
|
||||
private static IUnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||
|
||||
container.RegisterType<ICheckRepository, CheckRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<IClientRepository, ClientRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<ICompanyRepository, CompanyRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<ICountryRepository, CountryRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<ITripRepository, TripRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<ITripRepository, TripRepository>();
|
||||
|
||||
container.RegisterType<IConnectionString, ConnectionString>();
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private static LoggerFactory CreateLoggerFactory()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
return loggerFactory;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,18 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.2" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.1-dev-02308" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -27,4 +38,10 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -9,9 +9,7 @@ namespace ProjectTourismCompany.Repositories;
|
||||
|
||||
public interface ICheckRepository
|
||||
{
|
||||
IEnumerable<Check> ReadChecks(DateTime? dateFrom =
|
||||
null, DateTime? dateTo = null,
|
||||
int? tripId = null, int? clientId = null);
|
||||
IEnumerable<Check> ReadChecks(DateTime? dateFrom = null, DateTime? dateTo = null, int? tripId = null, int? clientId = null);
|
||||
Check ReadCheckById(int id);
|
||||
void CreateCheck(Check check);
|
||||
void DeleteCheck(int id);
|
||||
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTourismCompany.Repositories;
|
||||
|
||||
public interface IConnectionString
|
||||
{
|
||||
public string ConnectionString { get;}
|
||||
}
|
@ -1,4 +1,8 @@
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectTourismCompany.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -10,25 +14,91 @@ namespace ProjectTourismCompany.Repositories.Implementations;
|
||||
|
||||
internal class CheckRepository : ICheckRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
public ILogger<CheckRepository> _logger;
|
||||
|
||||
|
||||
public CheckRepository(IConnectionString connectionString, ILogger<CheckRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateCheck(Check check)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(check));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Receipt (Title, PurchaseDate, Price, TripId, ClientId)
|
||||
VALUES (@Title, @PurchaseDate, @Price, @TripId, @ClientId)";
|
||||
connection.Execute(queryInsert, check);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteCheck(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Receipt
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Check> ReadChecks(DateTime? dateFrom = null, DateTime? dateTo = null, int? tripId = null, int? clientId = null)
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Receipt";
|
||||
var expenses = connection.Query<Check>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
|
||||
return expenses;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Check ReadCheckById(int id)
|
||||
{
|
||||
return Check.CreateCheck(0, "title", DateTime.Now, 500, 1, 2);
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Receipt
|
||||
WHERE Id=@id";
|
||||
var expense = connection.QueryFirst<Check>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
|
||||
return expense;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
using ProjectTourismCompany.Entities.Enums;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectTourismCompany.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,28 +13,114 @@ namespace ProjectTourismCompany.Repositories.Implementations;
|
||||
|
||||
internal class ClientRepository : IClientRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<ClientRepository> _logger;
|
||||
|
||||
public ClientRepository(IConnectionString connectionString, ILogger<ClientRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateClient(Client client)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Client (Name, BirthDate, Status, Phone)
|
||||
VALUES (@Name, @BirthDate, @Status, @Phone)";
|
||||
connection.Execute(queryInsert, client);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteClient(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Client
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Client ReadClientById(int id)
|
||||
{
|
||||
return Client.CreateClient(0, string.Empty, DateTime.Now, ClientStatus.None, "1") ;
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Client
|
||||
WHERE Id=@id";
|
||||
var expense = connection.QueryFirst<Client>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
|
||||
return expense;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Client> ReadClients()
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Client";
|
||||
var expenses = connection.Query<Client>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
|
||||
return expenses;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateClient(Client client)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Client
|
||||
SET
|
||||
Name=@Name,
|
||||
BirthDate=@BirthDate,
|
||||
Status=@Status,
|
||||
Phone=@Phone
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, client);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,9 @@
|
||||
using ProjectTourismCompany.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectTourismCompany.Entities;
|
||||
using ProjectTourismCompany.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,28 +14,145 @@ namespace ProjectTourismCompany.Repositories.Implementations;
|
||||
|
||||
internal class CompanyRepository : ICompanyRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<CompanyRepository> _logger;
|
||||
|
||||
|
||||
public CompanyRepository(IConnectionString connectionString, ILogger<CompanyRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public void CreateCompany(Company company)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(company));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"
|
||||
INSERT INTO Company (Name, CountryId)
|
||||
VALUES (@Name, @CountryId);
|
||||
SELECT MAX(Id) FROM Company";
|
||||
var companyId =
|
||||
connection.QueryFirst<int>(queryInsert, company, transaction);
|
||||
var querySubInsert = @"
|
||||
INSERT INTO CompanyTrip (CompanyId, TripId, AdditionalPrice)
|
||||
VALUES (@CompanyId, @TripId, @AdditionalPrice)";
|
||||
foreach (var elem in company.CompanyTrip)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
companyId,
|
||||
elem.TripId,
|
||||
elem.AdditionalPrice
|
||||
}, transaction);
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteCompany(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryDeleteSub = @"
|
||||
DELETE FROM CompanyTrip
|
||||
WHERE CompanyId = @id";
|
||||
connection.Execute(queryDeleteSub, new { id }, transaction);
|
||||
|
||||
var queryDelete = @"
|
||||
DELETE FROM Company
|
||||
WHERE Id = @id";
|
||||
connection.Execute(queryDelete, new { id }, transaction);
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IEnumerable<Company> ReadCompanies()
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Company";
|
||||
var peopleExpenses = connection.Query<Company>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(peopleExpenses));
|
||||
return peopleExpenses;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Company ReadCompanyById(int id)
|
||||
{
|
||||
return Company.CreateCompany(1, "randomName", 73, []);
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Company
|
||||
WHERE Id=@id";
|
||||
var expense = connection.QueryFirst<Company>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
|
||||
return expense;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCompany(Company company)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(company));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Company
|
||||
SET
|
||||
Name=@Name,
|
||||
CountryId=@CountryId
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, company);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTourismCompany.Repositories.Implementations;
|
||||
|
||||
public class ConnectionString : IConnectionString
|
||||
{
|
||||
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=postgres1";
|
||||
}
|
@ -1,4 +1,8 @@
|
||||
using ProjectTourismCompany.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectTourismCompany.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -7,30 +11,114 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectTourismCompany.Repositories.Implementations;
|
||||
|
||||
internal class CountryRepository : ICountryRepository
|
||||
public class CountryRepository : ICountryRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<CountryRepository> _logger;
|
||||
|
||||
public CountryRepository(IConnectionString connectionString, ILogger<CountryRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public void CreateCountry(Country country)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(country));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Country (CountryName)
|
||||
VALUES (@CountryName)";
|
||||
connection.Execute(queryInsert, country);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteCountry(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Country
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Country> ReadCountries()
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Country";
|
||||
var expenses = connection.Query<Country>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
|
||||
return expenses;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Country ReadCountryById(int id)
|
||||
{
|
||||
return Country.CreateCountry(73, "Russia");
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Country
|
||||
WHERE Id=@id";
|
||||
var expense = connection.QueryFirst<Country>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
|
||||
return expense;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCountry(Country country)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(country));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Country
|
||||
SET
|
||||
CountryName=@CountryName
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, country);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
using ProjectTourismCompany.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectTourismCompany.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,18 +13,72 @@ namespace ProjectTourismCompany.Repositories.Implementations;
|
||||
|
||||
internal class TripRepository : ITripRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<TripRepository> _logger;
|
||||
|
||||
public TripRepository(IConnectionString connectionString, ILogger<TripRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public void CreateTrip(Trip trip)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(trip));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Trip (Title, Price, HumanCapacity, StartDate, EndDate, StartCity, EndCity, CompanyId, TravelType)
|
||||
VALUES (@Title, @Price, @HumanCapacity, @StartDate, @EndDate, @StartCity, @EndCity, @CompanyId, @TravelType)";
|
||||
connection.Execute(queryInsert, trip);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Trip ReadTripById(int id)
|
||||
{
|
||||
return Trip.CreateOpeartion(0, "a", 0, 0, DateTime.Now, DateTime.Now, "Moscow", "Piter", Entities.Enums.TravelType.None);
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Trip
|
||||
WHERE Id=@id";
|
||||
var expense = connection.QueryFirst<Trip>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
|
||||
return expense;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Trip> ReadTrips(DateTime? dateForm = null, DateTime? dateTo = null, int? tripId = null, int? companyId = null, int? countryId = null)
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Trip";
|
||||
var expenses = connection.Query<Trip>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
|
||||
return expenses;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
ProjectTourismCompany/ProjectTourismCompany/appsettings.json
Normal file
15
ProjectTourismCompany/ProjectTourismCompany/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/tourism_log.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user