diff --git a/PrecastConcreteFileImplement/Implements/ImplementerStorage.cs b/PrecastConcreteFileImplement/Implements/ImplementerStorage.cs index e16961c..bd2f309 100644 --- a/PrecastConcreteFileImplement/Implements/ImplementerStorage.cs +++ b/PrecastConcreteFileImplement/Implements/ImplementerStorage.cs @@ -1,4 +1,9 @@ -using System; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantFileImplement.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,98 +11,100 @@ using System.Threading.Tasks; namespace PrecastConcretePlantFileImplement.Implements { - public class ImplementerStorage : IImplementerStorage - { - private readonly DataFileSingleton _source; - public ImplementerStorage() - { - _source = DataFileSingleton.GetInstance(); - } - public ImplementerViewModel? Delete(ImplementerBindingModel model) - { - var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id); + public class ImplementerStorage : IImplementerStorage + { + private readonly DataFileSingleton _source; + public ImplementerStorage() + { + _source = DataFileSingleton.GetInstance(); + } + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id); - if (res != null) - { - _source.Implementers.Remove(res); - _source.SaveImplementers(); - } - return res?.GetViewModel; - } + if (res != null) + { + _source.Implementers.Remove(res); + _source.SaveImplementers(); + } + return res?.GetViewModel; + } - public ImplementerViewModel? GetElement(ImplementerSearchModel model) - { - if (model.Id.HasValue) - return _source.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (model.Id.HasValue) + return _source.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; - if (model.ImplementerFIO != null && model.Password != null) - return _source.Implementers - .FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) - && x.Password.Equals(model.Password)) - ?.GetViewModel; + if (model.ImplementerFIO != null && model.Password != null) + return _source.Implementers + .FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) + && x.Password.Equals(model.Password)) + ?.GetViewModel; - if (model.ImplementerFIO != null) - return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel; + if (model.ImplementerFIO != null) + return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel; - return null; - } + return null; + } - public List GetFilteredList(ImplementerSearchModel model) - { - if (model == null) - { - return new(); - } + public List GetFilteredList(ImplementerSearchModel model) + { + if (model == null) + { + return new(); + } - if (model.Id.HasValue) - { - var res = GetElement(model); + if (model.Id.HasValue) + { + var res = GetElement(model); - return res != null ? new() { res } : new(); - } + return res != null ? new() { res } : new(); + } - if (model.ImplementerFIO != null) - { - return _source.Implementers - .Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) - .Select(x => x.GetViewModel) - .ToList(); - } + if (model.ImplementerFIO != null) + { + return _source.Implementers + .Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) + .Select(x => x.GetViewModel) + .ToList(); + } - return new(); - } + return new(); + } - public List GetFullList() - { - return _source.Implementers.Select(x => x.GetViewModel).ToList(); - } + public List GetFullList() + { + return _source.Implementers + .Select(x => x.GetViewModel) + .ToList(); + } - public ImplementerViewModel? Insert(ImplementerBindingModel model) - { - model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1; + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1; - var res = Implementer.Create(model); + var res = Implementer.Create(model); - if (res != null) - { - _source.Implementers.Add(res); - _source.SaveImplementers(); - } + if (res != null) + { + _source.Implementers.Add(res); + _source.SaveImplementers(); + } - return res?.GetViewModel; - } + return res?.GetViewModel; + } - public ImplementerViewModel? Update(ImplementerBindingModel model) - { - var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id); + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id); - if (res != null) - { - res.Update(model); - _source.SaveImplementers(); - } + if (res != null) + { + res.Update(model); + _source.SaveImplementers(); + } - return res?.GetViewModel; - } - } + return res?.GetViewModel; + } + } } diff --git a/PrecastConcreteFileImplement/Models/Implementer.cs b/PrecastConcreteFileImplement/Models/Implementer.cs index cb887cb..ca21d99 100644 --- a/PrecastConcreteFileImplement/Models/Implementer.cs +++ b/PrecastConcreteFileImplement/Models/Implementer.cs @@ -1,82 +1,86 @@ -using System; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace PrecastConcretePlantFileImplement.Models { - public class Implementer : IImplementerModel - { - public string ImplementerFIO { get; private set; } = string.Empty; + public class Implementer : IImplementerModel + { + public string ImplementerFIO { get; private set; } = string.Empty; - public string Password { get; private set; } = string.Empty; + public string Password { get; private set; } = string.Empty; - public int WorkExperience { get; private set; } + public int WorkExperience { get; private set; } - public int Qualification { get; private set; } + public int Qualification { get; private set; } - public int Id { get; private set; } + public int Id { get; private set; } - public static Implementer? Create(XElement element) - { - if (element == null) - { - return null; - } - return new() - { - ImplementerFIO = element.Element("FIO")!.Value, - Password = element.Element("Password")!.Value, - Id = Convert.ToInt32(element.Attribute("Id")!.Value), - Qualification = Convert.ToInt32(element.Element("Qualification")!.Value), - WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value), - }; - } + public static Implementer? Create(XElement element) + { + if (element == null) + { + return null; + } + return new() + { + ImplementerFIO = element.Element("FIO")!.Value, + Password = element.Element("Password")!.Value, + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + Qualification = Convert.ToInt32(element.Element("Qualification")!.Value), + WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value), + }; + } - public static Implementer? Create(ImplementerBindingModel model) - { - if (model == null) - { - return null; - } - return new() - { - Id = model.Id, - Password = model.Password, - Qualification = model.Qualification, - ImplementerFIO = model.ImplementerFIO, - WorkExperience = model.WorkExperience, - }; - } + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + return new() + { + Id = model.Id, + Password = model.Password, + Qualification = model.Qualification, + ImplementerFIO = model.ImplementerFIO, + WorkExperience = model.WorkExperience, + }; + } - public void Update(ImplementerBindingModel model) - { - if (model == null) - { - return; - } - Password = model.Password; - Qualification = model.Qualification; - ImplementerFIO = model.ImplementerFIO; - WorkExperience = model.WorkExperience; - } + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + Password = model.Password; + Qualification = model.Qualification; + ImplementerFIO = model.ImplementerFIO; + WorkExperience = model.WorkExperience; + } - public ImplementerViewModel GetViewModel => new() - { - Id = Id, - Password = Password, - Qualification = Qualification, - ImplementerFIO = ImplementerFIO, - WorkExperience = WorkExperience - }; + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + Password = Password, + Qualification = Qualification, + ImplementerFIO = ImplementerFIO, + WorkExperience = WorkExperience + }; - public XElement GetXElement => new("Client", - new XAttribute("Id", Id), - new XElement("Password", Password), - new XElement("FIO", ImplementerFIO), - new XElement("Qualification", Qualification), - new XElement("WorkExperience", WorkExperience) - ); - } + public XElement GetXElement => new("Client", + new XAttribute("Id", Id), + new XElement("Password", Password), + new XElement("FIO", ImplementerFIO), + new XElement("Qualification", Qualification), + new XElement("WorkExperience", WorkExperience) + ); + } } diff --git a/PrecastConcretePlant/FormImplementer.Designer.cs b/PrecastConcretePlant/FormImplementer.Designer.cs index ff1dbf1..bdd716a 100644 --- a/PrecastConcretePlant/FormImplementer.Designer.cs +++ b/PrecastConcretePlant/FormImplementer.Designer.cs @@ -1,178 +1,173 @@ namespace PrecastConcretePlantView { - partial class FormImplementer - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormImplementer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + 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 - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonSave = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.numericUpDownQualification = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownWorkExperience = new System.Windows.Forms.NumericUpDown(); - this.textBoxPassword = new System.Windows.Forms.TextBox(); - this.textBoxFio = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).BeginInit(); - this.SuspendLayout(); - // - // buttonSave - // - this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSave.Location = new System.Drawing.Point(108, 151); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(89, 33); - this.buttonSave.TabIndex = 19; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.Location = new System.Drawing.Point(219, 151); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(89, 33); - this.buttonCancel.TabIndex = 18; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // numericUpDownQualification - // - this.numericUpDownQualification.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.numericUpDownQualification.Location = new System.Drawing.Point(116, 97); - this.numericUpDownQualification.Name = "numericUpDownQualification"; - this.numericUpDownQualification.Size = new System.Drawing.Size(264, 23); - this.numericUpDownQualification.TabIndex = 17; - // - // numericUpDownWorkExperience - // - this.numericUpDownWorkExperience.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.numericUpDownWorkExperience.Location = new System.Drawing.Point(116, 68); - this.numericUpDownWorkExperience.Name = "numericUpDownWorkExperience"; - this.numericUpDownWorkExperience.Size = new System.Drawing.Size(264, 23); - this.numericUpDownWorkExperience.TabIndex = 16; - // - // textBoxPassword - // - this.textBoxPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxPassword.Location = new System.Drawing.Point(116, 40); - this.textBoxPassword.Name = "textBoxPassword"; - this.textBoxPassword.PasswordChar = '*'; - this.textBoxPassword.Size = new System.Drawing.Size(264, 23); - this.textBoxPassword.TabIndex = 15; - // - // textBoxFio - // - this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxFio.Location = new System.Drawing.Point(116, 11); - this.textBoxFio.Name = "textBoxFio"; - this.textBoxFio.Size = new System.Drawing.Size(264, 23); - this.textBoxFio.TabIndex = 14; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(14, 99); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(91, 15); - this.label4.TabIndex = 13; - this.label4.Text = "Квалификация:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(67, 70); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 15); - this.label3.TabIndex = 12; - this.label3.Text = "Стаж:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(58, 43); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(52, 15); - this.label2.TabIndex = 11; - this.label2.Text = "Пароль:"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(68, 14); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(37, 15); - this.label1.TabIndex = 10; - this.label1.Text = "ФИО:"; - // - // FormImplementer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(402, 196); - this.Controls.Add(this.buttonSave); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.numericUpDownQualification); - this.Controls.Add(this.numericUpDownWorkExperience); - this.Controls.Add(this.textBoxPassword); - this.Controls.Add(this.textBoxFio); - this.Controls.Add(this.label4); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Name = "FormImplementer"; - this.Text = "FormImplementer"; - this.Load += new System.EventHandler(this.FormImplementer_Load); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonSave = new Button(); + buttonCancel = new Button(); + numericUpDownQualification = new NumericUpDown(); + numericUpDownWorkExperience = new NumericUpDown(); + textBoxPassword = new TextBox(); + textBoxFio = new TextBox(); + label4 = new Label(); + label3 = new Label(); + label2 = new Label(); + label1 = new Label(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQualification).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).BeginInit(); + SuspendLayout(); + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonSave.Location = new Point(108, 151); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(89, 33); + buttonSave.TabIndex = 19; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(219, 151); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(89, 33); + buttonCancel.TabIndex = 18; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // numericUpDownQualification + // + numericUpDownQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownQualification.Location = new Point(116, 97); + numericUpDownQualification.Name = "numericUpDownQualification"; + numericUpDownQualification.Size = new Size(264, 23); + numericUpDownQualification.TabIndex = 17; + // + // numericUpDownWorkExperience + // + numericUpDownWorkExperience.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownWorkExperience.Location = new Point(116, 68); + numericUpDownWorkExperience.Name = "numericUpDownWorkExperience"; + numericUpDownWorkExperience.Size = new Size(264, 23); + numericUpDownWorkExperience.TabIndex = 16; + // + // textBoxPassword + // + textBoxPassword.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxPassword.Location = new Point(116, 40); + textBoxPassword.Name = "textBoxPassword"; + textBoxPassword.PasswordChar = '*'; + textBoxPassword.Size = new Size(264, 23); + textBoxPassword.TabIndex = 15; + // + // textBoxFio + // + textBoxFio.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxFio.Location = new Point(116, 11); + textBoxFio.Name = "textBoxFio"; + textBoxFio.Size = new Size(264, 23); + textBoxFio.TabIndex = 14; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(14, 99); + label4.Name = "label4"; + label4.Size = new Size(91, 15); + label4.TabIndex = 13; + label4.Text = "Квалификация:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(67, 70); + label3.Name = "label3"; + label3.Size = new Size(38, 15); + label3.TabIndex = 12; + label3.Text = "Стаж:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(58, 43); + label2.Name = "label2"; + label2.Size = new Size(52, 15); + label2.TabIndex = 11; + label2.Text = "Пароль:"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(68, 14); + label1.Name = "label1"; + label1.Size = new Size(37, 15); + label1.TabIndex = 10; + label1.Text = "ФИО:"; + // + // FormImplementer + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(402, 196); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Controls.Add(numericUpDownQualification); + Controls.Add(numericUpDownWorkExperience); + Controls.Add(textBoxPassword); + Controls.Add(textBoxFio); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormImplementer"; + Text = "Исполнитель"; + Load += FormImplementer_Load; + ((System.ComponentModel.ISupportInitialize)numericUpDownQualification).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - } + #endregion - #endregion - - private Button buttonSave; - private Button buttonCancel; - private NumericUpDown numericUpDownQualification; - private NumericUpDown numericUpDownWorkExperience; - private TextBox textBoxPassword; - private TextBox textBoxFio; - private Label label4; - private Label label3; - private Label label2; - private Label label1; - } + private Button buttonSave; + private Button buttonCancel; + private NumericUpDown numericUpDownQualification; + private NumericUpDown numericUpDownWorkExperience; + private TextBox textBoxPassword; + private TextBox textBoxFio; + private Label label4; + private Label label3; + private Label label2; + private Label label1; + } } \ No newline at end of file diff --git a/PrecastConcretePlant/FormImplementer.cs b/PrecastConcretePlant/FormImplementer.cs index 2aa54fd..bb3c33f 100644 --- a/PrecastConcretePlant/FormImplementer.cs +++ b/PrecastConcretePlant/FormImplementer.cs @@ -5,96 +5,96 @@ using PrecastConcretePlantContracts.SearchModels; namespace PrecastConcretePlantView { - public partial class FormImplementer : Form - { - private readonly ILogger _logger; - private readonly IImplementerLogic _logic; - private int? _id; - public int Id { set { _id = value; } } + public partial class FormImplementer : Form + { + private readonly ILogger _logger; + private readonly IImplementerLogic _logic; + private int? _id; + public int Id { set { _id = value; } } - public FormImplementer(ILogger logger, IImplementerLogic logic) - { - InitializeComponent(); - _logger = logger; - _logic = logic; - } + public FormImplementer(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } - private void FormImplementer_Load(object sender, EventArgs e) - { - if (_id.HasValue) - { - try - { - _logger.LogInformation("Получение исполнителя"); - var view = _logic.ReadElement(new ImplementerSearchModel - { - Id = _id.Value - }); - if (view != null) - { - textBoxFio.Text = view.ImplementerFIO; - textBoxPassword.Text = view.Password; - numericUpDownQualification.Value = view.Qualification; - numericUpDownWorkExperience.Value = view.WorkExperience; - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения исполнителя"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } + private void FormImplementer_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение исполнителя"); + var view = _logic.ReadElement(new ImplementerSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxFio.Text = view.ImplementerFIO; + textBoxPassword.Text = view.Password; + numericUpDownQualification.Value = view.Qualification; + numericUpDownWorkExperience.Value = view.WorkExperience; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } - private void ButtonSave_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(textBoxPassword.Text)) - { - MessageBox.Show("Заполните пароль", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - if (string.IsNullOrEmpty(textBoxFio.Text)) - { - MessageBox.Show("Заполните фио", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - _logger.LogInformation("Сохранение исполнителя"); - try - { - var model = new ImplementerBindingModel - { - Id = _id ?? 0, - ImplementerFIO = textBoxFio.Text, - Password = textBoxPassword.Text, - Qualification = (int)numericUpDownQualification.Value, - WorkExperience = (int)numericUpDownWorkExperience.Value, - }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", - MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; - Close(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка сохранения исполнителя"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxPassword.Text)) + { + MessageBox.Show("Заполните пароль", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxFio.Text)) + { + MessageBox.Show("Заполните фио", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение исполнителя"); + try + { + var model = new ImplementerBindingModel + { + Id = _id ?? 0, + ImplementerFIO = textBoxFio.Text, + Password = textBoxPassword.Text, + Qualification = (int)numericUpDownQualification.Value, + WorkExperience = (int)numericUpDownWorkExperience.Value, + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } - private void ButtonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } - } + } } diff --git a/PrecastConcretePlant/FormImplementers.Designer.cs b/PrecastConcretePlant/FormImplementers.Designer.cs index b9269a9..0baeb74 100644 --- a/PrecastConcretePlant/FormImplementers.Designer.cs +++ b/PrecastConcretePlant/FormImplementers.Designer.cs @@ -1,121 +1,118 @@ namespace PrecastConcretePlantView { - partial class FormImplementers - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormImplementers + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + 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 - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonRef = new System.Windows.Forms.Button(); - this.buttonDel = new System.Windows.Forms.Button(); - this.buttonUpd = new System.Windows.Forms.Button(); - this.buttonAdd = new System.Windows.Forms.Button(); - this.dataGridView = new System.Windows.Forms.DataGridView(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); - // - // buttonRef - // - this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRef.Location = new System.Drawing.Point(532, 149); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(90, 37); - this.buttonRef.TabIndex = 14; - this.buttonRef.Text = "Обновить"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); - // - // buttonDel - // - this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDel.Location = new System.Drawing.Point(532, 110); - this.buttonDel.Name = "buttonDel"; - this.buttonDel.Size = new System.Drawing.Size(90, 33); - this.buttonDel.TabIndex = 13; - this.buttonDel.Text = "Удалить"; - this.buttonDel.UseVisualStyleBackColor = true; - this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); - // - // buttonUpd - // - this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUpd.Location = new System.Drawing.Point(532, 70); - this.buttonUpd.Name = "buttonUpd"; - this.buttonUpd.Size = new System.Drawing.Size(90, 34); - this.buttonUpd.TabIndex = 12; - this.buttonUpd.Text = "Изменить"; - this.buttonUpd.UseVisualStyleBackColor = true; - this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); - // - // buttonAdd - // - this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAdd.Location = new System.Drawing.Point(532, 34); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(90, 30); - this.buttonAdd.TabIndex = 11; - this.buttonAdd.Text = "Добавить"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); - // - // dataGridView - // - this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 12); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(469, 290); - this.dataGridView.TabIndex = 10; - // - // FormViewImplementers - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(634, 314); - this.Controls.Add(this.buttonRef); - this.Controls.Add(this.buttonDel); - this.Controls.Add(this.buttonUpd); - this.Controls.Add(this.buttonAdd); - this.Controls.Add(this.dataGridView); - this.Name = "FormViewImplementers"; - this.Text = "FormViewImplementers"; - this.Load += new System.EventHandler(this.FormViewImplementers_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonRef = new Button(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonRef + // + buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonRef.Location = new Point(532, 149); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(90, 37); + buttonRef.TabIndex = 14; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // buttonDel + // + buttonDel.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonDel.Location = new Point(532, 110); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(90, 33); + buttonDel.TabIndex = 13; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonUpd.Location = new Point(532, 70); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 34); + buttonUpd.TabIndex = 12; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonAdd.Location = new Point(532, 34); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 30); + buttonAdd.TabIndex = 11; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 12); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(469, 290); + dataGridView.TabIndex = 10; + // + // FormImplementers + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(634, 314); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormImplementers"; + Text = "Исполнители"; + Load += FormViewImplementers_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } - } + #endregion - #endregion - - private Button buttonRef; - private Button buttonDel; - private Button buttonUpd; - private Button buttonAdd; - private DataGridView dataGridView; - } + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } } \ No newline at end of file diff --git a/PrecastConcretePlant/FormImplementers.cs b/PrecastConcretePlant/FormImplementers.cs index 81fb05c..5311e4f 100644 --- a/PrecastConcretePlant/FormImplementers.cs +++ b/PrecastConcretePlant/FormImplementers.cs @@ -5,99 +5,99 @@ using PrecastConcretePlantContracts.BusinessLogicsContracts; namespace PrecastConcretePlantView { - public partial class FormImplementers : Form - { - private readonly ILogger _logger; - private readonly IImplementerLogic _logic; - public FormImplementers(ILogger logger, IImplementerLogic logic) - { - InitializeComponent(); - _logger = logger; - _logic = logic; - } - private void FormViewImplementers_Load(object sender, EventArgs e) - { - LoadData(); - } - private void LoadData() - { - try - { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка исполнителей"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки исполнителей"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - private void ButtonAdd_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer form) - { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } - private void ButtonUpd_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer form) - { - form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } - } - private void ButtonDel_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление исполнителя"); - try - { - if (!_logic.Delete(new ImplementerBindingModel - { - Id = id - })) - { - throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления исполнителя"); - MessageBox.Show(ex.Message, "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } - } + public partial class FormImplementers : Form + { + private readonly ILogger _logger; + private readonly IImplementerLogic _logic; + public FormImplementers(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormViewImplementers_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка исполнителей"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки исполнителей"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + if (service is FormImplementer form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + if (service is FormImplementer form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление исполнителя"); + try + { + if (!_logic.Delete(new ImplementerBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } } diff --git a/PrecastConcretePlantBusinessLogic/BusinessLogic/OrderLogic.cs b/PrecastConcretePlantBusinessLogic/BusinessLogic/OrderLogic.cs index a8a6084..64a85e1 100644 --- a/PrecastConcretePlantBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/PrecastConcretePlantBusinessLogic/BusinessLogic/OrderLogic.cs @@ -51,7 +51,6 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic } public OrderViewModel? ReadElement(OrderSearchModel model) - private bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) { if (model == null) { @@ -75,25 +74,30 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic { throw new ArgumentNullException(nameof(model)); } - if (viewModel.Status + 1 != newStatus) - { + if (viewModel.Status + 1 != newStatus && viewModel.Status != OrderStatus.Ожидание) + { _logger.LogWarning("Change status operation failed"); throw new InvalidOperationException(); - var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); - if (viewModel == null) - { - throw new ArgumentNullException(nameof(model)); - } - if (viewModel.Status + 1 != newStatus) - { - _logger.LogWarning("Change status operation failed"); - return false; } model.Status = newStatus; - if (model.Status == OrderStatus.Готов) - { - model.DateImplement = DateTime.Now; - } + if (model.Status == OrderStatus.Готов || viewModel.Status == OrderStatus.Ожидание) + { + model.DateImplement = DateTime.Now; + var reinforced = _reinforcedStorage.GetElement(new() { Id = viewModel.ReinforcedId }); + if (reinforced == null) + { + throw new ArgumentNullException(nameof(reinforced)); + } + if (!_shopLogic.AddReinforced(reinforced, viewModel.Count)) + { + model.Status = OrderStatus.Ожидание; + _logger.LogWarning($"AddReinforced operation failed"); + } + else + { + model.DateImplement = DateTime.Now; + } + } else { model.DateImplement = viewModel.DateImplement; @@ -102,21 +106,6 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic { model.ImplementerId = viewModel.ImplementerId.Value; } - CheckModel(model, false); - var reinforced = _reinforcedStorage.GetElement(new() { Id = viewModel.ReinforcedId }); - if (reinforced == null) - { - throw new ArgumentNullException(nameof(reinforced)); - } - if (!_shopLogic.AddReinforced(reinforced, viewModel.Count)) - { - throw new Exception($"AddReinforced operation failed"); - } - } - else - { - model.DateImplement = viewModel.DateImplement; - } CheckModel(model, false); if (_orderStorage.Update(model) == null) { diff --git a/PrecastConcretePlantBusinessLogic/BusinessLogic/WorkModeling.cs b/PrecastConcretePlantBusinessLogic/BusinessLogic/WorkModeling.cs index ed20a97..0e33e0e 100644 --- a/PrecastConcretePlantBusinessLogic/BusinessLogic/WorkModeling.cs +++ b/PrecastConcretePlantBusinessLogic/BusinessLogic/WorkModeling.cs @@ -12,129 +12,147 @@ using System.Threading.Tasks; namespace PrecastConcretePlantBusinessLogic.BusinessLogic { - public class WorkModeling : IWorkProcess - { - private readonly ILogger _logger; + public class WorkModeling : IWorkProcess + { + private readonly ILogger _logger; - private readonly Random _rnd; + private readonly Random _rnd; - private IOrderLogic? _orderLogic; + private IOrderLogic? _orderLogic; - public WorkModeling(ILogger logger) - { - _logger = logger; - _rnd = new Random(1000); - } + public WorkModeling(ILogger logger) + { + _logger = logger; + _rnd = new Random(1000); + } - public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic) - { - _orderLogic = orderLogic; - var implementers = implementerLogic.ReadList(null); - if (implementers == null) - { - _logger.LogWarning("DoWork. Implementers is null"); - return; - } + public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic) + { + _orderLogic = orderLogic; + var implementers = implementerLogic.ReadList(null); + if (implementers == null) + { + _logger.LogWarning("DoWork. Implementers is null"); + return; + } - var orders = _orderLogic.ReadList(new OrderSearchModel { Status = new() { OrderStatus.Принят, OrderStatus.Выполняется } }); - if (orders == null || orders.Count == 0) - { - _logger.LogWarning("DoWork. Orders is null or empty"); - return; - } + var orders = _orderLogic.ReadList(new OrderSearchModel { Statuses = new() { OrderStatus.Принят, OrderStatus.Выполняется, OrderStatus.Ожидание } }); + if (orders == null || orders.Count == 0) + { + _logger.LogWarning("DoWork. Orders is null or empty"); + return; + } - _logger.LogDebug("DoWork for {Count} orders", orders.Count); + _logger.LogDebug("DoWork for {Count} orders", orders.Count); - foreach (var implementer in implementers) - { - Task.Run(() => WorkerWorkAsync(implementer, orders)); - } - } + foreach (var implementer in implementers) + { + Task.Run(() => WorkerWorkAsync(implementer, orders)); + } + } - private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders) - { - if (_orderLogic == null || implementer == null) - { - return; - } - await RunOrderInWork(implementer, orders); + private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders) + { + if (_orderLogic == null || implementer == null) + { + return; + } + await RunOrderInWork(implementer, orders); - await Task.Run(() => - { - foreach (var order in orders) - { - try - { - _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); + await Task.Run(() => + { + foreach (var order in orders.Where(x => x.Status == OrderStatus.Ожидание && x.ImplementerId == implementer.Id)) + { + try + { + _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = order.Id + }); + } + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } + }); - _orderLogic.TakeOrderInWork(new OrderBindingModel - { - Id = order.Id, - ImplementerId = implementer.Id - }); + await RunOrderInWork(implementer, orders); - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); + await Task.Run(() => + { + foreach (var order in orders.Where(x => x.Status == OrderStatus.Принят)) + { + try + { + _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); + _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = order.Id, + ImplementerId = implementer.Id + }); + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); + _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = order.Id + }); + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + } + }); + } + private async Task RunOrderInWork(ImplementerViewModel implementer, List allOrders) + { + if (_orderLogic == null || implementer == null || allOrders == null || allOrders.Count == 0) + { + return; + } + try + { + var runOrder = await Task.Run(() => allOrders.FirstOrDefault(x => x.ImplementerId == implementer.Id && x.Status == OrderStatus.Выполняется)); + if (runOrder == null) + { + return; + } - _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); + _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id); - _orderLogic.DeliveryOrder(new OrderBindingModel - { - Id = order.Id - }); + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id); + _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = runOrder.Id + }); - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); - } + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } - catch (InvalidOperationException ex) - { - _logger.LogWarning(ex, "Error try get work"); - } + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } - catch (Exception ex) - { - _logger.LogError(ex, "Error while do work"); - throw; - } - } - }); - } - - private async Task RunOrderInWork(ImplementerViewModel implementer, List allOrders) - { - if (_orderLogic == null || implementer == null || allOrders == null || allOrders.Count == 0) - { - return; - } - try - { - var runOrder = await Task.Run(() => allOrders.FirstOrDefault(x => x.ImplementerId == implementer.Id && x.Status == OrderStatus.Выполняется)); - if (runOrder == null) - { - return; - } - - _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id); - - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count); - _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id); - _orderLogic.DeliveryOrder(new OrderBindingModel - { - Id = runOrder.Id - }); - - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); - } - - catch (InvalidOperationException ex) - { - _logger.LogWarning(ex, "Error try get work"); - } - - catch (Exception ex) - { - _logger.LogError(ex, "Error while do work"); - throw; - } - } - } + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + } + } } \ No newline at end of file diff --git a/PrecastConcretePlantContracts/BindingModels/ImplementerBindingModel.cs b/PrecastConcretePlantContracts/BindingModels/ImplementerBindingModel.cs index 1c55a14..d38e66e 100644 --- a/PrecastConcretePlantContracts/BindingModels/ImplementerBindingModel.cs +++ b/PrecastConcretePlantContracts/BindingModels/ImplementerBindingModel.cs @@ -6,16 +6,16 @@ using System.Threading.Tasks; namespace PrecastConcretePlantContracts.BindingModels { - public class ImplementerBindingModel - { - public int Id { get; set; } + public class ImplementerBindingModel + { + public int Id { get; set; } - public string ImplementerFIO { get; set; } = string.Empty; + public string ImplementerFIO { get; set; } = string.Empty; - public string Password { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; - public int WorkExperience { get; set; } + public int WorkExperience { get; set; } - public int Qualification { get; set; } - } + public int Qualification { get; set; } + } } diff --git a/PrecastConcretePlantContracts/BusinessLogicsContracts/IImplementerLogic.cs b/PrecastConcretePlantContracts/BusinessLogicsContracts/IImplementerLogic.cs index 37fbec9..571a13e 100644 --- a/PrecastConcretePlantContracts/BusinessLogicsContracts/IImplementerLogic.cs +++ b/PrecastConcretePlantContracts/BusinessLogicsContracts/IImplementerLogic.cs @@ -9,16 +9,16 @@ using System.Threading.Tasks; namespace PrecastConcretePlantContracts.BusinessLogicsContracts { - public interface IImplementerLogic - { - List? ReadList(ImplementerSearchModel? model); + public interface IImplementerLogic + { + List? ReadList(ImplementerSearchModel? model); - ImplementerViewModel? ReadElement(ImplementerSearchModel model); + ImplementerViewModel? ReadElement(ImplementerSearchModel model); - bool Create(ImplementerBindingModel model); + bool Create(ImplementerBindingModel model); - bool Update(ImplementerBindingModel model); + bool Update(ImplementerBindingModel model); - bool Delete(ImplementerBindingModel model); - } + bool Delete(ImplementerBindingModel model); + } } diff --git a/PrecastConcretePlantContracts/ViewModels/ImplementerViewModel.cs b/PrecastConcretePlantContracts/ViewModels/ImplementerViewModel.cs index b41daf9..f70dd5f 100644 --- a/PrecastConcretePlantContracts/ViewModels/ImplementerViewModel.cs +++ b/PrecastConcretePlantContracts/ViewModels/ImplementerViewModel.cs @@ -8,20 +8,20 @@ using System.Threading.Tasks; namespace PrecastConcretePlantContracts.ViewModels { - public class ImplementerViewModel : IImplementerModel - { - public int Id { get; set; } + public class ImplementerViewModel : IImplementerModel + { + public int Id { get; set; } - [DisplayName("ФИО исполнителя")] - public string ImplementerFIO { get; set; } = string.Empty; + [DisplayName("ФИО исполнителя")] + public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] - public string Password { get; set; } = string.Empty; + [DisplayName("Пароль")] + public string Password { get; set; } = string.Empty; - [DisplayName("Стаж работы")] - public int WorkExperience { get; set; } + [DisplayName("Стаж работы")] + public int WorkExperience { get; set; } - [DisplayName("Квалификация")] - public int Qualification { get; set; } - } + [DisplayName("Квалификация")] + public int Qualification { get; set; } + } } diff --git a/PrecastConcretePlantDataBaseImplemet/Implements/ImplementerStorage.cs b/PrecastConcretePlantDataBaseImplemet/Implements/ImplementerStorage.cs index 7027c5d..d1b14a4 100644 --- a/PrecastConcretePlantDataBaseImplemet/Implements/ImplementerStorage.cs +++ b/PrecastConcretePlantDataBaseImplemet/Implements/ImplementerStorage.cs @@ -12,105 +12,105 @@ using System.Threading.Tasks; namespace PrecastConcretePlantDatabaseImplement.Implements { - public class ImplementerStorage : IImplementerStorage - { - public List GetFullList() - { - using var context = new PrecastConcretePlantDatabase(); - return context.Implementers - .Select(x => x.GetViewModel) - .ToList(); - } + public class ImplementerStorage : IImplementerStorage + { + public List GetFullList() + { + using var context = new PrecastConcretePlantDatabase(); + return context.Implementers + .Select(x => x.GetViewModel) + .ToList(); + } - public List GetFilteredList(ImplementerSearchModel model) - { - if (model == null) - { - return new(); - } + public List GetFilteredList(ImplementerSearchModel model) + { + if (model == null) + { + return new(); + } - if (model.Id.HasValue) - { - var implementer = GetElement(model); + if (model.Id.HasValue) + { + var implementer = GetElement(model); - return implementer != null ? new() { implementer } : new(); - } + return implementer != null ? new() { implementer } : new(); + } - if (model.ImplementerFIO != null) - { - using var context = new SoftwareInstallationDataBase(); + if (model.ImplementerFIO != null) + { + using var context = new PrecastConcretePlantDatabase(); - return context.Implementers - .Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) - .Select(x => x.GetViewModel) - .ToList(); - } + return context.Implementers + .Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) + .Select(x => x.GetViewModel) + .ToList(); + } - return new(); - } + return new(); + } - public ImplementerViewModel? GetElement(ImplementerSearchModel model) - { - using var context = new PrecastConcretePlantDatabase(); - if (model.Id.HasValue) - return context.Implementers - .FirstOrDefault(x => x.Id == model.Id) - ?.GetViewModel; + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + using var context = new PrecastConcretePlantDatabase(); + if (model.Id.HasValue) + return context.Implementers + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; - if (model.ImplementerFIO != null && model.Password != null) - return context.Implementers - .FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) - && x.Password.Equals(model.Password)) - ?.GetViewModel; + if (model.ImplementerFIO != null && model.Password != null) + return context.Implementers + .FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) + && x.Password.Equals(model.Password)) + ?.GetViewModel; - if (model.ImplementerFIO != null) - return context.Implementers - .FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) - ?.GetViewModel; + if (model.ImplementerFIO != null) + return context.Implementers + .FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) + ?.GetViewModel; - return null; - } + return null; + } - public ImplementerViewModel? Insert(ImplementerBindingModel model) - { - using var context = new PrecastConcretePlantDatabase(); - var implementer = Implementer.Create(model); + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + using var context = new PrecastConcretePlantDatabase(); + var implementer = Implementer.Create(model); - if (implementer != null) - { - context.Implementers.Add(implementer); - context.SaveChanges(); - } + if (implementer != null) + { + context.Implementers.Add(implementer); + context.SaveChanges(); + } - return implementer?.GetViewModel; - } + return implementer?.GetViewModel; + } - public ImplementerViewModel? Update(ImplementerBindingModel model) - { - using var context = new PrecastConcretePlantDatabase(); - var implementer = context.Implementers - .FirstOrDefault(x => x.Id == model.Id); + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + using var context = new PrecastConcretePlantDatabase(); + var implementer = context.Implementers + .FirstOrDefault(x => x.Id == model.Id); - if (implementer != null) - { - implementer.Update(model); - context.SaveChanges(); - } + if (implementer != null) + { + implementer.Update(model); + context.SaveChanges(); + } - return implementer?.GetViewModel; - } + return implementer?.GetViewModel; + } - public ImplementerViewModel? Delete(ImplementerBindingModel model) - { - using var context = new PrecastConcretePlantDatabase(); - var implementer = context.Implementers - .FirstOrDefault(rec => rec.Id == model.Id); - if (implementer != null) - { - context.Implementers.Remove(implementer); - context.SaveChanges(); - } - return implementer?.GetViewModel; - } - } + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + using var context = new PrecastConcretePlantDatabase(); + var implementer = context.Implementers + .FirstOrDefault(rec => rec.Id == model.Id); + if (implementer != null) + { + context.Implementers.Remove(implementer); + context.SaveChanges(); + } + return implementer?.GetViewModel; + } + } } \ No newline at end of file diff --git a/PrecastConcretePlantDataBaseImplemet/Models/Implementer.cs b/PrecastConcretePlantDataBaseImplemet/Models/Implementer.cs index 0db20f3..9167e0b 100644 --- a/PrecastConcretePlantDataBaseImplemet/Models/Implementer.cs +++ b/PrecastConcretePlantDataBaseImplemet/Models/Implementer.cs @@ -11,60 +11,60 @@ using System.Threading.Tasks; namespace PrecastConcretePlantDatabaseImplement.Models { - public class Implementer : IImplementerModel - { - public int Id { get; private set; } + public class Implementer : IImplementerModel + { + public int Id { get; private set; } - [Required] - public string ImplementerFIO { get; private set; } = string.Empty; + [Required] + public string ImplementerFIO { get; private set; } = string.Empty; - [Required] - public string Password { get; private set; } = string.Empty; + [Required] + public string Password { get; private set; } = string.Empty; - [Required] - public int WorkExperience { get; private set; } + [Required] + public int WorkExperience { get; private set; } - [Required] - public int Qualification { get; private set; } + [Required] + public int Qualification { get; private set; } - [ForeignKey("ImplementerId")] - public virtual List Orders { get; set; } = new(); + [ForeignKey("ImplementerId")] + public virtual List Orders { get; set; } = new(); - public static Implementer? Create(ImplementerBindingModel model) - { - if (model == null) - { - return null; - } - return new Implementer() - { - Id = model.Id, - ImplementerFIO = model.ImplementerFIO, - Password = model.Password, - WorkExperience = model.WorkExperience, - Qualification = model.Qualification, - }; - } + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + return new Implementer() + { + Id = model.Id, + ImplementerFIO = model.ImplementerFIO, + Password = model.Password, + WorkExperience = model.WorkExperience, + Qualification = model.Qualification, + }; + } - public void Update(ImplementerBindingModel model) - { - if (model == null) - { - return; - } - ImplementerFIO = model.ImplementerFIO; - Password = model.Password; - WorkExperience = model.WorkExperience; - Qualification = model.Qualification; - } + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + ImplementerFIO = model.ImplementerFIO; + Password = model.Password; + WorkExperience = model.WorkExperience; + Qualification = model.Qualification; + } - public ImplementerViewModel GetViewModel => new() - { - Id = Id, - ImplementerFIO = ImplementerFIO, - Password = Password, - WorkExperience = WorkExperience, - Qualification = Qualification, - }; - } + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + ImplementerFIO = ImplementerFIO, + Password = Password, + WorkExperience = WorkExperience, + Qualification = Qualification, + }; + } } diff --git a/PrecastConcretePlantDataModels/Enums/OrderStatus.cs b/PrecastConcretePlantDataModels/Enums/OrderStatus.cs index 5719b6e..a4c675e 100644 --- a/PrecastConcretePlantDataModels/Enums/OrderStatus.cs +++ b/PrecastConcretePlantDataModels/Enums/OrderStatus.cs @@ -12,7 +12,8 @@ namespace PrecastConcretePlantDataModels.Enums Принят = 0, Выполняется = 1, Готов = 2, - Выдан = 3 + Выдан = 3, + Ожидание = 4 } } diff --git a/PrecastConcretePlantListImplement/Implements/ImplementerStorage.cs b/PrecastConcretePlantListImplement/Implements/ImplementerStorage.cs index fdb06d6..a7a3a70 100644 --- a/PrecastConcretePlantListImplement/Implements/ImplementerStorage.cs +++ b/PrecastConcretePlantListImplement/Implements/ImplementerStorage.cs @@ -2,6 +2,7 @@ using PrecastConcretePlantContracts.SearchModels; using PrecastConcretePlantContracts.StoragesContracts; using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantListImplement.Models; using System; using System.Collections.Generic; using System.Linq; @@ -10,121 +11,121 @@ using System.Threading.Tasks; namespace PrecastConcretePlantListImplement.Implements { - public class ImplementerStorage : IImplementerStorage - { - private readonly DataListSingleton _source; - public ImplementerStorage() - { - _source = DataListSingleton.GetInstance(); - } + public class ImplementerStorage : IImplementerStorage + { + private readonly DataListSingleton _source; + public ImplementerStorage() + { + _source = DataListSingleton.GetInstance(); + } - public ImplementerViewModel? Delete(ImplementerBindingModel model) - { - for (int i = 0; i < _source.Implementers.Count; ++i) - { - if (_source.Implementers[i].Id == model.Id) - { - var element = _source.Implementers[i]; - _source.Implementers.RemoveAt(i); + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + for (int i = 0; i < _source.Implementers.Count; ++i) + { + if (_source.Implementers[i].Id == model.Id) + { + var element = _source.Implementers[i]; + _source.Implementers.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } + return element.GetViewModel; + } + } + return null; + } - public ImplementerViewModel? GetElement(ImplementerSearchModel model) - { - foreach (var x in _source.Implementers) - { - if (model.Id.HasValue && x.Id == model.Id) - return x.GetViewModel; + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + foreach (var x in _source.Implementers) + { + if (model.Id.HasValue && x.Id == model.Id) + return x.GetViewModel; - if (model.ImplementerFIO != null && model.Password != null && - x.ImplementerFIO.Equals(model.ImplementerFIO) && - x.Password.Equals(model.Password)) - return x.GetViewModel; + if (model.ImplementerFIO != null && model.Password != null && + x.ImplementerFIO.Equals(model.ImplementerFIO) && + x.Password.Equals(model.Password)) + return x.GetViewModel; - if (model.ImplementerFIO != null && x.ImplementerFIO.Equals(model.ImplementerFIO)) - return x.GetViewModel; - } - return null; - } + if (model.ImplementerFIO != null && x.ImplementerFIO.Equals(model.ImplementerFIO)) + return x.GetViewModel; + } + return null; + } - public List GetFilteredList(ImplementerSearchModel model) - { - if (model == null) - { - return new(); - } + public List GetFilteredList(ImplementerSearchModel model) + { + if (model == null) + { + return new(); + } - if (model.Id.HasValue) - { - var res = GetElement(model); + if (model.Id.HasValue) + { + var res = GetElement(model); - return res != null ? new() { res } : new(); - } + return res != null ? new() { res } : new(); + } - List result = new(); + List result = new(); - if (model.ImplementerFIO != null) - { - foreach (var implementer in _source.Implementers) - { - if (implementer.ImplementerFIO.Equals(model.ImplementerFIO)) - { - result.Add(implementer.GetViewModel); - } - } - } - return result; - } + if (model.ImplementerFIO != null) + { + foreach (var implementer in _source.Implementers) + { + if (implementer.ImplementerFIO.Equals(model.ImplementerFIO)) + { + result.Add(implementer.GetViewModel); + } + } + } + return result; + } - public List GetFullList() - { - var result = new List(); + public List GetFullList() + { + var result = new List(); - foreach (var implementer in _source.Implementers) - { - result.Add(implementer.GetViewModel); - } + foreach (var implementer in _source.Implementers) + { + result.Add(implementer.GetViewModel); + } - return result; - } + return result; + } - public ImplementerViewModel? Insert(ImplementerBindingModel model) - { - model.Id = 1; + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + model.Id = 1; - foreach (var implementer in _source.Implementers) - { - if (model.Id <= implementer.Id) - { - model.Id = implementer.Id + 1; - } - } + foreach (var implementer in _source.Implementers) + { + if (model.Id <= implementer.Id) + { + model.Id = implementer.Id + 1; + } + } - var res = Implementer.Create(model); + var res = Implementer.Create(model); - if (res != null) - { - _source.Implementers.Add(res); - } - return res?.GetViewModel; - } + if (res != null) + { + _source.Implementers.Add(res); + } + return res?.GetViewModel; + } - public ImplementerViewModel? Update(ImplementerBindingModel model) - { - foreach (var implementer in _source.Implementers) - { - if (implementer.Id == model.Id) - { - implementer.Update(model); + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + foreach (var implementer in _source.Implementers) + { + if (implementer.Id == model.Id) + { + implementer.Update(model); - return implementer.GetViewModel; - } - } - return null; - } - } + return implementer.GetViewModel; + } + } + return null; + } + } } diff --git a/PrecastConcretePlantListImplement/Implements/OrderStorage.cs b/PrecastConcretePlantListImplement/Implements/OrderStorage.cs index 3ededc3..79f4f6e 100644 --- a/PrecastConcretePlantListImplement/Implements/OrderStorage.cs +++ b/PrecastConcretePlantListImplement/Implements/OrderStorage.cs @@ -36,33 +36,28 @@ namespace PrecastConcretePlantListImplement.Implements public OrderViewModel? GetElement(OrderSearchModel model) { - if (!model.Id.HasValue) - { - return null; - } - - foreach (var order in _source.Orders) - { - if (model.Id.HasValue && order.Id == model.Id) - { - return order.GetViewModel; - } - else if (model.ImplementerId.HasValue && model.Statuses != null && - order.ImplementerId == model.ImplementerId && - model.Statuses.Contains(order.Status)) - { - return GetViewModel(order); - } - - else if (model.ImplementerId.HasValue && - model.ImplementerId == order.ImplementerId) - { - return GetViewModel(order); - } - } - - return null; - } + if (model.Id.HasValue) + { + foreach (var order in _source.Orders) + { + if (model.Id.HasValue && order.Id == model.Id) + { + return order.GetViewModel; + } + } + } + else if (model.ImplementerId.HasValue && model.Statuses != null) + { + foreach (var order in _source.Orders) + { + if (model.ImplementerId == order.ImplementerId && model.Statuses.Contains(order.Status)) + { + return order.GetViewModel; + } + } + } + return null; + } public List GetFilteredList(OrderSearchModel model) { @@ -86,7 +81,7 @@ namespace PrecastConcretePlantListImplement.Implements result.Add(order.GetViewModel); } - else if (model.Status != null && model.Status.Contains(order.Status)) + else if (model.Statuses != null && model.Statuses.Contains(order.Status)) { result.Add(order.GetViewModel); } diff --git a/PrecastConcretePlantListImplement/Models/Implementer.cs b/PrecastConcretePlantListImplement/Models/Implementer.cs index 132554e..f34a133 100644 --- a/PrecastConcretePlantListImplement/Models/Implementer.cs +++ b/PrecastConcretePlantListImplement/Models/Implementer.cs @@ -9,52 +9,53 @@ using System.Threading.Tasks; namespace PrecastConcretePlantListImplement.Models { - public class Implementer : IImplementerModel - { - public int Id { get; private set; } + public class Implementer : IImplementerModel + { + public int Id { get; private set; } - public string ImplementerFIO { get; private set; } = string.Empty; + public string ImplementerFIO { get; private set; } = string.Empty; - public string Password { get; private set; } = string.Empty; + public string Password { get; private set; } = string.Empty; - public int WorkExperience { get; private set; } + public int WorkExperience { get; private set; } - public int Qualification { get; private set; } + public int Qualification { get; private set; } - public static Implementer? Create(ImplementerBindingModel model) - { - if (model == null) - { - return null; - } - return new() - { - Id = model.Id, - Password = model.Password, - Qualification = model.Qualification, - ImplementerFIO = model.ImplementerFIO, - WorkExperience = model.WorkExperience, - }; - } + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + return new() + { + Id = model.Id, + Password = model.Password, + Qualification = model.Qualification, + ImplementerFIO = model.ImplementerFIO, + WorkExperience = model.WorkExperience, + }; + } - public void Update(ImplementerBindingModel model) - { - if (model == null) - { - return; - } - Password = model.Password; - Qualification = model.Qualification; - ImplementerFIO = model.ImplementerFIO; - WorkExperience = model.WorkExperience; - } + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + Password = model.Password; + Qualification = model.Qualification; + ImplementerFIO = model.ImplementerFIO; + WorkExperience = model.WorkExperience; + } - public ImplementerViewModel GetViewModel => new() - { - Id = Id, - Password = Password, - Qualification = Qualification, - ImplementerFIO = ImplementerFIO, - }; - } + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + Password = Password, + Qualification = Qualification, + WorkExperience = WorkExperience, + ImplementerFIO = ImplementerFIO, + }; + } } diff --git a/PrecastConcretePlantRestApi/Controllers/ImplementerController.cs b/PrecastConcretePlantRestApi/Controllers/ImplementerController.cs index c2a7709..5f76e29 100644 --- a/PrecastConcretePlantRestApi/Controllers/ImplementerController.cs +++ b/PrecastConcretePlantRestApi/Controllers/ImplementerController.cs @@ -46,7 +46,7 @@ namespace PrecastConcretePlantRestApi.Controllers { return _order.ReadList(new OrderSearchModel { - Status = new() { OrderStatus.Принят } + Statuses = new() { OrderStatus.Принят } }); } catch (Exception ex)