Compare commits
3 Commits
9a6db9bd9e
...
c0fc48b7e4
Author | SHA1 | Date | |
---|---|---|---|
c0fc48b7e4 | |||
ecfa871e1a | |||
1b57449e73 |
166
LawFirm/LawFirm/FormMail.Designer.cs
generated
Normal file
166
LawFirm/LawFirm/FormMail.Designer.cs
generated
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
namespace LawFirmView
|
||||||
|
{
|
||||||
|
partial class FormMail
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
textBoxHead = new TextBox();
|
||||||
|
textBoxBody = new TextBox();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
label3 = new Label();
|
||||||
|
labelHead = new Label();
|
||||||
|
labelBody = new Label();
|
||||||
|
labelFrom = new Label();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(539, 53);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(84, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Заголовок:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(539, 115);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(104, 20);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Текст письма:";
|
||||||
|
//
|
||||||
|
// textBoxHead
|
||||||
|
//
|
||||||
|
textBoxHead.Location = new Point(547, 85);
|
||||||
|
textBoxHead.Name = "textBoxHead";
|
||||||
|
textBoxHead.Size = new Size(318, 27);
|
||||||
|
textBoxHead.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// textBoxBody
|
||||||
|
//
|
||||||
|
textBoxBody.Location = new Point(547, 138);
|
||||||
|
textBoxBody.Name = "textBoxBody";
|
||||||
|
textBoxBody.Size = new Size(318, 27);
|
||||||
|
textBoxBody.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(664, 230);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(94, 29);
|
||||||
|
buttonCancel.TabIndex = 5;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(771, 230);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(94, 29);
|
||||||
|
buttonSave.TabIndex = 6;
|
||||||
|
buttonSave.Text = "Отправить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(541, 9);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(82, 20);
|
||||||
|
label3.TabIndex = 7;
|
||||||
|
label3.Text = "Ваш ответ:";
|
||||||
|
//
|
||||||
|
// labelHead
|
||||||
|
//
|
||||||
|
labelHead.AutoSize = true;
|
||||||
|
labelHead.Location = new Point(12, 9);
|
||||||
|
labelHead.Name = "labelHead";
|
||||||
|
labelHead.Size = new Size(165, 20);
|
||||||
|
labelHead.TabIndex = 8;
|
||||||
|
labelHead.Text = "Заголовок сообщения";
|
||||||
|
//
|
||||||
|
// labelBody
|
||||||
|
//
|
||||||
|
labelBody.AutoSize = true;
|
||||||
|
labelBody.Location = new Point(12, 53);
|
||||||
|
labelBody.Name = "labelBody";
|
||||||
|
labelBody.Size = new Size(129, 20);
|
||||||
|
labelBody.TabIndex = 9;
|
||||||
|
labelBody.Text = "Текст сообщения";
|
||||||
|
//
|
||||||
|
// labelFrom
|
||||||
|
//
|
||||||
|
labelFrom.AutoSize = true;
|
||||||
|
labelFrom.Location = new Point(12, 234);
|
||||||
|
labelFrom.Name = "labelFrom";
|
||||||
|
labelFrom.Size = new Size(33, 20);
|
||||||
|
labelFrom.TabIndex = 10;
|
||||||
|
labelFrom.Text = "От: ";
|
||||||
|
//
|
||||||
|
// FormMail
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(877, 266);
|
||||||
|
Controls.Add(labelFrom);
|
||||||
|
Controls.Add(labelBody);
|
||||||
|
Controls.Add(labelHead);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(textBoxBody);
|
||||||
|
Controls.Add(textBoxHead);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Name = "FormMail";
|
||||||
|
Text = "Ответ на письмо";
|
||||||
|
Load += FormMail_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private TextBox textBoxHead;
|
||||||
|
private TextBox textBoxBody;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Label label3;
|
||||||
|
private Label labelHead;
|
||||||
|
private Label labelBody;
|
||||||
|
private Label labelFrom;
|
||||||
|
}
|
||||||
|
}
|
81
LawFirm/LawFirm/FormMail.cs
Normal file
81
LawFirm/LawFirm/FormMail.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
using LawFirmBusinessLogic.MailWorker;
|
||||||
|
using LawFirmContracts.BusinessLogicContracts;
|
||||||
|
using LawFirmContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace LawFirmView
|
||||||
|
{
|
||||||
|
public partial class FormMail : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
|
private readonly IMessageInfoLogic _logic;
|
||||||
|
private MessageInfoViewModel _message;
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public FormMail(ILogger<FormMail> logger, AbstractMailWorker mailWorker, IMessageInfoLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_mailWorker = mailWorker;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_mailWorker.MailSendAsync(new()
|
||||||
|
{
|
||||||
|
MailAddress = _message.SenderName,
|
||||||
|
Subject = textBoxHead.Text,
|
||||||
|
Text = textBoxBody.Text,
|
||||||
|
});
|
||||||
|
_logic.Update(new()
|
||||||
|
{
|
||||||
|
MessageId = MessageId,
|
||||||
|
Reply = textBoxBody.Text,
|
||||||
|
IsReaded = true,
|
||||||
|
});
|
||||||
|
MessageBox.Show("Успешно отправлен ответ", "Отправлен ответ", MessageBoxButtons.OK);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMail_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_message = _logic.ReadElement(new() { MessageId = MessageId });
|
||||||
|
if (_message == null) throw new ArgumentNullException("Письма с таким Id не существует");
|
||||||
|
|
||||||
|
labelHead.Text = _message.Subject;
|
||||||
|
labelBody.Text = _message.Body;
|
||||||
|
labelFrom.Text = $"От: {_message.SenderName}";
|
||||||
|
|
||||||
|
if (_message.IsReaded is false)
|
||||||
|
{
|
||||||
|
_logic.Update(new() { MessageId = MessageId, IsReaded = true, Reply = _message.Reply });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения собщения");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
LawFirm/LawFirm/FormMail.resx
Normal file
60
LawFirm/LawFirm/FormMail.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
160
LawFirm/LawFirm/FormMails.Designer.cs
generated
160
LawFirm/LawFirm/FormMails.Designer.cs
generated
@ -1,62 +1,114 @@
|
|||||||
namespace LawFirmView
|
namespace LawFirmView
|
||||||
{
|
{
|
||||||
partial class FormMails
|
partial class FormMails
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
buttonPrevPage = new Button();
|
||||||
SuspendLayout();
|
buttonNextPage = new Button();
|
||||||
//
|
labelPage = new Label();
|
||||||
// dataGridView
|
buttonReply = new Button();
|
||||||
//
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
SuspendLayout();
|
||||||
dataGridView.Location = new Point(12, 12);
|
//
|
||||||
dataGridView.Name = "dataGridView";
|
// dataGridView
|
||||||
dataGridView.RowHeadersWidth = 51;
|
//
|
||||||
dataGridView.RowTemplate.Height = 29;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Size = new Size(776, 426);
|
dataGridView.Location = new Point(12, 12);
|
||||||
dataGridView.TabIndex = 0;
|
dataGridView.Name = "dataGridView";
|
||||||
//
|
dataGridView.RowHeadersWidth = 51;
|
||||||
// FormMails
|
dataGridView.RowTemplate.Height = 29;
|
||||||
//
|
dataGridView.Size = new Size(776, 426);
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
dataGridView.TabIndex = 0;
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
//
|
||||||
ClientSize = new Size(800, 450);
|
// buttonPrevPage
|
||||||
Controls.Add(dataGridView);
|
//
|
||||||
Name = "FormMails";
|
buttonPrevPage.Location = new Point(594, 444);
|
||||||
Text = "Письма";
|
buttonPrevPage.Name = "buttonPrevPage";
|
||||||
Load += FormMails_Load;
|
buttonPrevPage.Size = new Size(94, 29);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
buttonPrevPage.TabIndex = 1;
|
||||||
ResumeLayout(false);
|
buttonPrevPage.Text = "Пред.";
|
||||||
}
|
buttonPrevPage.UseVisualStyleBackColor = true;
|
||||||
|
buttonPrevPage.Click += buttonPrevPage_Click;
|
||||||
|
//
|
||||||
|
// buttonNextPage
|
||||||
|
//
|
||||||
|
buttonNextPage.Location = new Point(694, 444);
|
||||||
|
buttonNextPage.Name = "buttonNextPage";
|
||||||
|
buttonNextPage.Size = new Size(94, 29);
|
||||||
|
buttonNextPage.TabIndex = 2;
|
||||||
|
buttonNextPage.Text = "След.";
|
||||||
|
buttonNextPage.UseVisualStyleBackColor = true;
|
||||||
|
buttonNextPage.Click += buttonNextPage_Click;
|
||||||
|
//
|
||||||
|
// labelPage
|
||||||
|
//
|
||||||
|
labelPage.AutoSize = true;
|
||||||
|
labelPage.Location = new Point(462, 448);
|
||||||
|
labelPage.Name = "labelPage";
|
||||||
|
labelPage.Size = new Size(91, 20);
|
||||||
|
labelPage.TabIndex = 3;
|
||||||
|
labelPage.Text = "Страница: 0";
|
||||||
|
//
|
||||||
|
// buttonReply
|
||||||
|
//
|
||||||
|
buttonReply.Location = new Point(12, 444);
|
||||||
|
buttonReply.Name = "buttonReply";
|
||||||
|
buttonReply.Size = new Size(94, 29);
|
||||||
|
buttonReply.TabIndex = 4;
|
||||||
|
buttonReply.Text = "Ответить";
|
||||||
|
buttonReply.UseVisualStyleBackColor = true;
|
||||||
|
buttonReply.Click += buttonReply_Click;
|
||||||
|
//
|
||||||
|
// FormMails
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 475);
|
||||||
|
Controls.Add(buttonReply);
|
||||||
|
Controls.Add(labelPage);
|
||||||
|
Controls.Add(buttonNextPage);
|
||||||
|
Controls.Add(buttonPrevPage);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormMails";
|
||||||
|
Text = "Письма";
|
||||||
|
Load += FormMails_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
}
|
private Button buttonPrevPage;
|
||||||
|
private Button buttonNextPage;
|
||||||
|
private Label labelPage;
|
||||||
|
private Button buttonReply;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
using LawFirmContracts.BusinessLogicContracts;
|
using LawFirm;
|
||||||
|
using LawFirmContracts.BusinessLogicContracts;
|
||||||
|
using LawFirmContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -12,38 +14,99 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace LawFirmView
|
namespace LawFirmView
|
||||||
{
|
{
|
||||||
public partial class FormMails : Form
|
public partial class FormMails : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IMessageInfoLogic _logic;
|
private readonly IMessageInfoLogic _logic;
|
||||||
|
private int currentPage = 1;
|
||||||
|
public int pageSize = 2;
|
||||||
|
|
||||||
public FormMails(ILogger<FormMails> logger, IMessageInfoLogic logic)
|
public FormMails(ILogger<FormMails> logger, IMessageInfoLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
buttonPrevPage.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void FormMails_Load(object sender, EventArgs e)
|
private void FormMails_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
LoadMail();
|
||||||
{
|
}
|
||||||
var list = _logic.ReadList(null);
|
|
||||||
if (list != null)
|
private bool LoadMail()
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
try
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
{
|
||||||
dataGridView.Columns["MessageId"].Visible = false;
|
var list = _logic.ReadList(new()
|
||||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
{
|
||||||
}
|
Page = currentPage,
|
||||||
_logger.LogInformation("Загрузка писем");
|
PageSize = pageSize,
|
||||||
}
|
});
|
||||||
catch (Exception ex)
|
if (list != null)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки писем");
|
dataGridView.DataSource = list;
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
MessageBoxIcon.Error);
|
dataGridView.Columns["MessageId"].Visible = false;
|
||||||
}
|
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
}
|
_logger.LogInformation("Загрузка писем");
|
||||||
|
labelPage.Text = $"Страница: {currentPage}";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки писем");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonPrevPage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (currentPage == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentPage--;
|
||||||
|
if (LoadMail())
|
||||||
|
{
|
||||||
|
buttonNextPage.Enabled = true;
|
||||||
|
if (currentPage == 1)
|
||||||
|
{
|
||||||
|
buttonPrevPage.Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonNextPage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
currentPage++;
|
||||||
|
if (!LoadMail() || ((List<MessageInfoViewModel>)dataGridView.DataSource).Count == 0)
|
||||||
|
{
|
||||||
|
currentPage--;
|
||||||
|
LoadMail();
|
||||||
|
buttonNextPage.Enabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonPrevPage.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonReply_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
||||||
|
if (service is FormMail form)
|
||||||
|
{
|
||||||
|
form.MessageId = (string)(dataGridView.SelectedRows[0].Cells["MessageId"].Value);
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadMail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ namespace LawFirm
|
|||||||
services.AddTransient<FormImplementers>();
|
services.AddTransient<FormImplementers>();
|
||||||
services.AddTransient<FormImplementer>();
|
services.AddTransient<FormImplementer>();
|
||||||
services.AddTransient<FormMails>();
|
services.AddTransient<FormMails>();
|
||||||
|
services.AddTransient<FormMail>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,18 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
public MessageInfoViewModel? ReadElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
var message = _messageInfoStorage.GetElement(model);
|
||||||
|
if (message == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Read message operation failed");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId} ", model?.MessageId, model?.ClientId);
|
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId} ", model?.MessageId, model?.ClientId);
|
||||||
var list = (model == null) ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
|
var list = (model == null) ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
|
||||||
@ -44,5 +55,15 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public bool Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (_messageInfoStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ namespace LawFirmClientApp
|
|||||||
{
|
{
|
||||||
private static readonly HttpClient _client = new();
|
private static readonly HttpClient _client = new();
|
||||||
public static ClientViewModel? Client { get; set; } = null;
|
public static ClientViewModel? Client { get; set; } = null;
|
||||||
public static void Connect(IConfiguration configuration)
|
public static int CurrentPage { get; set; } = 0;
|
||||||
|
public static void Connect(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
_client.DefaultRequestHeaders.Accept.Clear();
|
_client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
@ -4,6 +4,7 @@ using LawFirmContracts.ViewModels;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace LawFirmClientApp.Controllers
|
namespace LawFirmClientApp.Controllers
|
||||||
{
|
{
|
||||||
@ -136,16 +137,54 @@ namespace LawFirmClientApp.Controllers
|
|||||||
return count * (doc?.Price ?? 1);
|
return count * (doc?.Price ?? 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Mails()
|
public IActionResult Mails()
|
||||||
{
|
{
|
||||||
if (APIClient.Client == null)
|
if (APIClient.Client == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client.Id}"));
|
APIClient.CurrentPage = 0;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public Tuple<string?, string?, bool, bool>? SwitchPage(bool isNext)
|
||||||
|
{
|
||||||
|
if (isNext)
|
||||||
|
{
|
||||||
|
APIClient.CurrentPage++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (APIClient.CurrentPage == 1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
APIClient.CurrentPage--;
|
||||||
|
}
|
||||||
|
|
||||||
|
var messages = APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client!.Id}&pageNum={APIClient.CurrentPage}");
|
||||||
|
if (isNext && (messages == null || messages.Count == 0))
|
||||||
|
{
|
||||||
|
APIClient.CurrentPage--;
|
||||||
|
return Tuple.Create<string?, string?, bool, bool>(null, null, APIClient.CurrentPage != 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder htmlTable = new();
|
||||||
|
foreach (var mail in messages)
|
||||||
|
{
|
||||||
|
htmlTable.Append("<tr>" +
|
||||||
|
$"<td>{mail.DateDelivery}</td>" +
|
||||||
|
$"<td>{mail.Subject}</td>" +
|
||||||
|
$"<td>{mail.Body}</td>" +
|
||||||
|
"<td>" + (mail.IsReaded ? "Прочитано" : "Непрочитано") + "</td>" +
|
||||||
|
$"<td>{mail.Reply}</td>" +
|
||||||
|
"</tr>");
|
||||||
|
}
|
||||||
|
return Tuple.Create<string?, string?, bool, bool>(htmlTable.ToString(), APIClient.CurrentPage.ToString(), APIClient.CurrentPage != 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,54 +1,79 @@
|
|||||||
@using LawFirmContracts.ViewModels
|
@{
|
||||||
|
ViewData["Title"] = "Mails";
|
||||||
@model List<MessageInfoViewModel>
|
|
||||||
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Mails";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h1 class="display-4">Письма</h1>
|
<h1 class="display-4">Письма</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@{
|
<table class="table">
|
||||||
if (Model == null)
|
<thead>
|
||||||
{
|
<tr>
|
||||||
<h3 class="display-4">Авторизируйтесь</h3>
|
<th>
|
||||||
return;
|
Дата
|
||||||
}
|
</th>
|
||||||
|
<th>
|
||||||
|
Заголовок
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Текст
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Прочитано
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Ответ
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="mails-table-body">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<ul class="pagination justify-content-center">
|
||||||
|
<li id="prev-page" class="page-item">
|
||||||
|
<a class="page-link" href="#" aria-label="Previous">
|
||||||
|
<span aria-hidden="true">«</span>
|
||||||
|
<span class="sr-only">Предыдущее</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="page-item">
|
||||||
|
<a id="current-page" class="page-link"></a>
|
||||||
|
</li>
|
||||||
|
<li id="next-page" class="page-item">
|
||||||
|
<a class="page-link" href="#" aria-label="Next">
|
||||||
|
<span aria-hidden="true">»</span>
|
||||||
|
<span class="sr-only">Следующее</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table class="table">
|
<script>
|
||||||
<thead>
|
function onClicked(isNext) {
|
||||||
<tr>
|
$.ajax({
|
||||||
<th>
|
method: "GET",
|
||||||
Дата письма
|
url: "/Home/SwitchPage",
|
||||||
</th>
|
data: { isNext: isNext },
|
||||||
<th>
|
success: function (result) {
|
||||||
Заголовок
|
if (result != null) {
|
||||||
</th>
|
if (result.item1 != null && result.item2 != null) {
|
||||||
<th>
|
$("#mails-table-body").html(result.item1);
|
||||||
Текст
|
$("#current-page").text(result.item2);
|
||||||
</th>
|
}
|
||||||
</tr>
|
if (result.item3)
|
||||||
</thead>
|
$("#prev-page").removeClass("page-item disabled");
|
||||||
<tbody>
|
else
|
||||||
@foreach (var item in Model)
|
$("#prev-page").addClass("page-item disabled");
|
||||||
{
|
if (result.item4)
|
||||||
<tr>
|
$("#next-page").removeClass("page-item disabled");
|
||||||
<td>
|
else
|
||||||
@Html.DisplayFor(modelItem => item.DateDelivery)
|
$("#next-page").addClass("page-item disabled");
|
||||||
</td>
|
}
|
||||||
<td>
|
}
|
||||||
@Html.DisplayFor(modelItem => item.Subject)
|
});
|
||||||
</td>
|
}
|
||||||
<td>
|
onClicked(true);
|
||||||
@Html.DisplayFor(modelItem => item.Body)
|
$("#prev-page").on('click', () => onClicked(false));
|
||||||
</td>
|
$("#next-page").on('click', () => onClicked(true));
|
||||||
</tr>
|
|
||||||
}
|
</script>
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
}
|
|
||||||
</div>
|
|
@ -20,5 +20,7 @@ namespace LawFirmContracts.BindingModels
|
|||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
}
|
public bool IsReaded { get; set; }
|
||||||
|
public string? Reply { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,7 @@ namespace LawFirmContracts.BusinessLogicContracts
|
|||||||
{
|
{
|
||||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||||
bool Create(MessageInfoBindingModel model);
|
bool Create(MessageInfoBindingModel model);
|
||||||
}
|
bool Update(MessageInfoBindingModel model);
|
||||||
|
MessageInfoViewModel? ReadElement(MessageInfoSearchModel model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,7 @@ namespace LawFirmContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
public string? MessageId { get; set; }
|
public string? MessageId { get; set; }
|
||||||
|
public int? Page { get; set; }
|
||||||
|
public int? PageSize { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,6 @@ namespace LawFirmContracts.StorageContracts
|
|||||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||||
}
|
MessageInfoViewModel? Update(MessageInfoBindingModel model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,9 @@ namespace LawFirmContracts.ViewModels
|
|||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
[DisplayName("Текст")]
|
[DisplayName("Текст")]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
}
|
[DisplayName("Прочитано")]
|
||||||
|
public bool IsReaded { get; set; }
|
||||||
|
[DisplayName("Ответ")]
|
||||||
|
public string? Reply { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,7 @@ namespace LawFirmDataModels.Models
|
|||||||
DateTime DateDelivery { get; }
|
DateTime DateDelivery { get; }
|
||||||
string Subject { get; }
|
string Subject { get; }
|
||||||
string Body { get; }
|
string Body { get; }
|
||||||
}
|
public bool IsReaded { get; }
|
||||||
|
public string? Reply { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using LawFirmContracts.SearchModels;
|
|||||||
using LawFirmContracts.StorageContracts;
|
using LawFirmContracts.StorageContracts;
|
||||||
using LawFirmContracts.ViewModels;
|
using LawFirmContracts.ViewModels;
|
||||||
using LawFirmDatabaseImplement.Models;
|
using LawFirmDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -27,10 +28,16 @@ namespace LawFirmDatabaseImplement.Implements
|
|||||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawFirmDatabase();
|
using var context = new LawFirmDatabase();
|
||||||
return context.Messages
|
var messages = context.Messages
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
.Where(x => (model.ClientId == null) || (x.ClientId == model.ClientId))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel);
|
||||||
.ToList();
|
|
||||||
|
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||||
|
{
|
||||||
|
return messages.ToList();
|
||||||
|
}
|
||||||
|
return messages.Skip((model.Page.Value - 1) * model.PageSize.Value).Take(model.PageSize.Value).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageInfoViewModel> GetFullList()
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
@ -53,5 +60,17 @@ namespace LawFirmDatabaseImplement.Implements
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newMessage.GetViewModel;
|
return newMessage.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new LawFirmDatabase();
|
||||||
|
var message = context.Messages.Include(x => x.Client).FirstOrDefault(x => x.MessageId.Equals(model.MessageId));
|
||||||
|
if (message != null)
|
||||||
|
{
|
||||||
|
message.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
return message?.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,6 @@ namespace LawFirmDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new LawFirmDatabase();
|
using var context = new LawFirmDatabase();
|
||||||
|
|
||||||
if (model.ImplementerId != null && model.Status != null)
|
|
||||||
{
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Document)
|
|
||||||
.Include(x => x.Client)
|
|
||||||
.Include(x => x.Implementer)
|
|
||||||
.FirstOrDefault(x => x.Status.Equals(model.Status) && x.ImplementerId.Equals(model.ImplementerId))?.GetViewModel;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Document)
|
.Include(x => x.Document)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
|
381
LawFirm/LawFirmDatabaseImplement/Migrations/20230422091213_MessageInfoUpdate.Designer.cs
generated
Normal file
381
LawFirm/LawFirmDatabaseImplement/Migrations/20230422091213_MessageInfoUpdate.Designer.cs
generated
Normal file
@ -0,0 +1,381 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using LawFirmDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace LawFirmDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(LawFirmDatabase))]
|
||||||
|
[Migration("20230422091213_MessageInfoUpdate")]
|
||||||
|
partial class MessageInfoUpdate
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Blank", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("BlankName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blanks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Document", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("DocumentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Documents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.DocumentBlank", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BlankId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DocumentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("BlankId");
|
||||||
|
|
||||||
|
b.HasIndex("DocumentId");
|
||||||
|
|
||||||
|
b.ToTable("DocumentBlanks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.MessageInfo", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("MessageId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.Property<string>("Body")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int?>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateDelivery")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("IsReaded")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("Reply")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SenderName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Subject")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("MessageId");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("DocumentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("DocumentId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Adress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("MaxCountDocuments")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("OpeningDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Shops");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.ShopDocument", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DocumentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShopId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("DocumentId");
|
||||||
|
|
||||||
|
b.HasIndex("ShopId");
|
||||||
|
|
||||||
|
b.ToTable("ShopDocuments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.DocumentBlank", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Blank", "Blank")
|
||||||
|
.WithMany("DocumentBlanks")
|
||||||
|
.HasForeignKey("BlankId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document")
|
||||||
|
.WithMany("Blanks")
|
||||||
|
.HasForeignKey("DocumentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Blank");
|
||||||
|
|
||||||
|
b.Navigation("Document");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.MessageInfo", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Messages")
|
||||||
|
.HasForeignKey("ClientId");
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("DocumentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Document");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.ShopDocument", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("DocumentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LawFirmDatabaseImplement.Models.Shop", "Shop")
|
||||||
|
.WithMany("Documents")
|
||||||
|
.HasForeignKey("ShopId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Document");
|
||||||
|
|
||||||
|
b.Navigation("Shop");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Blank", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("DocumentBlanks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Messages");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Document", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Blanks");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LawFirmDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Documents");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace LawFirmDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class MessageInfoUpdate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsReaded",
|
||||||
|
table: "Messages",
|
||||||
|
type: "bit",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Reply",
|
||||||
|
table: "Messages",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsReaded",
|
||||||
|
table: "Messages");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Reply",
|
||||||
|
table: "Messages");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -155,6 +155,12 @@ namespace LawFirmDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("DateDelivery")
|
b.Property<DateTime>("DateDelivery")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("IsReaded")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("Reply")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<string>("SenderName")
|
b.Property<string>("SenderName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
@ -26,8 +26,10 @@ namespace LawFirmDatabaseImplement.Models
|
|||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public virtual Client? Client { get; private set; }
|
public virtual Client? Client { get; private set; }
|
||||||
|
public bool IsReaded { get; private set; }
|
||||||
|
public string? Reply { get; private set; }
|
||||||
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -41,10 +43,22 @@ namespace LawFirmDatabaseImplement.Models
|
|||||||
MessageId = model.MessageId,
|
MessageId = model.MessageId,
|
||||||
SenderName = model.SenderName,
|
SenderName = model.SenderName,
|
||||||
DateDelivery = model.DateDelivery,
|
DateDelivery = model.DateDelivery,
|
||||||
};
|
IsReaded = model.IsReaded,
|
||||||
|
Reply = model.Reply
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public void Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Reply = model.Reply;
|
||||||
|
IsReaded = model.IsReaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Body = Body,
|
Body = Body,
|
||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
@ -52,7 +66,9 @@ namespace LawFirmDatabaseImplement.Models
|
|||||||
MessageId = MessageId,
|
MessageId = MessageId,
|
||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
Reply = Reply,
|
||||||
|
IsReaded = IsReaded,
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,15 @@ namespace LawFirmFileImplement.Implements
|
|||||||
|
|
||||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
return _source.Messages
|
var messages = _source.Messages
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel);
|
||||||
.ToList();
|
|
||||||
|
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||||
|
{
|
||||||
|
return messages.ToList();
|
||||||
|
}
|
||||||
|
return messages.Skip((model.Page.Value - 1) * model.PageSize.Value).Take(model.PageSize.Value).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageInfoViewModel> GetFullList()
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
@ -54,5 +59,16 @@ namespace LawFirmFileImplement.Implements
|
|||||||
_source.SaveMessages();
|
_source.SaveMessages();
|
||||||
return newMessage.GetViewModel;
|
return newMessage.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
var message = _source.Messages.FirstOrDefault(x => x.MessageId.Equals(model.MessageId));
|
||||||
|
if (message != null)
|
||||||
|
{
|
||||||
|
message.Update(model);
|
||||||
|
_source.SaveMessages();
|
||||||
|
}
|
||||||
|
return message?.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,10 @@ namespace LawFirmFileImplement.Models
|
|||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
public bool IsReaded { get; private set; }
|
||||||
|
public string? Reply { get; private set; }
|
||||||
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -38,7 +40,9 @@ namespace LawFirmFileImplement.Models
|
|||||||
MessageId = model.MessageId,
|
MessageId = model.MessageId,
|
||||||
SenderName = model.SenderName,
|
SenderName = model.SenderName,
|
||||||
DateDelivery = model.DateDelivery,
|
DateDelivery = model.DateDelivery,
|
||||||
};
|
Reply = model.Reply,
|
||||||
|
IsReaded = model.IsReaded,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageInfo? Create(XElement element)
|
public static MessageInfo? Create(XElement element)
|
||||||
@ -55,10 +59,22 @@ namespace LawFirmFileImplement.Models
|
|||||||
MessageId = element.Attribute("MessageId")!.Value,
|
MessageId = element.Attribute("MessageId")!.Value,
|
||||||
SenderName = element.Attribute("SenderName")!.Value,
|
SenderName = element.Attribute("SenderName")!.Value,
|
||||||
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
||||||
};
|
Reply = element.Attribute("Reply")!.Value,
|
||||||
|
IsReaded = Convert.ToBoolean(element.Attribute("IsReaded")!.Value),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public void Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Reply = model.Reply;
|
||||||
|
IsReaded = model.IsReaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Body = Body,
|
Body = Body,
|
||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
@ -66,7 +82,9 @@ namespace LawFirmFileImplement.Models
|
|||||||
MessageId = MessageId,
|
MessageId = MessageId,
|
||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
Reply = Reply,
|
||||||
|
IsReaded = IsReaded,
|
||||||
|
};
|
||||||
|
|
||||||
public XElement GetXElement => new("MessageInfo",
|
public XElement GetXElement => new("MessageInfo",
|
||||||
new XAttribute("Body", Body),
|
new XAttribute("Body", Body),
|
||||||
@ -74,7 +92,9 @@ namespace LawFirmFileImplement.Models
|
|||||||
new XAttribute("ClientId", ClientId),
|
new XAttribute("ClientId", ClientId),
|
||||||
new XAttribute("MessageId", MessageId),
|
new XAttribute("MessageId", MessageId),
|
||||||
new XAttribute("SenderName", SenderName),
|
new XAttribute("SenderName", SenderName),
|
||||||
new XAttribute("DateDelivery", DateDelivery)
|
new XAttribute("DateDelivery", DateDelivery),
|
||||||
);
|
new XAttribute("Reply", Reply),
|
||||||
|
new XAttribute("HasRead", IsReaded)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,15 +30,29 @@ namespace LawFirmListImplements.Implements
|
|||||||
|
|
||||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
List<MessageInfoViewModel> result = new();
|
List<MessageInfoViewModel> messages = new();
|
||||||
foreach (var item in _source.Messages)
|
foreach (var item in _source.Messages)
|
||||||
{
|
{
|
||||||
if (item.ClientId.HasValue && item.ClientId == model.ClientId)
|
if (item.ClientId == model.ClientId)
|
||||||
{
|
{
|
||||||
result.Add(item.GetViewModel);
|
messages.Add(item.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||||
|
{
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
if (model.Page * model.PageSize >= messages.Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<MessageInfoViewModel> filterMessages = new();
|
||||||
|
for (var i = (model.Page.Value - 1) * model.PageSize.Value; i < model.Page.Value * model.PageSize.Value; i++)
|
||||||
|
{
|
||||||
|
filterMessages.Add(messages[i]);
|
||||||
|
}
|
||||||
|
return filterMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageInfoViewModel> GetFullList()
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
@ -61,5 +75,18 @@ namespace LawFirmListImplements.Implements
|
|||||||
_source.Messages.Add(newMessage);
|
_source.Messages.Add(newMessage);
|
||||||
return newMessage.GetViewModel;
|
return newMessage.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var message in _source.Messages)
|
||||||
|
{
|
||||||
|
if (message.MessageId.Equals(model.MessageId))
|
||||||
|
{
|
||||||
|
message.Update(model);
|
||||||
|
return message.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,10 @@ namespace LawFirmListImplements.Models
|
|||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
public bool IsReaded { get; private set; }
|
||||||
|
public string? Reply { get; private set; }
|
||||||
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -37,10 +39,22 @@ namespace LawFirmListImplements.Models
|
|||||||
MessageId = model.MessageId,
|
MessageId = model.MessageId,
|
||||||
SenderName = model.SenderName,
|
SenderName = model.SenderName,
|
||||||
DateDelivery = model.DateDelivery,
|
DateDelivery = model.DateDelivery,
|
||||||
};
|
Reply = model.Reply,
|
||||||
|
IsReaded = model.IsReaded,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public void Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Reply = model.Reply;
|
||||||
|
IsReaded = model.IsReaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Body = Body,
|
Body = Body,
|
||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
@ -48,7 +62,9 @@ namespace LawFirmListImplements.Models
|
|||||||
MessageId = MessageId,
|
MessageId = MessageId,
|
||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
Reply = Reply,
|
||||||
|
IsReaded = IsReaded,
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,9 @@ namespace LawFirmRestApi.Controllers
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IClientLogic _logic;
|
private readonly IClientLogic _logic;
|
||||||
private readonly IMessageInfoLogic _mailLogic;
|
private readonly IMessageInfoLogic _mailLogic;
|
||||||
|
public int pageSize = 2;
|
||||||
|
|
||||||
public ClientController(IClientLogic logic, IMessageInfoLogic mailLogic, ILogger<ClientController> logger)
|
public ClientController(IClientLogic logic, IMessageInfoLogic mailLogic, ILogger<ClientController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
@ -65,14 +66,16 @@ namespace LawFirmRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<MessageInfoViewModel>? GetMessages(int clientId)
|
public List<MessageInfoViewModel>? GetMessages(int clientId, int pageNum)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _mailLogic.ReadList(new MessageInfoSearchModel
|
return _mailLogic.ReadList(new()
|
||||||
{
|
{
|
||||||
ClientId = clientId
|
ClientId = clientId,
|
||||||
});
|
Page = pageNum,
|
||||||
|
PageSize = pageSize
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user