Complete lab 7 hard
This commit is contained in:
parent
d20613c3bb
commit
3ba1703499
29
SushiBar/SushiBar/FormMails.Designer.cs
generated
29
SushiBar/SushiBar/FormMails.Designer.cs
generated
@ -29,6 +29,8 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.PrevButton = new System.Windows.Forms.Button();
|
||||
this.NextButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -40,12 +42,35 @@
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(776, 426);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
this.dataGridView.RowHeaderMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DataGridView_RowHeaderMouseDoubleClick);
|
||||
//
|
||||
// PrevButton
|
||||
//
|
||||
this.PrevButton.Location = new System.Drawing.Point(794, 415);
|
||||
this.PrevButton.Name = "PrevButton";
|
||||
this.PrevButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.PrevButton.TabIndex = 1;
|
||||
this.PrevButton.Text = "<";
|
||||
this.PrevButton.UseVisualStyleBackColor = true;
|
||||
this.PrevButton.Click += new System.EventHandler(this.PrevButton_Click);
|
||||
//
|
||||
// NextButton
|
||||
//
|
||||
this.NextButton.Location = new System.Drawing.Point(794, 386);
|
||||
this.NextButton.Name = "NextButton";
|
||||
this.NextButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.NextButton.TabIndex = 2;
|
||||
this.NextButton.Text = ">";
|
||||
this.NextButton.UseVisualStyleBackColor = true;
|
||||
this.NextButton.Click += new System.EventHandler(this.NextButton_Click);
|
||||
//
|
||||
// FormMails
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.ClientSize = new System.Drawing.Size(882, 450);
|
||||
this.Controls.Add(this.NextButton);
|
||||
this.Controls.Add(this.PrevButton);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormMails";
|
||||
this.Text = "FormMails";
|
||||
@ -58,5 +83,7 @@
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button PrevButton;
|
||||
private Button NextButton;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
@ -7,6 +9,8 @@ namespace SushiBar
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private int page = 1;
|
||||
private int pageSize = 3;
|
||||
|
||||
public FormMails(ILogger<FormMails> logger, IMessageInfoLogic logic)
|
||||
{
|
||||
@ -14,18 +18,25 @@ namespace SushiBar
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
LoadData();
|
||||
PrevButton.Enabled = false;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
var list = _logic.ReadList(new MessageInfoSearchModel
|
||||
{
|
||||
Page = page,
|
||||
PageSize = pageSize,
|
||||
});
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["Reply"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Load mails");
|
||||
@ -41,5 +52,45 @@ namespace SushiBar
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void NextButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
page++;
|
||||
LoadData();
|
||||
if (((List<MessageInfoViewModel>)dataGridView.DataSource).Count == 0)
|
||||
{
|
||||
_logger.LogWarning("Out of range messages");
|
||||
page--;
|
||||
NextButton.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrevButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void PrevButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (page == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
page--;
|
||||
LoadData();
|
||||
NextButton.Enabled = true;
|
||||
if (page == 1)
|
||||
{
|
||||
PrevButton.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReplyMail));
|
||||
if (service is not FormReplyMail form) return;
|
||||
form.MessageId = (string)dataGridView.Rows[e.RowIndex].Cells["MessageId"].Value;
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
122
SushiBar/SushiBar/FormReplyMail.Designer.cs
generated
Normal file
122
SushiBar/SushiBar/FormReplyMail.Designer.cs
generated
Normal file
@ -0,0 +1,122 @@
|
||||
namespace SushiBar
|
||||
{
|
||||
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()
|
||||
{
|
||||
this.labelClient = new System.Windows.Forms.Label();
|
||||
this.labelOrder = new System.Windows.Forms.Label();
|
||||
this.ReplyText = new System.Windows.Forms.RichTextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.buttonReply = new System.Windows.Forms.Button();
|
||||
this.buttonClose = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelClient
|
||||
//
|
||||
this.labelClient.AutoSize = true;
|
||||
this.labelClient.Location = new System.Drawing.Point(12, 9);
|
||||
this.labelClient.Name = "labelClient";
|
||||
this.labelClient.Size = new System.Drawing.Size(38, 15);
|
||||
this.labelClient.TabIndex = 0;
|
||||
this.labelClient.Text = "label1";
|
||||
//
|
||||
// labelOrder
|
||||
//
|
||||
this.labelOrder.AutoSize = true;
|
||||
this.labelOrder.Location = new System.Drawing.Point(12, 38);
|
||||
this.labelOrder.Name = "labelOrder";
|
||||
this.labelOrder.Size = new System.Drawing.Size(38, 15);
|
||||
this.labelOrder.TabIndex = 1;
|
||||
this.labelOrder.Text = "label2";
|
||||
//
|
||||
// ReplyText
|
||||
//
|
||||
this.ReplyText.Location = new System.Drawing.Point(12, 88);
|
||||
this.ReplyText.Name = "ReplyText";
|
||||
this.ReplyText.Size = new System.Drawing.Size(776, 315);
|
||||
this.ReplyText.TabIndex = 2;
|
||||
this.ReplyText.Text = "";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 70);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(59, 15);
|
||||
this.label3.TabIndex = 3;
|
||||
this.label3.Text = "Reply text";
|
||||
//
|
||||
// buttonReply
|
||||
//
|
||||
this.buttonReply.Location = new System.Drawing.Point(12, 415);
|
||||
this.buttonReply.Name = "buttonReply";
|
||||
this.buttonReply.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonReply.TabIndex = 4;
|
||||
this.buttonReply.Text = "Reply";
|
||||
this.buttonReply.UseVisualStyleBackColor = true;
|
||||
this.buttonReply.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonClose
|
||||
//
|
||||
this.buttonClose.Location = new System.Drawing.Point(93, 415);
|
||||
this.buttonClose.Name = "buttonClose";
|
||||
this.buttonClose.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonClose.TabIndex = 5;
|
||||
this.buttonClose.Text = "Close";
|
||||
this.buttonClose.UseVisualStyleBackColor = true;
|
||||
this.buttonClose.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormReplyMail
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonClose);
|
||||
this.Controls.Add(this.buttonReply);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.ReplyText);
|
||||
this.Controls.Add(this.labelOrder);
|
||||
this.Controls.Add(this.labelClient);
|
||||
this.Name = "FormReplyMail";
|
||||
this.Text = "FormReplyMail";
|
||||
this.Load += new System.EventHandler(this.FormReplyMail_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelClient;
|
||||
private Label labelOrder;
|
||||
private RichTextBox ReplyText;
|
||||
private Label label3;
|
||||
private Button buttonReply;
|
||||
private Button buttonClose;
|
||||
}
|
||||
}
|
80
SushiBar/SushiBar/FormReplyMail.cs
Normal file
80
SushiBar/SushiBar/FormReplyMail.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarBusinessLogic.MailWorker;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
namespace SushiBar
|
||||
{
|
||||
public partial class FormReplyMail : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private MessageInfoViewModel? _message = null;
|
||||
|
||||
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 MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = _message.SenderName,
|
||||
Subject = _message.Subject,
|
||||
Text = ReplyText.Text,
|
||||
});
|
||||
_logic.Update(new MessageInfoBindingModel
|
||||
{
|
||||
MessageId = MessageId,
|
||||
Reply = ReplyText.Text,
|
||||
IsRead = true,
|
||||
});
|
||||
MessageBox.Show("Mail sended", "Sending mail", MessageBoxButtons.OK);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormReplyMail_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_message = _logic.ReadElement(new MessageInfoSearchModel
|
||||
{
|
||||
MessageId = MessageId
|
||||
});
|
||||
Text += $"For {_message.SenderName}";
|
||||
labelClient.Text = _message.Subject;
|
||||
labelOrder.Text = _message.Body;
|
||||
if (!_message.IsRead)
|
||||
{
|
||||
_logic.Update(new MessageInfoBindingModel
|
||||
{
|
||||
MessageId = MessageId,
|
||||
IsRead = true,
|
||||
Reply = _message.Reply
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
SushiBar/SushiBar/FormReplyMail.resx
Normal file
60
SushiBar/SushiBar/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>
|
@ -10,8 +10,8 @@ using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarDatabaseImplement.Implements;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
namespace SushiBar;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
@ -104,8 +104,8 @@ namespace SushiBar
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormMails>();
|
||||
services.AddTransient<FormReplyMail>();
|
||||
}
|
||||
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
}
|
@ -28,13 +28,29 @@ public class MessageInfoLogic : IMessageInfoLogic
|
||||
|
||||
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId} ",
|
||||
_logger.LogInformation("ReadList. MessageId:{MessageId} .ClientId:{ClientId} .Page:{Page}",
|
||||
model?.MessageId,
|
||||
model?.ClientId);
|
||||
model?.ClientId,
|
||||
model.Page);
|
||||
var list = model == null ? _messageStorage.GetFullList() : _messageStorage.GetFilteredList(model);
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (_messageStorage.Update(model) != null) return true;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? ReadElement(MessageInfoSearchModel model)
|
||||
{
|
||||
var res = _messageStorage.GetElement(model);
|
||||
if (res != null) return res;
|
||||
_logger.LogWarning("Read element operation failed");
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarBusinessLogic.MailWorker;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
@ -19,7 +19,6 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger,
|
||||
IOrderStorage orderStorage,
|
||||
IStoreLogic storeLogic,
|
||||
ISushiStorage sushiStorage,
|
||||
IOrderStorage orderStorage,
|
||||
|
@ -151,13 +151,16 @@ namespace SushiBarClientApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Mails()
|
||||
public IActionResult Mails(int page=1)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/GetMessages?clientId={APIClient.Client.Id}"));
|
||||
return View(APIClient
|
||||
.GetRequest<List<MessageInfoViewModel>>(
|
||||
$"api/client/GetMessages?clientId={APIClient.Client.Id}&page={page}"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
ViewData["Title"] = "Mails";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
<h1 class="display-4">Mail</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
@ -16,13 +16,13 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Дата письма
|
||||
Date
|
||||
</th>
|
||||
<th>
|
||||
Заголовок
|
||||
Title
|
||||
</th>
|
||||
<th>
|
||||
Текст
|
||||
Text
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -47,4 +47,48 @@
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" id="prev">Previous</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" id="next">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<script>
|
||||
const url = document.location.href;
|
||||
const urlPart1 = url.split('=')[0];
|
||||
const urlParameter = url.split('=')[1];
|
||||
let parameter = parseInt(urlParameter);
|
||||
|
||||
const go = () => {
|
||||
window.location.href = window.location.protocol + "//" + window.location.host + `/Home/Mails?page=${parameter}`
|
||||
}
|
||||
|
||||
const paginationNext = document.getElementById("next")
|
||||
paginationNext.onclick = (e) => {
|
||||
e.preventDefault();
|
||||
if (isNaN(parameter)) {
|
||||
parameter = 1
|
||||
}
|
||||
parameter++;
|
||||
go();
|
||||
}
|
||||
|
||||
const paginationPrev = document.getElementById("prev")
|
||||
|
||||
if (isNaN(parameter) || parameter === 1) {
|
||||
paginationPrev.parentElement.classList.add("disabled");
|
||||
}
|
||||
|
||||
paginationPrev.onclick = (e) => {
|
||||
e.preventDefault();
|
||||
parameter--;
|
||||
if (parameter <= 0)
|
||||
parameter = 1
|
||||
go();
|
||||
}
|
||||
</script>
|
@ -10,4 +10,6 @@ public class MessageInfoBindingModel : IMessageInfoModel
|
||||
public DateTime DateDelivery { get; set; }
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Body { get; set; } = string.Empty;
|
||||
public bool IsRead { get; set; }
|
||||
public string? Reply { get; set; }
|
||||
}
|
@ -8,4 +8,6 @@ public interface IMessageInfoLogic
|
||||
{
|
||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||
bool Create(MessageInfoBindingModel model);
|
||||
bool Update(MessageInfoBindingModel model);
|
||||
MessageInfoViewModel? ReadElement(MessageInfoSearchModel model);
|
||||
}
|
@ -4,4 +4,6 @@ public class MessageInfoSearchModel
|
||||
{
|
||||
public string? MessageId { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public int? Page { get; set; }
|
||||
public int? PageSize { get; set; }
|
||||
}
|
@ -10,4 +10,5 @@ public interface IMessageInfoStorage
|
||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||
MessageInfoViewModel? Update(MessageInfoBindingModel model);
|
||||
}
|
@ -13,4 +13,6 @@ public class MessageInfoViewModel : IMessageInfoModel
|
||||
public DateTime DateDelivery { get; set; }
|
||||
public string Subject { get; set; }
|
||||
public string Body { get; set; }
|
||||
public bool IsRead { get; set; }
|
||||
public string? Reply { get; set; }
|
||||
}
|
@ -18,13 +18,14 @@ public class MessageStorage : IMessageInfoStorage
|
||||
|
||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||
{
|
||||
if (!model.ClientId.HasValue)
|
||||
return new List<MessageInfoViewModel>();
|
||||
using var context = new SushiBarDatabase();
|
||||
return context.Messages
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
var res = context.Messages
|
||||
.Where(x => !model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return model is not { Page: { }, PageSize: { } } ?
|
||||
res.ToList() :
|
||||
res.Skip((model.Page.Value - 1) * model.PageSize.Value).Take(model.PageSize.Value).ToList();
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel> GetFullList()
|
||||
@ -47,4 +48,14 @@ public class MessageStorage : IMessageInfoStorage
|
||||
context.SaveChanges();
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
var res = context.Messages.FirstOrDefault(x => x.MessageId.Equals(model.MessageId));
|
||||
if (res == null) return res?.GetViewModel;
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
@ -1,251 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using SushiBarDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SushiBarDatabase))]
|
||||
[Migration("20230410100751_lab6")]
|
||||
partial class lab6
|
||||
{
|
||||
/// <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("SushiBarDatabaseImplement.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("SushiBarDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.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("SushiBarDatabaseImplement.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?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SushiId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("SushiName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("SushiId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("SushiName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Sushi");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SushiId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("SushiId");
|
||||
|
||||
b.ToTable("SushiComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany()
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SushiId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Sushi");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiComponent", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("SushiComponent")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("SushiId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Sushi");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("SushiComponent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class lab6 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ImplementerId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFio = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId",
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ImplementerId",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,290 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using SushiBarDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SushiBarDatabase))]
|
||||
[Migration("20230423155623_lab7")]
|
||||
partial class lab7
|
||||
{
|
||||
/// <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("SushiBarDatabaseImplement.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("SushiBarDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.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("SushiBarDatabaseImplement.Models.Message", 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<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("SushiBarDatabaseImplement.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?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SushiId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("SushiName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("SushiId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("SushiName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Sushi");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SushiId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("SushiId");
|
||||
|
||||
b.ToTable("SushiComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Message", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany()
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SushiId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Sushi");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiComponent", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("SushiComponent")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("SushiId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Sushi");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("SushiComponent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class lab7 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true),
|
||||
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)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Messages_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Messages_ClientId",
|
||||
table: "Messages",
|
||||
column: "ClientId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Messages");
|
||||
}
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ using SushiBarDatabaseImplement;
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SushiBarDatabase))]
|
||||
[Migration("20230425050030_lab5hard")]
|
||||
partial class lab5hard
|
||||
[Migration("20230504200506_lab7Hard")]
|
||||
partial class lab7Hard
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -97,6 +97,42 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Message", 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>("IsRead")
|
||||
.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("SushiBarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -117,6 +153,9 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -134,6 +173,8 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("SushiId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
@ -209,7 +250,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Sushi");
|
||||
b.ToTable("Sushis");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiComponent", b =>
|
||||
@ -255,6 +296,10 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany()
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SushiId")
|
||||
@ -263,6 +308,8 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Sushi");
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class lab5hard : Migration
|
||||
public partial class lab7Hard : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@ -40,6 +40,22 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFio = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Stores",
|
||||
columns: table => new
|
||||
@ -57,7 +73,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Sushi",
|
||||
name: "Sushis",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
@ -67,7 +83,30 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Sushi", x => x.Id);
|
||||
table.PrimaryKey("PK_Sushis", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true),
|
||||
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),
|
||||
IsRead = table.Column<bool>(type: "bit", nullable: false),
|
||||
Reply = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Messages_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -78,6 +117,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SushiId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
ImplementerId = table.Column<int>(type: "int", nullable: true),
|
||||
SushiName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
@ -95,9 +135,14 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Sushi_SushiId",
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
column: x => x.ImplementerId,
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Sushis_SushiId",
|
||||
column: x => x.SushiId,
|
||||
principalTable: "Sushi",
|
||||
principalTable: "Sushis",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -122,9 +167,9 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_StoreSushis_Sushi_SushiId",
|
||||
name: "FK_StoreSushis_Sushis_SushiId",
|
||||
column: x => x.SushiId,
|
||||
principalTable: "Sushi",
|
||||
principalTable: "Sushis",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -149,18 +194,28 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SushiComponents_Sushi_SushiId",
|
||||
name: "FK_SushiComponents_Sushis_SushiId",
|
||||
column: x => x.SushiId,
|
||||
principalTable: "Sushi",
|
||||
principalTable: "Sushis",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Messages_ClientId",
|
||||
table: "Messages",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_SushiId",
|
||||
table: "Orders",
|
||||
@ -190,6 +245,9 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Messages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
@ -202,6 +260,9 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Stores");
|
||||
|
||||
@ -209,7 +270,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Sushi");
|
||||
name: "Sushis");
|
||||
}
|
||||
}
|
||||
}
|
@ -94,6 +94,42 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Message", 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>("IsRead")
|
||||
.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("SushiBarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -240,6 +276,15 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
b.ToTable("SushiComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Message", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
|
||||
|
@ -18,6 +18,8 @@ public class Message : IMessageInfoModel
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
public bool IsRead { get; private set; }
|
||||
public string? Reply { get; private set; }
|
||||
|
||||
public virtual Client Client { get; set; }
|
||||
|
||||
@ -38,6 +40,16 @@ public class Message : IMessageInfoModel
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Reply = model.Reply;
|
||||
IsRead = model.IsRead;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
Body = Body,
|
||||
|
@ -50,4 +50,9 @@ public class MessageInfoStorage : IMessageInfoStorage
|
||||
source.SaveMessages();
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -66,4 +66,8 @@ public class Message : IMessageInfoModel
|
||||
new XAttribute("SenderName", SenderName),
|
||||
new XAttribute("DateDelivery", DateDelivery)
|
||||
);
|
||||
|
||||
public bool IsRead => throw new NotImplementedException();
|
||||
|
||||
public string? Reply => throw new NotImplementedException();
|
||||
}
|
@ -8,4 +8,6 @@ public interface IMessageInfoModel
|
||||
DateTime DateDelivery { get; }
|
||||
string Subject { get; }
|
||||
string Body { get; }
|
||||
bool IsRead { get; }
|
||||
string? Reply { get; }
|
||||
}
|
@ -69,13 +69,15 @@ public class ClientController : Controller
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId)
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _mailLogic.ReadList(new MessageInfoSearchModel
|
||||
{
|
||||
ClientId = clientId
|
||||
ClientId = clientId,
|
||||
Page = page,
|
||||
PageSize = 3
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -59,4 +59,9 @@ public class MessageInfoStorage : IMessageInfoStorage
|
||||
_source.Messages.Add(newMessage);
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -39,4 +39,8 @@ public class Message : IMessageInfoModel
|
||||
ClientId = ClientId,
|
||||
MessageId = MessageId
|
||||
};
|
||||
|
||||
public bool IsRead => throw new NotImplementedException();
|
||||
|
||||
public string? Reply => throw new NotImplementedException();
|
||||
}
|
Loading…
Reference in New Issue
Block a user