Pibd-24 Boyko_M.S. LabWork04 #4
@ -5,18 +5,29 @@ namespace ProjectGSM.Entities;
|
|||||||
|
|
||||||
public class Advocate
|
public class Advocate
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[Browsable(false)] public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
public bool Sex { get; private set; }
|
[DisplayName("Имя")] public string Name { get; private set; } = string.Empty;
|
||||||
public DateTime DateOfBirth { get; private set; }
|
|
||||||
public int Experience { get; private set; }
|
[DisplayName("Пол")] public bool Sex { get; private set; }
|
||||||
public int CompletedTasks { get; private set; }
|
|
||||||
public int Rating { get; private set; }
|
[DisplayName("Дата рождения")] public DateTime DateOfBirth { get; private set; }
|
||||||
public string Email { get; private set; } = string.Empty;
|
|
||||||
public string PhoneNumber { get; private set; } = string.Empty;
|
[DisplayName("Опыт")] public int Experience { get; private set; }
|
||||||
public string Address { get; private set; } = string.Empty;
|
|
||||||
public LicenseType LicenseType { get; private set; }
|
[DisplayName("Выполненные задачи")] public int CompletedTasks { get; private set; }
|
||||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
|
||||||
|
[DisplayName("Рейтинг")] public int Rating { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Электронная почта")] public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Номер телефона")] public string PhoneNumber { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Адрес")] public string Address { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Тип лицензии")] public LicenseType LicenseType { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата создания")] public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
// Конструктор для создания сущности
|
// Конструктор для создания сущности
|
||||||
public static Advocate CreateEntity(
|
public static Advocate CreateEntity(
|
||||||
@ -47,4 +58,4 @@ public class Advocate
|
|||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +1,39 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.ComponentModel;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using ProjectGSM.Entities.Enums;
|
using ProjectGSM.Entities.Enums;
|
||||||
|
|
||||||
namespace ProjectGSM.Entities;
|
namespace ProjectGSM.Entities;
|
||||||
|
|
||||||
public class Case
|
public class Case
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[Browsable(false)] public int Id { get; private set; }
|
||||||
public TypeAppeal TypeAppeal { get; private set; }
|
|
||||||
public bool Payment { get; private set; } = false;
|
[DisplayName("Тип обращения")] public TypeAppeal TypeAppeal { get; private set; }
|
||||||
public decimal Price { get; private set; }
|
|
||||||
public decimal VictoryPrice { get; private set; }
|
[DisplayName("Оплата")] public bool Payment { get; private set; } = false;
|
||||||
public bool Verdict { get; private set; } = false;
|
|
||||||
public int CourtId { get; private set; }
|
[DisplayName("Цена")] public decimal Price { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
|
||||||
public string Description { get; private set; } = string.Empty;
|
[DisplayName("Цена приговора")] public decimal VictoryPrice { get; private set; }
|
||||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
|
||||||
[JsonIgnore]public List<CaseAdvocate> Advocates { get; set; }
|
[DisplayName("Решение")] public bool Verdict { get; private set; } = false;
|
||||||
|
|
||||||
|
[Browsable(false)] public int CourtId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)] public int ClientId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Суд")] public string CourtName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Клиент")] public string ClientName { get; private set; } = string.Empty;
|
||||||
|
[DisplayName("Описание")] public string Description { get; private set; } = string.Empty;
|
||||||
|
[DisplayName("Дата создания")] public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
|
||||||
|
[JsonIgnore] [Browsable(false)] public List<CaseAdvocate> Advocates { get; set; } = new();
|
||||||
|
|
||||||
|
[DisplayName("Адвокаты")]
|
||||||
|
public string AdvocatesNames => string.Join(", ", Advocates.Select(x => $"{x.AdvocateName} ({x.Post})"));
|
||||||
|
|
||||||
// Конструктор для создания сущности
|
// Конструктор для создания сущности
|
||||||
public static Case CreateEntity(
|
public static Case CreateEntity(
|
||||||
int id,
|
int id,
|
||||||
@ -27,7 +45,7 @@ public class Case
|
|||||||
int courtId,
|
int courtId,
|
||||||
int clientId,
|
int clientId,
|
||||||
string description
|
string description
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return new Case
|
return new Case
|
||||||
{
|
{
|
||||||
@ -43,4 +61,4 @@ public class Case
|
|||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,20 @@
|
|||||||
namespace ProjectGSM.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectGSM.Entities;
|
||||||
|
|
||||||
public class CaseAdvocate
|
public class CaseAdvocate
|
||||||
{
|
{
|
||||||
public int CaseId { get; private set; }
|
[Browsable(false)] public int CaseId { get; private set; }
|
||||||
public int AdvocateId { get; private set; }
|
|
||||||
public string Post { get; private set; } = string.Empty;
|
[Browsable(false)] public int AdvocateId { get; private set; }
|
||||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
|
||||||
|
[DisplayName("Дело")] public string CaseDescription { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Авокат")] public string AdvocateName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Должность")] public string Post { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата создания")] public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
// Конструктор для создания сущности
|
// Конструктор для создания сущности
|
||||||
public static CaseAdvocate CreateEntity(int caseId, int advocateId, string post)
|
public static CaseAdvocate CreateEntity(int caseId, int advocateId, string post)
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
namespace ProjectGSM.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectGSM.Entities;
|
||||||
|
|
||||||
public class Client
|
public class Client
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[Browsable(false)] public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
public bool Sex { get; private set; }
|
[DisplayName("Имя")] public string Name { get; private set; } = string.Empty;
|
||||||
public DateTime DateOfBirth { get; private set; }
|
|
||||||
public string Email { get; private set; } = string.Empty;
|
[DisplayName("Пол")] public bool Sex { get; private set; }
|
||||||
public string PhoneNumber { get; private set; } = string.Empty;
|
|
||||||
public string Address { get; private set; } = string.Empty;
|
[DisplayName("Дата рождения")] public DateTime DateOfBirth { get; private set; }
|
||||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
|
||||||
|
[DisplayName("Электронная почта")] public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Номер телефона")] public string PhoneNumber { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Адрес")] public string Address { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата создания")] public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
// Конструктор для создания сущности
|
// Конструктор для создания сущности
|
||||||
public static Client CreateEntity(
|
public static Client CreateEntity(
|
||||||
@ -33,4 +42,4 @@ public class Client
|
|||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,16 @@
|
|||||||
namespace ProjectGSM.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectGSM.Entities;
|
||||||
|
|
||||||
public class Court
|
public class Court
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[Browsable(false)] public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
public string Address { get; private set; } = string.Empty;
|
[DisplayName("Название")] public string Name { get; private set; } = string.Empty;
|
||||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
|
||||||
|
[DisplayName("Адрес")] public string Address { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата создания")] public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
// Конструктор для создания сущности
|
// Конструктор для создания сущности
|
||||||
public static Court CreateEntity(int id, string name, string address, DateTime? createdAt = null)
|
public static Court CreateEntity(int id, string name, string address, DateTime? createdAt = null)
|
||||||
@ -18,4 +23,4 @@ public class Court
|
|||||||
CreatedAt = createdAt ?? DateTime.UtcNow
|
CreatedAt = createdAt ?? DateTime.UtcNow
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,19 @@
|
|||||||
using ProjectGSM.Entities.Enums;
|
using System.ComponentModel;
|
||||||
|
using ProjectGSM.Entities.Enums;
|
||||||
|
|
||||||
namespace ProjectGSM.Entities;
|
namespace ProjectGSM.Entities;
|
||||||
|
|
||||||
public class StatusHistory
|
public class StatusHistory
|
||||||
{
|
{
|
||||||
public int CaseId { get; private set; }
|
[Browsable(false)] public int CaseId { get; private set; }
|
||||||
public Status Status { get; private set; }
|
|
||||||
public decimal Price { get; private set; }
|
[DisplayName("Дело")] public string CaseDescription { get; private set; } = string.Empty;
|
||||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
|
||||||
|
[DisplayName("Статус")] public Status Status { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Цена")] public decimal Price { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата создания")] public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
// Конструктор для создания сущности
|
// Конструктор для создания сущности
|
||||||
public static StatusHistory CreateEntity(int caseId, Status status, decimal price, DateTime? dateTime = null)
|
public static StatusHistory CreateEntity(int caseId, Status status, decimal price, DateTime? dateTime = null)
|
||||||
@ -20,4 +26,4 @@ public class StatusHistory
|
|||||||
CreatedAt = dateTime ?? DateTime.UtcNow
|
CreatedAt = dateTime ?? DateTime.UtcNow
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using ProjectGSM.Forms;
|
using ProjectGSM.Forms;
|
||||||
using System.ComponentModel;
|
|
||||||
using Unity;
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectGSM
|
namespace ProjectGSM
|
||||||
|
@ -102,8 +102,12 @@ namespace ProjectGSM.Forms
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewAdvocats.DataSource =
|
private void LoadList() {
|
||||||
_advocateRepository.ReadAdvocates();
|
dataGridViewAdvocats.DataSource =
|
||||||
|
_advocateRepository.ReadAdvocates();
|
||||||
|
dataGridViewAdvocats.Columns["CreatedAt"].DefaultCellStyle.Format =
|
||||||
|
"dd.MM.yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
44
ProjectGSM/Forms/FormCases.Designer.cs
generated
44
ProjectGSM/Forms/FormCases.Designer.cs
generated
@ -31,9 +31,9 @@
|
|||||||
panel1 = new Panel();
|
panel1 = new Panel();
|
||||||
deleteButton = new Button();
|
deleteButton = new Button();
|
||||||
addButton = new Button();
|
addButton = new Button();
|
||||||
dataGridView1 = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
panel1.SuspendLayout();
|
panel1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
@ -71,37 +71,37 @@
|
|||||||
//
|
//
|
||||||
// dataGridView1
|
// dataGridView1
|
||||||
//
|
//
|
||||||
dataGridView1.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView1.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView1.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView1.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView1.BackgroundColor = SystemColors.Info;
|
dataGridView.BackgroundColor = SystemColors.Info;
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
dataGridView1.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView1.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView1.Name = "dataGridView1";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView1.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView1.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView1.RowHeadersWidth = 62;
|
dataGridView.RowHeadersWidth = 62;
|
||||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView1.Size = new Size(604, 450);
|
dataGridView.Size = new Size(604, 450);
|
||||||
dataGridView1.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// FormCases
|
// FormCases
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(746, 450);
|
ClientSize = new Size(746, 450);
|
||||||
Controls.Add(dataGridView1);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(panel1);
|
Controls.Add(panel1);
|
||||||
Name = "FormCases";
|
Name = "FormCases";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Дела";
|
Text = "Дела";
|
||||||
Load += FormClients_Load;
|
Load += FormClients_Load;
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +110,6 @@
|
|||||||
private Panel panel1;
|
private Panel panel1;
|
||||||
private Button deleteButton;
|
private Button deleteButton;
|
||||||
private Button addButton;
|
private Button addButton;
|
||||||
private DataGridView dataGridView1;
|
private DataGridView dataGridView;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -81,20 +81,25 @@ namespace ProjectGSM.Forms
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridView1.DataSource =
|
private void LoadList()
|
||||||
_caseRepository.ReadCases();
|
{
|
||||||
|
dataGridView.DataSource =
|
||||||
|
_caseRepository.ReadCases();
|
||||||
|
dataGridView.Columns["CreatedAt"].DefaultCellStyle.Format =
|
||||||
|
"dd.MM.yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
if (dataGridView1.SelectedRows.Count < 1)
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
id =
|
id =
|
||||||
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
ProjectGSM/Forms/FormClients.Designer.cs
generated
42
ProjectGSM/Forms/FormClients.Designer.cs
generated
@ -32,9 +32,9 @@
|
|||||||
deleteButton = new Button();
|
deleteButton = new Button();
|
||||||
editButton = new Button();
|
editButton = new Button();
|
||||||
addButton = new Button();
|
addButton = new Button();
|
||||||
dataGridView1 = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
panel1.SuspendLayout();
|
panel1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
@ -86,36 +86,36 @@
|
|||||||
//
|
//
|
||||||
// dataGridView1
|
// dataGridView1
|
||||||
//
|
//
|
||||||
dataGridView1.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView1.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView1.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView1.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView1.BackgroundColor = SystemColors.Info;
|
dataGridView.BackgroundColor = SystemColors.Info;
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
dataGridView1.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView1.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView1.Name = "dataGridView1";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView1.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView1.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView1.Size = new Size(604, 450);
|
dataGridView.Size = new Size(604, 450);
|
||||||
dataGridView1.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// FormClients
|
// FormClients
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(746, 450);
|
ClientSize = new Size(746, 450);
|
||||||
Controls.Add(dataGridView1);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(panel1);
|
Controls.Add(panel1);
|
||||||
Name = "FormClients";
|
Name = "FormClients";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Клиенты";
|
Text = "Клиенты";
|
||||||
Load += FormClients_Load;
|
Load += FormClients_Load;
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +125,6 @@
|
|||||||
private Button deleteButton;
|
private Button deleteButton;
|
||||||
private Button editButton;
|
private Button editButton;
|
||||||
private Button addButton;
|
private Button addButton;
|
||||||
private DataGridView dataGridView1;
|
private DataGridView dataGridView;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -102,20 +102,24 @@ namespace ProjectGSM.Forms
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridView1.DataSource =
|
private void LoadList() {
|
||||||
_clientRepository.ReadClients();
|
dataGridView.DataSource =
|
||||||
|
_clientRepository.ReadClients();
|
||||||
|
dataGridView.Columns["CreatedAt"].DefaultCellStyle.Format =
|
||||||
|
"dd.MM.yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
if (dataGridView1.SelectedRows.Count < 1)
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
id =
|
id =
|
||||||
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
ProjectGSM/Forms/FormCourts.Designer.cs
generated
42
ProjectGSM/Forms/FormCourts.Designer.cs
generated
@ -32,9 +32,9 @@
|
|||||||
deleteButton = new Button();
|
deleteButton = new Button();
|
||||||
editButton = new Button();
|
editButton = new Button();
|
||||||
addButton = new Button();
|
addButton = new Button();
|
||||||
dataGridView1 = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
panel1.SuspendLayout();
|
panel1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
@ -86,36 +86,36 @@
|
|||||||
//
|
//
|
||||||
// dataGridView1
|
// dataGridView1
|
||||||
//
|
//
|
||||||
dataGridView1.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView1.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView1.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView1.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView1.BackgroundColor = SystemColors.Info;
|
dataGridView.BackgroundColor = SystemColors.Info;
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
dataGridView1.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView1.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView1.Name = "dataGridView1";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView1.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView1.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView1.Size = new Size(604, 450);
|
dataGridView.Size = new Size(604, 450);
|
||||||
dataGridView1.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// FormCourts
|
// FormCourts
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(746, 450);
|
ClientSize = new Size(746, 450);
|
||||||
Controls.Add(dataGridView1);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(panel1);
|
Controls.Add(panel1);
|
||||||
Name = "FormCourts";
|
Name = "FormCourts";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Суды";
|
Text = "Суды";
|
||||||
Load += FormClients_Load;
|
Load += FormClients_Load;
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +125,6 @@
|
|||||||
private Button deleteButton;
|
private Button deleteButton;
|
||||||
private Button editButton;
|
private Button editButton;
|
||||||
private Button addButton;
|
private Button addButton;
|
||||||
private DataGridView dataGridView1;
|
private DataGridView dataGridView;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -102,20 +102,25 @@ namespace ProjectGSM.Forms
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridView1.DataSource =
|
private void LoadList()
|
||||||
_courtRepository.ReadCourts();
|
{
|
||||||
|
dataGridView.DataSource =
|
||||||
|
_courtRepository.ReadCourts();
|
||||||
|
dataGridView.Columns["CreatedAt"].DefaultCellStyle.Format =
|
||||||
|
"dd.MM.yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
if (dataGridView1.SelectedRows.Count < 1)
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
id =
|
id =
|
||||||
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
ProjectGSM/Forms/FormStatusesHistory.Designer.cs
generated
42
ProjectGSM/Forms/FormStatusesHistory.Designer.cs
generated
@ -30,9 +30,9 @@
|
|||||||
{
|
{
|
||||||
panel1 = new Panel();
|
panel1 = new Panel();
|
||||||
addButton = new Button();
|
addButton = new Button();
|
||||||
dataGridView1 = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
panel1.SuspendLayout();
|
panel1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
@ -58,36 +58,36 @@
|
|||||||
//
|
//
|
||||||
// dataGridView1
|
// dataGridView1
|
||||||
//
|
//
|
||||||
dataGridView1.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView1.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView1.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView1.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView1.BackgroundColor = SystemColors.Info;
|
dataGridView.BackgroundColor = SystemColors.Info;
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
dataGridView1.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView1.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView1.Name = "dataGridView1";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView1.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView1.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView1.Size = new Size(604, 450);
|
dataGridView.Size = new Size(604, 450);
|
||||||
dataGridView1.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// FormStatusesHistory
|
// FormStatusesHistory
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(746, 450);
|
ClientSize = new Size(746, 450);
|
||||||
Controls.Add(dataGridView1);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(panel1);
|
Controls.Add(panel1);
|
||||||
Name = "FormStatusesHistory";
|
Name = "FormStatusesHistory";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Суды";
|
Text = "Суды";
|
||||||
Load += FormClients_Load;
|
Load += FormClients_Load;
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +95,6 @@
|
|||||||
|
|
||||||
private Panel panel1;
|
private Panel panel1;
|
||||||
private Button addButton;
|
private Button addButton;
|
||||||
private DataGridView dataGridView1;
|
private DataGridView dataGridView;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,16 +8,17 @@ namespace ProjectGSM.Forms
|
|||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
private readonly IStatusHistoryRepository _statusHistoryRepository;
|
private readonly IStatusHistoryRepository _statusHistoryRepository;
|
||||||
|
|
||||||
public FormStatusesHistory(IUnityContainer container, IStatusHistoryRepository statusHistoryRepository)
|
public FormStatusesHistory(IUnityContainer container, IStatusHistoryRepository statusHistoryRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ??
|
_container = container ??
|
||||||
throw new ArgumentNullException(nameof(container));
|
throw new ArgumentNullException(nameof(container));
|
||||||
_statusHistoryRepository = statusHistoryRepository ??
|
_statusHistoryRepository = statusHistoryRepository ??
|
||||||
throw new
|
throw new
|
||||||
ArgumentNullException(nameof(statusHistoryRepository));
|
ArgumentNullException(nameof(statusHistoryRepository));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addButton_Click(object sender, EventArgs e)
|
private void addButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -28,9 +29,8 @@ namespace ProjectGSM.Forms
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormClients_Load(object sender, EventArgs e)
|
private void FormClients_Load(object sender, EventArgs e)
|
||||||
@ -42,27 +42,31 @@ namespace ProjectGSM.Forms
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridView1.DataSource =
|
private void LoadList()
|
||||||
_statusHistoryRepository.ReadStatusHistories();
|
{
|
||||||
|
dataGridView.DataSource =
|
||||||
|
_statusHistoryRepository.ReadStatusHistories();
|
||||||
|
dataGridView.Columns["CreatedAt"].DefaultCellStyle.Format =
|
||||||
|
"dd.MM.yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
if (dataGridView1.SelectedRows.Count < 1)
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
id =
|
id =
|
||||||
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
34
ProjectGSM/Query/QueryBuilder.cs
Normal file
34
ProjectGSM/Query/QueryBuilder.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ProjectGSM.Query;
|
||||||
|
|
||||||
|
internal class QueryBuilder
|
||||||
|
{
|
||||||
|
private readonly StringBuilder _builder;
|
||||||
|
|
||||||
|
public QueryBuilder()
|
||||||
|
{
|
||||||
|
_builder = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryBuilder AddCondition(string condition)
|
||||||
|
{
|
||||||
|
if (_builder.Length > 0)
|
||||||
|
{
|
||||||
|
_builder.Append(" AND ");
|
||||||
|
}
|
||||||
|
|
||||||
|
_builder.Append(condition);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Build()
|
||||||
|
{
|
||||||
|
if (_builder.Length == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"WHERE {_builder}";
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ namespace ProjectGSM.Repositories;
|
|||||||
public interface IStatusHistoryRepository
|
public interface IStatusHistoryRepository
|
||||||
{
|
{
|
||||||
IEnumerable<StatusHistory> ReadStatusHistories(DateTime? dateForm = null, DateTime? dateTo = null,
|
IEnumerable<StatusHistory> ReadStatusHistories(DateTime? dateForm = null, DateTime? dateTo = null,
|
||||||
int? caseId = null, int? statusId = null);
|
int? caseId = null);
|
||||||
void CreateStatusHistory(StatusHistory statusHistory);
|
void CreateStatusHistory(StatusHistory statusHistory);
|
||||||
void DeleteStatusHistory(int statusId, int caseId);
|
void DeleteStatusHistory(int statusId, int caseId);
|
||||||
}
|
}
|
@ -27,7 +27,10 @@ public class CaseAdvocatesRepository : ICaseAdvocateRepository
|
|||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM case_advocates";
|
var querySelect =
|
||||||
|
"SELECT ca.*, a.name as AdvocateName, cs.description as CaseDescription " +
|
||||||
|
"FROM case_advocates as ca LEFT JOIN cases as cs ON cs.id = ca.caseid " +
|
||||||
|
"LEFT JOIN advocates as a ON a.id = ca.advocateid";
|
||||||
var caseAdvocates =
|
var caseAdvocates =
|
||||||
connection.Query<CaseAdvocate>(querySelect);
|
connection.Query<CaseAdvocate>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
@ -26,8 +26,12 @@ public class CaseRepository : ICaseRepository
|
|||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM cases";
|
var querySelect =
|
||||||
|
"SELECT cases.*, courts.name as CourtName, clients.name as ClientName " +
|
||||||
|
"FROM cases LEFT JOIN courts on courts.Id = cases.courtid " +
|
||||||
|
"LEFT JOIN clients on clients.Id = cases.clientid";
|
||||||
var cases = connection.Query<Case>(querySelect);
|
var cases = connection.Query<Case>(querySelect);
|
||||||
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
JsonSerializer.Serialize(cases));
|
JsonSerializer.Serialize(cases));
|
||||||
return cases;
|
return cases;
|
||||||
@ -70,7 +74,8 @@ public class CaseRepository : ICaseRepository
|
|||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
connection.Open();
|
connection.Open();
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert = @"INSERT INTO Cases (typeappeal, Payment, Price, victoryprice, Verdict, courtid, clientid, Description, createdat)
|
var queryInsert =
|
||||||
|
@"INSERT INTO Cases (typeappeal, Payment, Price, victoryprice, Verdict, courtid, clientid, Description, createdat)
|
||||||
VALUES (@TypeAppeal, @Payment, @Price, @VictoryPrice, @Verdict, @CourtId, @ClientId, @Description, @CreatedAt);
|
VALUES (@TypeAppeal, @Payment, @Price, @VictoryPrice, @Verdict, @CourtId, @ClientId, @Description, @CreatedAt);
|
||||||
SELECT MAX(Id) FROM cases;";
|
SELECT MAX(Id) FROM cases;";
|
||||||
var caseId =
|
var caseId =
|
||||||
@ -80,9 +85,12 @@ SELECT MAX(Id) FROM cases;";
|
|||||||
VALUES (@CaseId, @AdvocateId, @Post, @CreatedAt)";
|
VALUES (@CaseId, @AdvocateId, @Post, @CreatedAt)";
|
||||||
foreach (var elem in caseEntity.Advocates)
|
foreach (var elem in caseEntity.Advocates)
|
||||||
{
|
{
|
||||||
connection.Execute(querySubInsert, new {
|
connection.Execute(querySubInsert, new
|
||||||
caseId, elem.AdvocateId, elem.Post, elem.CreatedAt }, transaction);
|
{
|
||||||
|
caseId, elem.AdvocateId, elem.Post, elem.CreatedAt
|
||||||
|
}, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -4,6 +4,7 @@ using Dapper;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
using ProjectGSM.Entities;
|
using ProjectGSM.Entities;
|
||||||
|
using ProjectGSM.Query;
|
||||||
|
|
||||||
namespace ProjectGSM.Repositories.Implementations;
|
namespace ProjectGSM.Repositories.Implementations;
|
||||||
|
|
||||||
@ -11,34 +12,50 @@ public class StatusHistoryRepository : IStatusHistoryRepository
|
|||||||
{
|
{
|
||||||
private readonly IConnectionString _connectionString;
|
private readonly IConnectionString _connectionString;
|
||||||
private readonly ILogger<StatusHistoryRepository> _logger;
|
private readonly ILogger<StatusHistoryRepository> _logger;
|
||||||
|
|
||||||
public StatusHistoryRepository(IConnectionString connectionString,
|
public StatusHistoryRepository(IConnectionString connectionString,
|
||||||
ILogger<StatusHistoryRepository> logger)
|
ILogger<StatusHistoryRepository> logger)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
_connectionString = connectionString;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<StatusHistory> ReadStatusHistories(DateTime? dateForm = null, DateTime? dateTo = null,
|
public IEnumerable<StatusHistory> ReadStatusHistories(DateTime? dateForm = null, DateTime? dateTo = null,
|
||||||
int? caseId = null, int? statusId = null)
|
int? caseId = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
var builder = new QueryBuilder();
|
||||||
try
|
if (dateForm.HasValue)
|
||||||
{
|
{
|
||||||
using var connection = new
|
builder.AddCondition("sh.CreatedAt >= @dateForm");
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = "SELECT * FROM status_histories";
|
|
||||||
var statusHistories =
|
|
||||||
connection.Query<StatusHistory>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
|
||||||
JsonSerializer.Serialize(statusHistories));
|
|
||||||
return statusHistories;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
if (dateTo.HasValue)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
builder.AddCondition("sh.CreatedAt <= @dateTo");
|
||||||
throw;
|
}
|
||||||
|
if (caseId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("sh.caseid = @caseId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect =
|
||||||
|
@$"SELECT sh.*, c.description as CaseDescription FROM status_histories as sh LEFT JOIN cases as c ON c.id = sh.caseid{builder.Build()}";
|
||||||
|
var statusHistories =
|
||||||
|
connection.Query<StatusHistory>(querySelect, new { dateForm, dateTo, caseId });
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonSerializer.Serialize(statusHistories));
|
||||||
|
return statusHistories;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void CreateStatusHistory(StatusHistory statusHistory)
|
public void CreateStatusHistory(StatusHistory statusHistory)
|
||||||
{
|
{
|
||||||
@ -59,7 +76,6 @@ public class StatusHistoryRepository : IStatusHistoryRepository
|
|||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteStatusHistory(int statusId, int caseId)
|
public void DeleteStatusHistory(int statusId, int caseId)
|
||||||
|
Loading…
Reference in New Issue
Block a user