fix
This commit is contained in:
parent
6e3d43e265
commit
f0f89c2720
@ -46,7 +46,7 @@ namespace GiftShopBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. ClientFIO:{ClientFIO}. Id:{ Id}", model.ClientFIO, model.Id);
|
_logger.LogInformation("ReadElement. ClientFIO:{ClientFIO}. Email: {Email}. Id:{ Id}", model.ClientFIO, model.Email, model.Id);
|
||||||
var element = _clientStorage.GetElement(model);
|
var element = _clientStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ namespace GiftShopBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ClientFIO:{ClientFIO}. Id:{Id}", model?.ClientFIO, model?.Id);
|
_logger.LogInformation("ReadList. ClientFIO: {ClientName}. Email: {Email}. Id: {Id}.", model?.ClientFIO, model?.Email, model?.Id);
|
||||||
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
@ -100,13 +100,13 @@ namespace GiftShopBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Password))
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("У клиента отсутствует пароль", nameof(model.Email));
|
throw new ArgumentNullException("У клиента отсутствует пароль", nameof(model.Password));
|
||||||
}
|
}
|
||||||
if (!Regex.IsMatch(model.Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
|
if (!Regex.IsMatch(model.Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$", RegexOptions.IgnoreCase))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Неправильно введенный email", nameof(model.Email));
|
throw new ArgumentException("Неправильно введенный email", nameof(model.Email));
|
||||||
}
|
}
|
||||||
if (!Regex.IsMatch(model.Password, @"^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$") || model.Password.Length < 10 || model.Password.Length > 50)
|
if (model.Password.Length < 10 || model.Password.Length > 50)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Неправильно введенный пароль", nameof(model.Password));
|
throw new ArgumentException("Неправильно введенный пароль", nameof(model.Password));
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,14 @@ namespace GiftShopBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
|
|
||||||
model.Status = OrderStatus.Принят;
|
model.Status = OrderStatus.Принят;
|
||||||
|
var result = _orderStorage.Insert(model);
|
||||||
if (_orderStorage.Insert(model) == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
model.Status = OrderStatus.Неизвестен;
|
model.Status = OrderStatus.Неизвестен;
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SendOrderMessage(result.ClientId, $"Магазин подарков, Заказ №{result.Id}", $"Заказ №{result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +79,15 @@ namespace GiftShopBusinessLogic.BusinessLogics
|
|||||||
model.Sum = vmodel.Sum;
|
model.Sum = vmodel.Sum;
|
||||||
model.Count = vmodel.Count;
|
model.Count = vmodel.Count;
|
||||||
|
|
||||||
if (_orderStorage.Update(model) == null)
|
var result = _orderStorage.Update(model);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SendOrderMessage(result.ClientId, $"Магазин подарков, Заказ №{result.Id}", $"Заказ №{model.Id} изменен статус на {result.Status}");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
32
GiftShop/GiftShopView/FormCreateOrder.Designer.cs
generated
32
GiftShop/GiftShopView/FormCreateOrder.Designer.cs
generated
@ -36,6 +36,8 @@
|
|||||||
textBoxSum = new TextBox();
|
textBoxSum = new TextBox();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
|
labelClient = new Label();
|
||||||
|
comboBoxClient = new ComboBox();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelGift
|
// labelGift
|
||||||
@ -50,7 +52,7 @@
|
|||||||
// labelCount
|
// labelCount
|
||||||
//
|
//
|
||||||
labelCount.AutoSize = true;
|
labelCount.AutoSize = true;
|
||||||
labelCount.Location = new Point(34, 112);
|
labelCount.Location = new Point(34, 138);
|
||||||
labelCount.Name = "labelCount";
|
labelCount.Name = "labelCount";
|
||||||
labelCount.Size = new Size(93, 20);
|
labelCount.Size = new Size(93, 20);
|
||||||
labelCount.TabIndex = 1;
|
labelCount.TabIndex = 1;
|
||||||
@ -59,7 +61,7 @@
|
|||||||
// labelSum
|
// labelSum
|
||||||
//
|
//
|
||||||
labelSum.AutoSize = true;
|
labelSum.AutoSize = true;
|
||||||
labelSum.Location = new Point(34, 171);
|
labelSum.Location = new Point(34, 187);
|
||||||
labelSum.Name = "labelSum";
|
labelSum.Name = "labelSum";
|
||||||
labelSum.Size = new Size(58, 20);
|
labelSum.Size = new Size(58, 20);
|
||||||
labelSum.TabIndex = 2;
|
labelSum.TabIndex = 2;
|
||||||
@ -77,7 +79,7 @@
|
|||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(141, 109);
|
textBoxCount.Location = new Point(141, 135);
|
||||||
textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
textBoxCount.Size = new Size(369, 27);
|
textBoxCount.Size = new Size(369, 27);
|
||||||
textBoxCount.TabIndex = 4;
|
textBoxCount.TabIndex = 4;
|
||||||
@ -85,7 +87,7 @@
|
|||||||
//
|
//
|
||||||
// textBoxSum
|
// textBoxSum
|
||||||
//
|
//
|
||||||
textBoxSum.Location = new Point(141, 171);
|
textBoxSum.Location = new Point(141, 187);
|
||||||
textBoxSum.Name = "textBoxSum";
|
textBoxSum.Name = "textBoxSum";
|
||||||
textBoxSum.ReadOnly = true;
|
textBoxSum.ReadOnly = true;
|
||||||
textBoxSum.Size = new Size(369, 27);
|
textBoxSum.Size = new Size(369, 27);
|
||||||
@ -111,11 +113,31 @@
|
|||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
|
// labelClient
|
||||||
|
//
|
||||||
|
labelClient.AutoSize = true;
|
||||||
|
labelClient.Location = new Point(34, 92);
|
||||||
|
labelClient.Name = "labelClient";
|
||||||
|
labelClient.Size = new Size(61, 20);
|
||||||
|
labelClient.TabIndex = 8;
|
||||||
|
labelClient.Text = "Клиент:";
|
||||||
|
//
|
||||||
|
// comboBoxClient
|
||||||
|
//
|
||||||
|
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxClient.FormattingEnabled = true;
|
||||||
|
comboBoxClient.Location = new Point(141, 89);
|
||||||
|
comboBoxClient.Name = "comboBoxClient";
|
||||||
|
comboBoxClient.Size = new Size(369, 28);
|
||||||
|
comboBoxClient.TabIndex = 9;
|
||||||
|
//
|
||||||
// FormCreateOrder
|
// FormCreateOrder
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(539, 308);
|
ClientSize = new Size(539, 308);
|
||||||
|
Controls.Add(comboBoxClient);
|
||||||
|
Controls.Add(labelClient);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(textBoxSum);
|
Controls.Add(textBoxSum);
|
||||||
@ -141,5 +163,7 @@
|
|||||||
private TextBox textBoxSum;
|
private TextBox textBoxSum;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private Label labelClient;
|
||||||
|
private ComboBox comboBoxClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,12 +13,15 @@ namespace GiftShopView
|
|||||||
|
|
||||||
private readonly IOrderLogic _logicO;
|
private readonly IOrderLogic _logicO;
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IGiftLogic logicP, IOrderLogic logicO)
|
private readonly IClientLogic _logicC;
|
||||||
|
|
||||||
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, IGiftLogic logicP, IOrderLogic logicO, IClientLogic logicC)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicP = logicP;
|
_logicP = logicP;
|
||||||
_logicO = logicO;
|
_logicO = logicO;
|
||||||
|
_logicC = logicC;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
@ -46,6 +49,24 @@ namespace GiftShopView
|
|||||||
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Загрузка клиентов для заказа");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicC.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxClient.DisplayMember = "Клиент";
|
||||||
|
comboBoxClient.ValueMember = "Id";
|
||||||
|
comboBoxClient.DataSource = list.Select(c => c.ClientFIO).ToList();
|
||||||
|
comboBoxClient.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка клиентов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalcSum()
|
private void CalcSum()
|
||||||
@ -100,6 +121,7 @@ namespace GiftShopView
|
|||||||
{
|
{
|
||||||
GiftId = Convert.ToInt32(comboBoxGift.SelectedValue),
|
GiftId = Convert.ToInt32(comboBoxGift.SelectedValue),
|
||||||
GiftName = comboBoxGift.Text,
|
GiftName = comboBoxGift.Text,
|
||||||
|
ClientId = Convert.ToInt32(comboBoxClient.SelectedIndex),
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@ namespace GiftShopView
|
|||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMails_Load(object sender, EventArgs e)
|
private void LoadData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -36,6 +36,11 @@ namespace GiftShopView
|
|||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FormMails_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user