Этот комит, почти рабочий комит
This commit is contained in:
parent
e987e043bf
commit
53dce1b1d9
149
PrecastConcretePlant/PrecastConcretePlant/FormReplyMail.Designer.cs
generated
Normal file
149
PrecastConcretePlant/PrecastConcretePlant/FormReplyMail.Designer.cs
generated
Normal file
@ -0,0 +1,149 @@
|
||||
namespace PrecastConcretePlantView
|
||||
{
|
||||
partial class FormReplyMail
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
textBoxHead = new TextBox();
|
||||
textBoxMail = new TextBox();
|
||||
textBoxReply = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(460, 291);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(117, 30);
|
||||
buttonSave.TabIndex = 0;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(337, 291);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(117, 30);
|
||||
buttonCancel.TabIndex = 1;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Location = new Point(12, 9);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(117, 23);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Заголовок письма:";
|
||||
label1.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Location = new Point(12, 38);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(117, 23);
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "Текст письма:";
|
||||
label2.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Location = new Point(12, 117);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(117, 31);
|
||||
label3.TabIndex = 4;
|
||||
label3.Text = "Ответ на письмо:";
|
||||
label3.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// textBoxHead
|
||||
//
|
||||
textBoxHead.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxHead.Location = new Point(135, 5);
|
||||
textBoxHead.Name = "textBoxHead";
|
||||
textBoxHead.ReadOnly = true;
|
||||
textBoxHead.Size = new Size(442, 23);
|
||||
textBoxHead.TabIndex = 5;
|
||||
//
|
||||
// textBoxMail
|
||||
//
|
||||
textBoxMail.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxMail.Location = new Point(135, 35);
|
||||
textBoxMail.Multiline = true;
|
||||
textBoxMail.Name = "textBoxMail";
|
||||
textBoxMail.ReadOnly = true;
|
||||
textBoxMail.Size = new Size(442, 76);
|
||||
textBoxMail.TabIndex = 6;
|
||||
//
|
||||
// textBoxReply
|
||||
//
|
||||
textBoxReply.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxReply.Location = new Point(135, 117);
|
||||
textBoxReply.Multiline = true;
|
||||
textBoxReply.Name = "textBoxReply";
|
||||
textBoxReply.Size = new Size(442, 168);
|
||||
textBoxReply.TabIndex = 7;
|
||||
//
|
||||
// FormReplyMail
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(589, 333);
|
||||
Controls.Add(textBoxReply);
|
||||
Controls.Add(textBoxMail);
|
||||
Controls.Add(textBoxHead);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Name = "FormReplyMail";
|
||||
Text = "Ответ на письмо";
|
||||
Load += FormReplyMail_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxHead;
|
||||
private TextBox textBoxMail;
|
||||
private TextBox textBoxReply;
|
||||
}
|
||||
}
|
83
PrecastConcretePlant/PrecastConcretePlant/FormReplyMail.cs
Normal file
83
PrecastConcretePlant/PrecastConcretePlant/FormReplyMail.cs
Normal file
@ -0,0 +1,83 @@
|
||||
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;
|
||||
using PrecastConcretePlantBusinessLogic.MailWorker;
|
||||
using PrecastConcretePlantContracts.BusinessLogicsContracts;
|
||||
using PrecastConcretePlantContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MimeKit;
|
||||
|
||||
namespace PrecastConcretePlantView
|
||||
{
|
||||
public partial class FormReplyMail : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private MessageInfoViewModel _message;
|
||||
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
public FormReplyMail(ILogger<FormReplyMail> 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 = _message.Subject,
|
||||
Text = textBoxReply.Text,
|
||||
});
|
||||
_logic.Update(new()
|
||||
{
|
||||
MessageId = MessageId,
|
||||
Reply = textBoxReply.Text,
|
||||
HasRead = true,
|
||||
});
|
||||
MessageBox.Show("Успешно отправлено письмо", "Отправка письма", MessageBoxButtons.OK);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormReplyMail_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_message = _logic.ReadElement(new() { MessageId = MessageId });
|
||||
if (_message == null)
|
||||
throw new ArgumentNullException("Письма с таким id не существует");
|
||||
Text += $"для {_message.SenderName}";
|
||||
textBoxHead.Text = _message.Subject;
|
||||
textBoxMail.Text = _message.Body;
|
||||
if (_message.HasRead is false)
|
||||
{
|
||||
_logic.Update(new() { MessageId = MessageId, HasRead = true, Reply = _message.Reply });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения собщения");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
PrecastConcretePlant/PrecastConcretePlant/FormReplyMail.resx
Normal file
60
PrecastConcretePlant/PrecastConcretePlant/FormReplyMail.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>
|
@ -1,62 +1,104 @@
|
||||
namespace PrecastConcretePlantView
|
||||
{
|
||||
partial class FormViewMail
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class FormViewMail
|
||||
{
|
||||
/// <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);
|
||||
}
|
||||
/// <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
|
||||
#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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(803, 450);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// FormViewMail
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormViewMail";
|
||||
Text = "Письма";
|
||||
Load += FormViewMail_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonPrevPage = new Button();
|
||||
buttonNextPage = new Button();
|
||||
labelInfoPages = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(730, 454);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.RowHeaderMouseClick += dataGridView_RowHeaderMouseClick;
|
||||
//
|
||||
// buttonPrevPage
|
||||
//
|
||||
buttonPrevPage.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonPrevPage.Location = new Point(12, 460);
|
||||
buttonPrevPage.Name = "buttonPrevPage";
|
||||
buttonPrevPage.Size = new Size(75, 23);
|
||||
buttonPrevPage.TabIndex = 1;
|
||||
buttonPrevPage.Text = "<<<";
|
||||
buttonPrevPage.UseVisualStyleBackColor = true;
|
||||
buttonPrevPage.Click += ButtonPrevPage_Click;
|
||||
//
|
||||
// buttonNextPage
|
||||
//
|
||||
buttonNextPage.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonNextPage.Location = new Point(203, 460);
|
||||
buttonNextPage.Name = "buttonNextPage";
|
||||
buttonNextPage.Size = new Size(75, 23);
|
||||
buttonNextPage.TabIndex = 2;
|
||||
buttonNextPage.Text = ">>>";
|
||||
buttonNextPage.UseVisualStyleBackColor = true;
|
||||
buttonNextPage.Click += ButtonNextPage_Click;
|
||||
//
|
||||
// labelInfoPages
|
||||
//
|
||||
labelInfoPages.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
labelInfoPages.Location = new Point(93, 464);
|
||||
labelInfoPages.Name = "labelInfoPages";
|
||||
labelInfoPages.Size = new Size(104, 19);
|
||||
labelInfoPages.TabIndex = 3;
|
||||
labelInfoPages.Text = "{0} страница";
|
||||
labelInfoPages.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// FormViewMail
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(727, 498);
|
||||
Controls.Add(labelInfoPages);
|
||||
Controls.Add(buttonNextPage);
|
||||
Controls.Add(buttonPrevPage);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormViewMail";
|
||||
Text = "Письма";
|
||||
Load += FormViewMail_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonPrevPage;
|
||||
private Button buttonNextPage;
|
||||
private Label labelInfoPages;
|
||||
}
|
||||
}
|
@ -10,42 +10,102 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using PrecastConcretePlantContracts.ViewModels;
|
||||
|
||||
namespace PrecastConcretePlantView
|
||||
|
||||
{
|
||||
public partial class FormViewMail : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private int currentPage = 1;
|
||||
public int pageSize = 5;
|
||||
|
||||
public FormViewMail(ILogger<FormViewMail> logger, IMessageInfoLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
public FormViewMail(ILogger<FormViewMail> logger, IMessageInfoLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
buttonPrevPage.Enabled = false;
|
||||
}
|
||||
|
||||
private void FormViewMail_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка писем");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки писем");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void FormViewMail_Load(object sender, EventArgs e)
|
||||
{
|
||||
MailLoad();
|
||||
}
|
||||
|
||||
private bool MailLoad()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(new()
|
||||
{
|
||||
Page = currentPage,
|
||||
PageSize = pageSize,
|
||||
});
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка писем");
|
||||
labelInfoPages.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)
|
||||
{
|
||||
_logger.LogWarning("Неккоректный номер страницы {page}", currentPage - 1);
|
||||
return;
|
||||
}
|
||||
currentPage--;
|
||||
if (MailLoad())
|
||||
{
|
||||
buttonNextPage.Enabled = true;
|
||||
if (currentPage == 1)
|
||||
{
|
||||
buttonPrevPage.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonNextPage_Click(object sender, EventArgs e)
|
||||
{
|
||||
currentPage++;
|
||||
if (!MailLoad() || ((List<MessageInfoViewModel>)dataGridView.DataSource).Count == 0)
|
||||
{
|
||||
_logger.LogWarning("Out of range messages");
|
||||
currentPage--;
|
||||
MailLoad();
|
||||
buttonNextPage.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonPrevPage.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReplyMail));
|
||||
if (service is FormReplyMail form)
|
||||
{
|
||||
form.MessageId = (string)dataGridView.Rows[e.RowIndex].Cells["MessageId"].Value;
|
||||
form.ShowDialog();
|
||||
MailLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ namespace PrecastConcretePlantView
|
||||
services.AddTransient<FormViewImplementers>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormViewMail>();
|
||||
services.AddTransient<FormReplyMail>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
}
|
||||
|
@ -44,5 +44,25 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public bool Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (_messageInfoStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public MessageInfoViewModel? ReadElement(MessageInfoSearchModel model)
|
||||
{
|
||||
var res = _messageInfoStorage.GetElement(model);
|
||||
if (res == null)
|
||||
{
|
||||
_logger.LogWarning("Read element operation failed");
|
||||
return null;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ namespace PrecastConcretePlantClientApp
|
||||
|
||||
public static ClientViewModel? Client { get; set; } = null;
|
||||
|
||||
public static int CurrentPage { get; set; } = 0;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
|
@ -3,6 +3,7 @@ using PrecastConcretePlantClientApp.Models;
|
||||
using PrecastConcretePlantContracts.BindingModels;
|
||||
using PrecastConcretePlantContracts.ViewModels;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace PrecastConcretePlantClientApp.Controllers
|
||||
{
|
||||
@ -144,5 +145,42 @@ namespace PrecastConcretePlantClientApp.Controllers
|
||||
}
|
||||
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client.Id}"));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<string?, string?, bool, bool>? SwitchPage(bool isNext)
|
||||
{
|
||||
if (isNext)
|
||||
{
|
||||
APIClient.CurrentPage++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (APIClient.CurrentPage == 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
APIClient.CurrentPage--;
|
||||
}
|
||||
|
||||
var res = APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client!.Id}&page={APIClient.CurrentPage}");
|
||||
if (isNext && (res == null || res.Count == 0))
|
||||
{
|
||||
APIClient.CurrentPage--;
|
||||
return Tuple.Create<string?, string?, bool, bool>(null, null, APIClient.CurrentPage != 1, false);
|
||||
}
|
||||
|
||||
StringBuilder htmlTable = new();
|
||||
foreach (var mail in res)
|
||||
{
|
||||
htmlTable.Append("<tr>" +
|
||||
$"<td>{mail.DateDelivery}</td>" +
|
||||
$"<td>{mail.Subject}</td>" +
|
||||
$"<td>{mail.Body}</td>" +
|
||||
"<td>" + (mail.HasRead ? "Прочитано" : "Непрочитано") + "</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,80 @@
|
||||
@using PrecastConcretePlantContracts.ViewModels
|
||||
|
||||
@model List<MessageInfoViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Mails";
|
||||
@{
|
||||
ViewData["Title"] = "Mails";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Письма</h1>
|
||||
<h1 class="display-4">Письма</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Дата письма
|
||||
</th>
|
||||
<th>
|
||||
Заголовок
|
||||
</th>
|
||||
<th>
|
||||
Текст
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateDelivery)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Subject)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Body)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Дата письма
|
||||
</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>
|
||||
|
||||
<script>
|
||||
function onClicked(isNext) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/SwitchPage",
|
||||
data: { isNext: isNext },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
if (result.item1 != null && result.item2 != null) {
|
||||
$("#mails-table-body").html(result.item1);
|
||||
$("#current-page").text(result.item2);
|
||||
}
|
||||
if (result.item3)
|
||||
$("#prev-page").removeClass("page-item disabled");
|
||||
else
|
||||
$("#prev-page").addClass("page-item disabled");
|
||||
if (result.item4)
|
||||
$("#next-page").removeClass("page-item disabled");
|
||||
else
|
||||
$("#next-page").addClass("page-item disabled");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Чтобы в первый раз загрузить данные и попасть на первую страницу
|
||||
onClicked(true);
|
||||
$("#prev-page").on('click', () => onClicked(false));
|
||||
$("#next-page").on('click', () => onClicked(true));
|
||||
|
||||
</script>
|
@ -7,6 +7,7 @@
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/PrecastConcretePlantClientApp.styles.css" asp-append-version="true" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
@ -20,5 +20,7 @@ namespace PrecastConcretePlantContracts.BindingModels
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateDelivery { get; set; }
|
||||
public bool HasRead { get; set; }
|
||||
public string? Reply { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,8 @@ namespace PrecastConcretePlantContracts.BusinessLogicsContracts
|
||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||
|
||||
bool Create(MessageInfoBindingModel model);
|
||||
bool Update(MessageInfoBindingModel model);
|
||||
MessageInfoViewModel? ReadElement(MessageInfoSearchModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,8 @@ namespace PrecastConcretePlantContracts.SearchModels
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public string? MessageId { get; set; }
|
||||
public int? Page { get; set; }
|
||||
public int? PageSize { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace PrecastConcretePlantContracts.StoragesContracts
|
||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||
|
||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||
MessageInfoViewModel? Update(MessageInfoBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -25,5 +25,9 @@ namespace PrecastConcretePlantContracts.ViewModels
|
||||
|
||||
[DisplayName("Текст")]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
[DisplayName("Прочитано")]
|
||||
public bool HasRead { get; set; }
|
||||
[DisplayName("Ответ")]
|
||||
public string? Reply { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -19,5 +19,7 @@ namespace PrecastConcretePlantDataModels.Models
|
||||
string Subject { get; }
|
||||
|
||||
string Body { get; }
|
||||
public bool HasRead { get; }
|
||||
public string? Reply { get; }
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,14 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||
{
|
||||
using var context = new PrecastConcretePlantDataBase();
|
||||
return context.Messages
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
var res = context.Messages
|
||||
.Where(x => !model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel);
|
||||
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||
{
|
||||
return res.ToList();
|
||||
}
|
||||
return res.Skip((model.Page.Value - 1) * model.PageSize.Value).Take(model.PageSize.Value).ToList();
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel> GetFullList()
|
||||
@ -53,5 +57,17 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
using var context = new PrecastConcretePlantDataBase();
|
||||
var res = context.Messages.FirstOrDefault(x => x.MessageId.Equals(model.MessageId));
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using PrecastConcretePlantDatabaseImplement;
|
||||
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PrecastConcretePlantDataBase))]
|
||||
[Migration("20230503170550_Lab7Hard")]
|
||||
[Migration("20230503180531_Lab7Hard")]
|
||||
partial class Lab7Hard
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -112,6 +112,12 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("HasRead")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Reply")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
@ -95,7 +95,9 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
HasRead = table.Column<bool>(type: "bit", nullable: false),
|
||||
Reply = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
@ -109,6 +109,12 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("HasRead")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Reply")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
@ -27,6 +27,9 @@ namespace PrecastConcretePlantDatabaseImplement.Models
|
||||
|
||||
public Client? Client { get; private set; }
|
||||
|
||||
public bool HasRead { get; private set; }
|
||||
public string? Reply { get; private set; }
|
||||
|
||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -36,6 +39,8 @@ namespace PrecastConcretePlantDatabaseImplement.Models
|
||||
return new()
|
||||
{
|
||||
Body = model.Body,
|
||||
Reply = model.Reply,
|
||||
HasRead = model.HasRead,
|
||||
Subject = model.Subject,
|
||||
ClientId = model.ClientId,
|
||||
MessageId = model.MessageId,
|
||||
@ -44,9 +49,21 @@ namespace PrecastConcretePlantDatabaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Reply = model.Reply;
|
||||
HasRead = model.HasRead;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
Body = Body,
|
||||
Reply = Reply,
|
||||
HasRead = HasRead,
|
||||
Subject = Subject,
|
||||
ClientId = ClientId,
|
||||
MessageId = MessageId,
|
||||
|
@ -30,10 +30,15 @@ namespace PrecastConcretePlantFileImplement.Implements
|
||||
|
||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||
{
|
||||
return _source.Messages
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
var res = _source.Messages
|
||||
.Where(x => !model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel);
|
||||
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||
{
|
||||
return res.ToList();
|
||||
}
|
||||
return res.Skip((model.Page.Value - 1) * model.PageSize.Value).Take(model.PageSize.Value).ToList();
|
||||
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel> GetFullList()
|
||||
@ -54,5 +59,16 @@ namespace PrecastConcretePlantFileImplement.Implements
|
||||
_source.SaveMessages();
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
var res = _source.Messages.FirstOrDefault(x => x.MessageId.Equals(model.MessageId));
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
_source.SaveMessages();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ namespace PrecastConcretePlantFileImplement.Models
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
public bool HasRead { get; private set; }
|
||||
public string? Reply { get; private set; }
|
||||
|
||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
@ -33,6 +35,8 @@ namespace PrecastConcretePlantFileImplement.Models
|
||||
return new()
|
||||
{
|
||||
Body = model.Body,
|
||||
Reply = model.Reply,
|
||||
HasRead = model.HasRead,
|
||||
Subject = model.Subject,
|
||||
ClientId = model.ClientId,
|
||||
MessageId = model.MessageId,
|
||||
@ -50,6 +54,8 @@ namespace PrecastConcretePlantFileImplement.Models
|
||||
return new()
|
||||
{
|
||||
Body = element.Attribute("Body")!.Value,
|
||||
Reply = element.Attribute("Reply")!.Value,
|
||||
HasRead = Convert.ToBoolean(element.Attribute("HasRead")!.Value),
|
||||
Subject = element.Attribute("Subject")!.Value,
|
||||
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
||||
MessageId = element.Attribute("MessageId")!.Value,
|
||||
@ -58,9 +64,21 @@ namespace PrecastConcretePlantFileImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Reply = model.Reply;
|
||||
HasRead = model.HasRead;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
Body = Body,
|
||||
Reply = Reply,
|
||||
HasRead = HasRead,
|
||||
Subject = Subject,
|
||||
ClientId = ClientId,
|
||||
MessageId = MessageId,
|
||||
@ -70,6 +88,8 @@ namespace PrecastConcretePlantFileImplement.Models
|
||||
|
||||
public XElement GetXElement => new("MessageInfo",
|
||||
new XAttribute("Body", Body),
|
||||
new XAttribute("Reply", Reply),
|
||||
new XAttribute("HasRead", HasRead),
|
||||
new XAttribute("Subject", Subject),
|
||||
new XAttribute("ClientId", ClientId),
|
||||
new XAttribute("MessageId", MessageId),
|
||||
@ -78,3 +98,4 @@ namespace PrecastConcretePlantFileImplement.Models
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,21 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
result.Add(item.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (model.Page * model.PageSize >= result.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MessageInfoViewModel> filteredResult = new();
|
||||
for (var i = (model.Page.Value - 1) * model.PageSize.Value; i < model.Page.Value * model.PageSize.Value; i++)
|
||||
{
|
||||
filteredResult.Add(result[i]);
|
||||
}
|
||||
return filteredResult;
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel> GetFullList()
|
||||
@ -62,5 +76,18 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
_source.Messages.Add(newMessage);
|
||||
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,6 +22,8 @@ namespace PrecastConcretePlantListImplement.Models
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
public bool HasRead { get; private set; }
|
||||
public string? Reply { get; private set; }
|
||||
|
||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
@ -32,6 +34,8 @@ namespace PrecastConcretePlantListImplement.Models
|
||||
return new()
|
||||
{
|
||||
Body = model.Body,
|
||||
Reply = model.Reply,
|
||||
HasRead = model.HasRead,
|
||||
Subject = model.Subject,
|
||||
ClientId = model.ClientId,
|
||||
MessageId = model.MessageId,
|
||||
@ -40,9 +44,21 @@ namespace PrecastConcretePlantListImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Reply = model.Reply;
|
||||
HasRead = model.HasRead;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
Body = Body,
|
||||
Reply = Reply,
|
||||
HasRead = HasRead,
|
||||
Subject = Subject,
|
||||
ClientId = ClientId,
|
||||
MessageId = MessageId,
|
||||
|
@ -14,6 +14,7 @@ namespace PrecastConcretePlantRestApi.Controllers
|
||||
|
||||
private readonly IClientLogic _logic;
|
||||
private readonly IMessageInfoLogic _mailLogic;
|
||||
public int pageSize = 3;
|
||||
|
||||
public ClientController(IClientLogic logic, IMessageInfoLogic mailLogic, ILogger<ClientController> logger)
|
||||
{
|
||||
@ -68,14 +69,17 @@ namespace PrecastConcretePlantRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId)
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _mailLogic.ReadList(new MessageInfoSearchModel
|
||||
return _mailLogic.ReadList(new()
|
||||
{
|
||||
ClientId = clientId
|
||||
ClientId = clientId,
|
||||
Page = page,
|
||||
PageSize = pageSize
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -86,3 +90,4 @@ namespace PrecastConcretePlantRestApi.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user