PIbd-23 Firsov Kirill LabWork 02 #3

Closed
Firsov_Kirill wants to merge 2 commits from LabWork#2 into LabWork#1
8 changed files with 30 additions and 32 deletions
Showing only changes of commit 40b82024d2 - Show all commits

View File

@ -3,6 +3,12 @@ using ClothShopContracts.SearchModels;
using ClothShopContracts.StoragesContracts;
using ClothShopContracts.ViewModels;
using ClothShopFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClothShopFileImplement.Implements
{
public class ComponentStorage : IComponentStorage
@ -14,21 +20,15 @@ namespace ClothShopFileImplement.Implements
}
public List<ComponentViewModel> GetFullList()
{
return source.Components
.Select(x => x.GetViewModel)
.ToList();
return source.Components.Select(x => x.GetViewModel).ToList();
}
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
model)
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName))
{
return new();
}
return source.Components
.Where(x => x.ComponentName.Contains(model.ComponentName))
.Select(x => x.GetViewModel)
.ToList();
return source.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
}
public ComponentViewModel? GetElement(ComponentSearchModel model)
{
@ -36,12 +36,8 @@ namespace ClothShopFileImplement.Implements
{
return null;
}
return source.Components
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName ==
model.ComponentName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
return source.Components.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public ComponentViewModel? Insert(ComponentBindingModel model)
{
@ -58,8 +54,7 @@ namespace ClothShopFileImplement.Implements
}
public ComponentViewModel? Update(ComponentBindingModel model)
{
var component = source.Components.FirstOrDefault(x => x.Id ==
model.Id);
var component = source.Components.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
@ -70,8 +65,7 @@ namespace ClothShopFileImplement.Implements
}
public ComponentViewModel? Delete(ComponentBindingModel model)
{
var element = source.Components.FirstOrDefault(x => x.Id ==
model.Id);
var element = source.Components.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Components.Remove(element);
@ -82,4 +76,3 @@ namespace ClothShopFileImplement.Implements
}
}
}

View File

@ -1,7 +1,13 @@
using ClothShopContracts.BindingModels;
using ClothShopContracts.ViewModels;
using ClothShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ClothShopFileImplement.Models
{
public class Component : IComponentModel
@ -51,9 +57,8 @@ namespace ClothShopFileImplement.Models
Cost = Cost
};
public XElement GetXElement => new("Component",
new XAttribute("Id", Id),
new XElement("ComponentName", ComponentName),
new XElement("Cost", Cost.ToString()));
new XAttribute("Id", Id),
new XElement("ComponentName", ComponentName),
new XElement("Cost", Cost.ToString()));
}
}
}

View File

@ -98,8 +98,8 @@
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormComponents";
this.Text = "FormComponents";
this.Click += new System.EventHandler(this.FormComponents_Load);
this.Text = "Компоненты";
this.Load += new System.EventHandler(this.FormComponents_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);

View File

@ -126,7 +126,7 @@
this.Controls.Add(this.labelTextile);
this.Controls.Add(this.comboBoxTextile);
this.Name = "FormCreateOrder";
this.Text = "FormCreateOrder";
this.Text = "Создать заказ";
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -152,7 +152,7 @@
this.Controls.Add(this.buttonTakeOrderInWork);
this.Controls.Add(this.buttonCreateOrder);
this.Name = "FormMain";
this.Text = "FormMain";
this.Text = "Заказы";
this.Load += new System.EventHandler(this.FormMain_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.menuStrip.ResumeLayout(false);

View File

@ -204,7 +204,7 @@
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Name = "FormTextile";
this.Text = "FormTextile";
this.Text = "Изделия";
this.Load += new System.EventHandler(this.FormTextile_Load);
this.groupBoxComponents.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridViewComponents)).EndInit();

View File

@ -102,7 +102,7 @@
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelComponent);
this.Name = "FormTextileComponent";
this.Text = "FormTextileComponent";
this.Text = "Компонет изделия";
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -98,7 +98,7 @@
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormTextiles";
this.Text = "FormTextiles";
this.Text = "Изделия";
this.Load += new System.EventHandler(this.FormTextiles_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);