Compare commits
13 Commits
LabWork1
...
LabWork3Ha
| Author | SHA1 | Date | |
|---|---|---|---|
| 88df8068a5 | |||
| 2e0bf741a9 | |||
| ec67110d7c | |||
| ed1504beb1 | |||
| 313cd7b2c1 | |||
| 3923eacebd | |||
| 1a02b213fd | |||
| 322fd334ca | |||
| 0f18d6640b | |||
| b291b2963f | |||
| 9a3f4f5271 | |||
| 07dc91676c | |||
| 1cf8894318 |
@@ -0,0 +1,234 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class CarShopLogic : ICarShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarShopStorage _shopStorage;
|
||||
public CarShopLogic(ILogger<CarShopLogic> logger, ICarShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
|
||||
public bool AddCar(CarShopSearchModel model, ICarModel car, int quantity)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (quantity <= 0)
|
||||
{
|
||||
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(quantity));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddCarInShop. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddCarInShop element not found");
|
||||
return false;
|
||||
}
|
||||
var quantityCars = 0;
|
||||
foreach (var ShopCar in element.Cars)
|
||||
quantityCars += ShopCar.Value.Item2;
|
||||
if((quantityCars + quantity) > element.Fullness)
|
||||
{
|
||||
throw new ArgumentException("Превышена максимальная вместимость", nameof(quantity));
|
||||
}
|
||||
|
||||
|
||||
_logger.LogInformation("AddCarInShop find. Id:{Id}", element.Id);
|
||||
|
||||
if (element.Cars.TryGetValue(car.Id, out var pair))
|
||||
{
|
||||
element.Cars[car.Id] = (car, quantity + pair.Item2);
|
||||
_logger.LogInformation("AddCarInShop. Has been added {quantity} {car} in {ShopName}", quantity, car.CarName, element.ShopName);
|
||||
}
|
||||
else
|
||||
{
|
||||
element.Cars[car.Id] = (car, quantity);
|
||||
_logger.LogInformation("AddCarInShop. Has been added {quantity} new Car {car} in {ShopName}", quantity, car.CarName, element.ShopName);
|
||||
}
|
||||
|
||||
_shopStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
Adress = element.Adress,
|
||||
ShopName = element.ShopName,
|
||||
DateOpen = element.DateOpen,
|
||||
Fullness = element.Fullness,
|
||||
Cars = element.Cars
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddCar(ICarModel car, int quantity)
|
||||
{
|
||||
if (CheckShops(quantity))
|
||||
{
|
||||
foreach(var shop in ReadList(null))
|
||||
{
|
||||
if(quantity==0) return true;
|
||||
int OccupiedPlaces = 0;
|
||||
foreach(var ShopCar in shop.Cars)
|
||||
{
|
||||
OccupiedPlaces += ShopCar.Value.Item2;
|
||||
}
|
||||
int EmptyPlaces = shop.Fullness - OccupiedPlaces;
|
||||
if(EmptyPlaces > 0)
|
||||
{
|
||||
EmptyPlaces = EmptyPlaces > quantity ? quantity : EmptyPlaces;
|
||||
AddCar(new CarShopSearchModel { Id = shop.Id}, car, EmptyPlaces);
|
||||
quantity -= EmptyPlaces;
|
||||
if (quantity == 0) return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CheckShops( int quantity)
|
||||
{
|
||||
foreach(var shop in ReadList(null))
|
||||
{
|
||||
int OccupiedPlaces = 0;
|
||||
foreach(var car in shop.Cars)
|
||||
{
|
||||
OccupiedPlaces += car.Value.Item2;
|
||||
}
|
||||
int EmptyPlaces = shop.Fullness - OccupiedPlaces;
|
||||
quantity -= EmptyPlaces;
|
||||
}
|
||||
if(quantity <= 0)
|
||||
return true;
|
||||
else return false;
|
||||
|
||||
}
|
||||
|
||||
public bool Create(CarShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
model.Cars = new();
|
||||
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(CarShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public CarShopViewModel? ReadElement(CarShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<CarShopViewModel>? ReadList(CarShopSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id} ", model?.ShopName, model?.Id);
|
||||
|
||||
var list = (model == null) ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(CarShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
|
||||
}
|
||||
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(CarShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Shop. ShopName:{0}.Adress:{1}. Id: {2}", model.ShopName, model.Adress, model.Id);
|
||||
var element = _shopStorage.GetElement(new CarShopSearchModel
|
||||
{
|
||||
ShopName = model.ShopName
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id && element.ShopName == model.ShopName)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,14 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<ComponentLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly ICarShopLogic _carShopLogic;
|
||||
private readonly ICarStorage _carStorage;
|
||||
public OrderLogic(ILogger<ComponentLogic> logger, IOrderStorage orderStorage, ICarShopLogic carShopLogic, ICarStorage carStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_carShopLogic = carShopLogic;
|
||||
_carStorage = carStorage;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
@@ -58,7 +62,16 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
model.Status = newStatus;
|
||||
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
model.DateImplement = DateTime.Now;
|
||||
{
|
||||
model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
if (!_carShopLogic.AddCar(_carStorage.GetElement(new CarSearchModel { Id = model.CarId }), model.Count))
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Small places in shops");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantContracts.BindingModels
|
||||
{
|
||||
public class CarShopBindingModel : ICarShop
|
||||
{
|
||||
public string ShopName { get; set; } = String.Empty;
|
||||
|
||||
public string Adress { get; set; } = String.Empty ;
|
||||
|
||||
public DateTime DateOpen { get; set; } = new();
|
||||
public int Fullness { get; set; }
|
||||
|
||||
public Dictionary<int, (ICarModel, int)> Cars { get; set; } = new();
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace AutomobilePlantContracts.BindingModels
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICarShopLogic
|
||||
{
|
||||
List<CarShopViewModel>? ReadList(CarShopSearchModel? model);
|
||||
CarShopViewModel? ReadElement(CarShopSearchModel model);
|
||||
bool Create(CarShopBindingModel model);
|
||||
bool Update(CarShopBindingModel model);
|
||||
bool Delete(CarShopBindingModel model);
|
||||
bool AddCar(CarShopSearchModel model, ICarModel car, int quantity);
|
||||
bool CheckShops(int quantity);
|
||||
bool AddCar(ICarModel car, int quantity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantContracts.SearchModel
|
||||
{
|
||||
public class CarShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantContracts.StoragesContracts
|
||||
{
|
||||
public interface ICarShopStorage
|
||||
{
|
||||
List<CarShopViewModel> GetFullList();
|
||||
List<CarShopViewModel> GetFilteredList(CarShopSearchModel model);
|
||||
bool TrySell ( ICarModel car, int quantity);
|
||||
CarShopViewModel? GetElement(CarShopSearchModel model);
|
||||
CarShopViewModel? Insert(CarShopBindingModel model);
|
||||
CarShopViewModel? Update(CarShopBindingModel model);
|
||||
CarShopViewModel? Delete(CarShopBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantContracts.ViewModel
|
||||
{
|
||||
public class CarShopViewModel : ICarShop
|
||||
{
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = String.Empty;
|
||||
[DisplayName("Адрес")]
|
||||
public string Adress { get; set; } = String.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpen { get; set; } = new();
|
||||
[DisplayName("Наполненность")]
|
||||
public int Fullness { get; set; }
|
||||
|
||||
public Dictionary<int, (ICarModel, int)> Cars { get; set; } = new();
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace AutomobilePlantContracts.ViewModel
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
||||
|
||||
17
AutomobilePlant/AbstractAutoDataModels/Models/ICarShop.cs
Normal file
17
AutomobilePlant/AbstractAutoDataModels/Models/ICarShop.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataModels.Models
|
||||
{
|
||||
public interface ICarShop : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Adress { get; }
|
||||
DateTime DateOpen { get; }
|
||||
int Fullness { get; }
|
||||
Dictionary<int, (ICarModel, int)> Cars { get; }
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,13 @@ namespace AutomobilePlantListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Car> Cars { get; set; }
|
||||
public List<CarShop> Shops { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Cars = new List<Car>();
|
||||
Shops = new List<CarShop>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using AutomobilePlantListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantListImplement.Implements
|
||||
{
|
||||
public class CarShopStorege : ICarShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public CarShopStorege()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<CarShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<CarShopViewModel>();
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public List<CarShopViewModel> GetFilteredList(CarShopSearchModel model)
|
||||
{
|
||||
var result = new List<CarShopViewModel>();
|
||||
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.ShopName))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public CarShopViewModel? GetElement(CarShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public CarShopViewModel? Insert(CarShopBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (model.Id <= shop.Id)
|
||||
{
|
||||
model.Id = shop.Id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newShop = CarShop.Create(model);
|
||||
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Shops.Add(newShop);
|
||||
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public CarShopViewModel? Update(CarShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CarShopViewModel? Delete(CarShopBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public bool TrySell(ICarModel car, int quantity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
61
AutomobilePlant/AbstractAutoListImplement/Models/CarShop.cs
Normal file
61
AutomobilePlant/AbstractAutoListImplement/Models/CarShop.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantListImplement.Models
|
||||
{
|
||||
public class CarShop : ICarShop
|
||||
{
|
||||
public string ShopName { get; private set; } = String.Empty;
|
||||
|
||||
public string Adress { get; private set; } = String.Empty;
|
||||
|
||||
public DateTime DateOpen { get; private set; }
|
||||
public int Fullness { get; set; }
|
||||
|
||||
public Dictionary<int, (ICarModel, int)> Cars { get; private set; } = new ();
|
||||
|
||||
public int Id { get; private set; }
|
||||
public static CarShop? Create(CarShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new CarShop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Adress = model.Adress,
|
||||
DateOpen = model.DateOpen,
|
||||
Cars = new()
|
||||
};
|
||||
}
|
||||
public void Update(CarShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Adress = model.Adress;
|
||||
DateOpen = model.DateOpen;
|
||||
Cars = model.Cars;
|
||||
}
|
||||
public CarShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Adress = Adress,
|
||||
DateOpen = DateOpen,
|
||||
Cars = Cars
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantDataModels",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantContracts", "AbstractAutoContracts\AutomobilePlantContracts.csproj", "{4B515980-8AD9-48F3-886E-3C2A6B1E9D90}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantBusinessLogic", "AbstractAutoBusinessLogic\AutomobilePlantBusinessLogic.csproj", "{D57C726F-E5B4-4CB3-A754-D5F93295CE1E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantBusinessLogic", "AbstractAutoBusinessLogic\AutomobilePlantBusinessLogic.csproj", "{D57C726F-E5B4-4CB3-A754-D5F93295CE1E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantListImplement", "AbstractAutoListImplement\AutomobilePlantListImplement.csproj", "{305978E5-BFB5-47B0-94C9-2C5D06748BD6}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantListImplement", "AbstractAutoListImplement\AutomobilePlantListImplement.csproj", "{305978E5-BFB5-47B0-94C9-2C5D06748BD6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlant", "AutomobilePlant\AutomobilePlant.csproj", "{8DB13E4F-D083-40DD-B1C2-F3CF74B762C2}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlant", "AutomobilePlant\AutomobilePlant.csproj", "{8DB13E4F-D083-40DD-B1C2-F3CF74B762C2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomomilePlantFileImplement", "AutomomilePlantFileImplement\AutomomilePlantFileImplement.csproj", "{3EC099D5-0C5C-43F5-AC6D-09B4D7CE9D72}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantDataBaseImplements", "AutomobilePlantDataBaseImplements\AutomobilePlantDataBaseImplements.csproj", "{166A9D0A-A545-4634-811B-7BC2BC33631D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -39,6 +43,14 @@ Global
|
||||
{8DB13E4F-D083-40DD-B1C2-F3CF74B762C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8DB13E4F-D083-40DD-B1C2-F3CF74B762C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8DB13E4F-D083-40DD-B1C2-F3CF74B762C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3EC099D5-0C5C-43F5-AC6D-09B4D7CE9D72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3EC099D5-0C5C-43F5-AC6D-09B4D7CE9D72}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3EC099D5-0C5C-43F5-AC6D-09B4D7CE9D72}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3EC099D5-0C5C-43F5-AC6D-09B4D7CE9D72}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{166A9D0A-A545-4634-811B-7BC2BC33631D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{166A9D0A-A545-4634-811B-7BC2BC33631D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{166A9D0A-A545-4634-811B-7BC2BC33631D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{166A9D0A-A545-4634-811B-7BC2BC33631D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -19,12 +19,16 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractAutoBusinessLogic\AutomobilePlantBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\AbstractAutoListImplement\AutomobilePlantListImplement.csproj" />
|
||||
<ProjectReference Include="..\AutomobilePlantDataBaseImplements\AutomobilePlantDataBaseImplements.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
38
AutomobilePlant/AutomobilePlant/FormMain.Designer.cs
generated
38
AutomobilePlant/AutomobilePlant/FormMain.Designer.cs
generated
@@ -32,12 +32,15 @@
|
||||
this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.CreateOrderButton = new System.Windows.Forms.Button();
|
||||
this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
|
||||
this.OrderReadyButton = new System.Windows.Forms.Button();
|
||||
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
||||
this.UpdateListButton = new System.Windows.Forms.Button();
|
||||
this.AddShopCarButton = new System.Windows.Forms.Button();
|
||||
this.Sellbutton = new System.Windows.Forms.Button();
|
||||
this.MenuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@@ -58,7 +61,8 @@
|
||||
//
|
||||
this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ИзделияToolStripMenuItem,
|
||||
this.КомпонентыToolStripMenuItem});
|
||||
this.КомпонентыToolStripMenuItem,
|
||||
this.магазиныToolStripMenuItem});
|
||||
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
||||
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||
@@ -77,6 +81,13 @@
|
||||
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
||||
this.магазиныToolStripMenuItem.Text = "Магазины";
|
||||
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click);
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
@@ -143,11 +154,33 @@
|
||||
this.UpdateListButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
||||
//
|
||||
// AddShopCarButton
|
||||
//
|
||||
this.AddShopCarButton.Location = new System.Drawing.Point(832, 416);
|
||||
this.AddShopCarButton.Name = "AddShopCarButton";
|
||||
this.AddShopCarButton.Size = new System.Drawing.Size(143, 56);
|
||||
this.AddShopCarButton.TabIndex = 7;
|
||||
this.AddShopCarButton.Text = "Пополнить магазин";
|
||||
this.AddShopCarButton.UseVisualStyleBackColor = true;
|
||||
this.AddShopCarButton.Click += new System.EventHandler(this.AddShopCarButton_Click);
|
||||
//
|
||||
// Sellbutton
|
||||
//
|
||||
this.Sellbutton.Location = new System.Drawing.Point(832, 507);
|
||||
this.Sellbutton.Name = "Sellbutton";
|
||||
this.Sellbutton.Size = new System.Drawing.Size(143, 56);
|
||||
this.Sellbutton.TabIndex = 8;
|
||||
this.Sellbutton.Text = "Продать";
|
||||
this.Sellbutton.UseVisualStyleBackColor = true;
|
||||
this.Sellbutton.Click += new System.EventHandler(this.Sellbutton_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(989, 600);
|
||||
this.Controls.Add(this.Sellbutton);
|
||||
this.Controls.Add(this.AddShopCarButton);
|
||||
this.Controls.Add(this.UpdateListButton);
|
||||
this.Controls.Add(this.IssuedOrderButton);
|
||||
this.Controls.Add(this.OrderReadyButton);
|
||||
@@ -180,5 +213,8 @@
|
||||
private Button OrderReadyButton;
|
||||
private Button IssuedOrderButton;
|
||||
private Button UpdateListButton;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private Button AddShopCarButton;
|
||||
private Button Sellbutton;
|
||||
}
|
||||
}
|
||||
@@ -196,5 +196,37 @@ namespace AutomobilePlant
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddShopCarButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShopAdd));
|
||||
|
||||
if (service is FormShopAdd form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void Sellbutton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShopSell));
|
||||
|
||||
if (service is FormShopSell form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
181
AutomobilePlant/AutomobilePlant/FormShop.Designer.cs
generated
Normal file
181
AutomobilePlant/AutomobilePlant/FormShop.Designer.cs
generated
Normal file
@@ -0,0 +1,181 @@
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
partial class FormShop
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.CarGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.CarNameField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.CountField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.CarGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// CarGroupBox
|
||||
//
|
||||
this.CarGroupBox.Controls.Add(this.DataGridView);
|
||||
this.CarGroupBox.Location = new System.Drawing.Point(12, 13);
|
||||
this.CarGroupBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.CarGroupBox.Name = "CarGroupBox";
|
||||
this.CarGroupBox.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.CarGroupBox.Size = new System.Drawing.Size(825, 467);
|
||||
this.CarGroupBox.TabIndex = 5;
|
||||
this.CarGroupBox.TabStop = false;
|
||||
this.CarGroupBox.Text = "машиины";
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.DataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.DataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ID,
|
||||
this.CarNameField,
|
||||
this.CountField});
|
||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.DataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.DataGridView.Location = new System.Drawing.Point(7, 29);
|
||||
this.DataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.DataGridView.Name = "DataGridView";
|
||||
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
|
||||
this.DataGridView.RowHeadersWidth = 51;
|
||||
this.DataGridView.RowTemplate.Height = 25;
|
||||
this.DataGridView.Size = new System.Drawing.Size(762, 429);
|
||||
this.DataGridView.TabIndex = 0;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.MinimumWidth = 6;
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
this.ID.Width = 125;
|
||||
//
|
||||
// CarNameField
|
||||
//
|
||||
this.CarNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.CarNameField.HeaderText = "Машина";
|
||||
this.CarNameField.MinimumWidth = 6;
|
||||
this.CarNameField.Name = "CarNameField";
|
||||
//
|
||||
// CountField
|
||||
//
|
||||
this.CountField.HeaderText = "Количество";
|
||||
this.CountField.MinimumWidth = 6;
|
||||
this.CountField.Name = "CountField";
|
||||
this.CountField.Width = 125;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
this.UpdateButton.Location = new System.Drawing.Point(395, 505);
|
||||
this.UpdateButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.UpdateButton.Name = "UpdateButton";
|
||||
this.UpdateButton.Size = new System.Drawing.Size(126, 51);
|
||||
this.UpdateButton.TabIndex = 4;
|
||||
this.UpdateButton.Text = "Обновить";
|
||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(695, 505);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(126, 45);
|
||||
this.ButtonCancel.TabIndex = 7;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(548, 505);
|
||||
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(126, 45);
|
||||
this.SaveButton.TabIndex = 8;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(853, 568);
|
||||
this.Controls.Add(this.UpdateButton);
|
||||
this.Controls.Add(this.SaveButton);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.CarGroupBox);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
this.CarGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private GroupBox CarGroupBox;
|
||||
private Button UpdateButton;
|
||||
private DataGridView DataGridView;
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn CarNameField;
|
||||
private DataGridViewTextBoxColumn CountField;
|
||||
private Button ButtonCancel;
|
||||
private Button SaveButton;
|
||||
}
|
||||
}
|
||||
113
AutomobilePlant/AutomobilePlant/FormShop.cs
Normal file
113
AutomobilePlant/AutomobilePlant/FormShop.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarShopLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (ICarModel, int)> _carComponents;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormShop(ILogger<FormShop> logger, ICarShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_carComponents = new Dictionary<int, (ICarModel, int)>();
|
||||
}
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new CarShopSearchModel
|
||||
{
|
||||
Id =
|
||||
_id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
|
||||
_carComponents = view.Cars ?? new
|
||||
Dictionary<int, (ICarModel, int)>();
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка машин магазина");
|
||||
try
|
||||
{
|
||||
if (_carComponents != null)
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
foreach (var pc in _carComponents)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.CarName, pc.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки машин магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
60
AutomobilePlant/AutomobilePlant/FormShop.resx
Normal file
60
AutomobilePlant/AutomobilePlant/FormShop.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>
|
||||
142
AutomobilePlant/AutomobilePlant/FormShopAdd.Designer.cs
generated
Normal file
142
AutomobilePlant/AutomobilePlant/FormShopAdd.Designer.cs
generated
Normal file
@@ -0,0 +1,142 @@
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
partial class FormShopAdd
|
||||
{
|
||||
/// <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.ShopNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.CarComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.NameShopLabel = new System.Windows.Forms.Label();
|
||||
this.CarLabel = new System.Windows.Forms.Label();
|
||||
this.CountTextBox = new System.Windows.Forms.TextBox();
|
||||
this.CountLabel = new System.Windows.Forms.Label();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.CancelButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ShopNameComboBox
|
||||
//
|
||||
this.ShopNameComboBox.FormattingEnabled = true;
|
||||
this.ShopNameComboBox.Location = new System.Drawing.Point(113, 41);
|
||||
this.ShopNameComboBox.Name = "ShopNameComboBox";
|
||||
this.ShopNameComboBox.Size = new System.Drawing.Size(233, 28);
|
||||
this.ShopNameComboBox.TabIndex = 0;
|
||||
//
|
||||
// CarComboBox
|
||||
//
|
||||
this.CarComboBox.FormattingEnabled = true;
|
||||
this.CarComboBox.Location = new System.Drawing.Point(113, 93);
|
||||
this.CarComboBox.Name = "CarComboBox";
|
||||
this.CarComboBox.Size = new System.Drawing.Size(233, 28);
|
||||
this.CarComboBox.TabIndex = 1;
|
||||
//
|
||||
// NameShopLabel
|
||||
//
|
||||
this.NameShopLabel.AutoSize = true;
|
||||
this.NameShopLabel.Location = new System.Drawing.Point(12, 44);
|
||||
this.NameShopLabel.Name = "NameShopLabel";
|
||||
this.NameShopLabel.Size = new System.Drawing.Size(69, 20);
|
||||
this.NameShopLabel.TabIndex = 2;
|
||||
this.NameShopLabel.Text = "Магазин";
|
||||
//
|
||||
// CarLabel
|
||||
//
|
||||
this.CarLabel.AutoSize = true;
|
||||
this.CarLabel.Location = new System.Drawing.Point(12, 96);
|
||||
this.CarLabel.Name = "CarLabel";
|
||||
this.CarLabel.Size = new System.Drawing.Size(68, 20);
|
||||
this.CarLabel.TabIndex = 3;
|
||||
this.CarLabel.Text = "Изделие";
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
this.CountTextBox.Location = new System.Drawing.Point(113, 139);
|
||||
this.CountTextBox.Name = "CountTextBox";
|
||||
this.CountTextBox.Size = new System.Drawing.Size(233, 27);
|
||||
this.CountTextBox.TabIndex = 4;
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
this.CountLabel.AutoSize = true;
|
||||
this.CountLabel.Location = new System.Drawing.Point(12, 146);
|
||||
this.CountLabel.Name = "CountLabel";
|
||||
this.CountLabel.Size = new System.Drawing.Size(58, 20);
|
||||
this.CountLabel.TabIndex = 5;
|
||||
this.CountLabel.Text = "Кол-во";
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(130, 189);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(94, 44);
|
||||
this.SaveButton.TabIndex = 6;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
this.CancelButton.Location = new System.Drawing.Point(252, 189);
|
||||
this.CancelButton.Name = "CancelButton";
|
||||
this.CancelButton.Size = new System.Drawing.Size(94, 44);
|
||||
this.CancelButton.TabIndex = 7;
|
||||
this.CancelButton.Text = "Закрыть";
|
||||
this.CancelButton.UseVisualStyleBackColor = true;
|
||||
this.CancelButton.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormShopAdd
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(413, 245);
|
||||
this.Controls.Add(this.CancelButton);
|
||||
this.Controls.Add(this.SaveButton);
|
||||
this.Controls.Add(this.CountLabel);
|
||||
this.Controls.Add(this.CountTextBox);
|
||||
this.Controls.Add(this.CarLabel);
|
||||
this.Controls.Add(this.NameShopLabel);
|
||||
this.Controls.Add(this.CarComboBox);
|
||||
this.Controls.Add(this.ShopNameComboBox);
|
||||
this.Name = "FormShopAdd";
|
||||
this.Text = "FormShopAdd";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox ShopNameComboBox;
|
||||
private ComboBox CarComboBox;
|
||||
private Label NameShopLabel;
|
||||
private Label CarLabel;
|
||||
private TextBox CountTextBox;
|
||||
private Label CountLabel;
|
||||
private Button SaveButton;
|
||||
private Button CancelButton;
|
||||
}
|
||||
}
|
||||
104
AutomobilePlant/AutomobilePlant/FormShopAdd.cs
Normal file
104
AutomobilePlant/AutomobilePlant/FormShopAdd.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
public partial class FormShopAdd : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarShopLogic _shopLogic;
|
||||
private readonly ICarLogic _carLogic;
|
||||
private readonly List<CarShopViewModel>? _listShops;
|
||||
private readonly List<CarViewModel>? _listCars;
|
||||
public FormShopAdd(ILogger<FormShopAdd> logger, ICarShopLogic shopLogic, ICarLogic carLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_shopLogic = shopLogic;
|
||||
_carLogic = carLogic;
|
||||
_logger = logger;
|
||||
_listShops = shopLogic.ReadList(null);
|
||||
if (_listShops != null)
|
||||
{
|
||||
ShopNameComboBox.DisplayMember = "ShopName";
|
||||
ShopNameComboBox.ValueMember = "Id";
|
||||
ShopNameComboBox.DataSource = _listShops;
|
||||
ShopNameComboBox.SelectedItem = null;
|
||||
}
|
||||
|
||||
_listCars = carLogic.ReadList(null);
|
||||
if (_listCars != null)
|
||||
{
|
||||
CarComboBox.DisplayMember = "CarName";
|
||||
CarComboBox.ValueMember = "Id";
|
||||
CarComboBox.DataSource = _listCars;
|
||||
CarComboBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ShopNameComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CarComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление изделия в магазин");
|
||||
|
||||
try
|
||||
{
|
||||
var car = _carLogic.ReadElement(new()
|
||||
{
|
||||
Id = (int)CarComboBox.SelectedValue
|
||||
});
|
||||
|
||||
if (car == null)
|
||||
{
|
||||
throw new Exception("Не найдено изделие. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
var resultOperation = _shopLogic.AddCar(
|
||||
model: new() { Id = (int)ShopNameComboBox.SelectedValue },
|
||||
car: car,
|
||||
quantity: Convert.ToInt32(CountTextBox.Text)
|
||||
);
|
||||
|
||||
if (!resultOperation)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
AutomobilePlant/AutomobilePlant/FormShopAdd.resx
Normal file
60
AutomobilePlant/AutomobilePlant/FormShopAdd.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>
|
||||
263
AutomobilePlant/AutomobilePlant/FormShopCar.Designer.cs
generated
Normal file
263
AutomobilePlant/AutomobilePlant/FormShopCar.Designer.cs
generated
Normal file
@@ -0,0 +1,263 @@
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
partial class FormShopCar
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.ShopNameLabel = new System.Windows.Forms.Label();
|
||||
this.AdressLabel = new System.Windows.Forms.Label();
|
||||
this.ShopNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AdressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ComponentsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ComponentNameField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.CountField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.DateOpenPicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.FullnessnumericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.Fullness = new System.Windows.Forms.Label();
|
||||
this.ComponentsGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.FullnessnumericUpDown)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ShopNameLabel
|
||||
//
|
||||
this.ShopNameLabel.AutoSize = true;
|
||||
this.ShopNameLabel.Location = new System.Drawing.Point(14, 12);
|
||||
this.ShopNameLabel.Name = "ShopNameLabel";
|
||||
this.ShopNameLabel.Size = new System.Drawing.Size(84, 20);
|
||||
this.ShopNameLabel.TabIndex = 0;
|
||||
this.ShopNameLabel.Text = "Название: ";
|
||||
//
|
||||
// AdressLabel
|
||||
//
|
||||
this.AdressLabel.AutoSize = true;
|
||||
this.AdressLabel.Location = new System.Drawing.Point(14, 57);
|
||||
this.AdressLabel.Name = "AdressLabel";
|
||||
this.AdressLabel.Size = new System.Drawing.Size(51, 20);
|
||||
this.AdressLabel.TabIndex = 1;
|
||||
this.AdressLabel.Text = "Адрес";
|
||||
//
|
||||
// ShopNameTextBox
|
||||
//
|
||||
this.ShopNameTextBox.Location = new System.Drawing.Point(95, 8);
|
||||
this.ShopNameTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ShopNameTextBox.Name = "ShopNameTextBox";
|
||||
this.ShopNameTextBox.Size = new System.Drawing.Size(323, 27);
|
||||
this.ShopNameTextBox.TabIndex = 2;
|
||||
//
|
||||
// AdressTextBox
|
||||
//
|
||||
this.AdressTextBox.Location = new System.Drawing.Point(95, 53);
|
||||
this.AdressTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.AdressTextBox.Name = "AdressTextBox";
|
||||
this.AdressTextBox.Size = new System.Drawing.Size(323, 27);
|
||||
this.AdressTextBox.TabIndex = 3;
|
||||
//
|
||||
// ComponentsGroupBox
|
||||
//
|
||||
this.ComponentsGroupBox.Controls.Add(this.ButtonCancel);
|
||||
this.ComponentsGroupBox.Controls.Add(this.SaveButton);
|
||||
this.ComponentsGroupBox.Controls.Add(this.UpdateButton);
|
||||
this.ComponentsGroupBox.Controls.Add(this.DataGridView);
|
||||
this.ComponentsGroupBox.Location = new System.Drawing.Point(14, 107);
|
||||
this.ComponentsGroupBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ComponentsGroupBox.Name = "ComponentsGroupBox";
|
||||
this.ComponentsGroupBox.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ComponentsGroupBox.Size = new System.Drawing.Size(825, 467);
|
||||
this.ComponentsGroupBox.TabIndex = 5;
|
||||
this.ComponentsGroupBox.TabStop = false;
|
||||
this.ComponentsGroupBox.Text = "Машины";
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(674, 232);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(126, 45);
|
||||
this.ButtonCancel.TabIndex = 7;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(674, 79);
|
||||
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(126, 45);
|
||||
this.SaveButton.TabIndex = 8;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
this.UpdateButton.Location = new System.Drawing.Point(674, 142);
|
||||
this.UpdateButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.UpdateButton.Name = "UpdateButton";
|
||||
this.UpdateButton.Size = new System.Drawing.Size(126, 51);
|
||||
this.UpdateButton.TabIndex = 4;
|
||||
this.UpdateButton.Text = "Обновить";
|
||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.DataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
|
||||
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.DataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ID,
|
||||
this.ComponentNameField,
|
||||
this.CountField});
|
||||
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle5.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.DataGridView.DefaultCellStyle = dataGridViewCellStyle5;
|
||||
this.DataGridView.Location = new System.Drawing.Point(7, 29);
|
||||
this.DataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.DataGridView.Name = "DataGridView";
|
||||
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle6.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;
|
||||
this.DataGridView.RowHeadersWidth = 51;
|
||||
this.DataGridView.RowTemplate.Height = 25;
|
||||
this.DataGridView.Size = new System.Drawing.Size(641, 429);
|
||||
this.DataGridView.TabIndex = 0;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.MinimumWidth = 6;
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
this.ID.Width = 125;
|
||||
//
|
||||
// ComponentNameField
|
||||
//
|
||||
this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ComponentNameField.HeaderText = "Машина";
|
||||
this.ComponentNameField.MinimumWidth = 6;
|
||||
this.ComponentNameField.Name = "ComponentNameField";
|
||||
//
|
||||
// CountField
|
||||
//
|
||||
this.CountField.HeaderText = "Количество";
|
||||
this.CountField.MinimumWidth = 6;
|
||||
this.CountField.Name = "CountField";
|
||||
this.CountField.Width = 125;
|
||||
//
|
||||
// DateOpenPicker
|
||||
//
|
||||
this.DateOpenPicker.Location = new System.Drawing.Point(495, 12);
|
||||
this.DateOpenPicker.Name = "DateOpenPicker";
|
||||
this.DateOpenPicker.Size = new System.Drawing.Size(250, 27);
|
||||
this.DateOpenPicker.TabIndex = 6;
|
||||
//
|
||||
// FullnessnumericUpDown
|
||||
//
|
||||
this.FullnessnumericUpDown.Location = new System.Drawing.Point(595, 57);
|
||||
this.FullnessnumericUpDown.Name = "FullnessnumericUpDown";
|
||||
this.FullnessnumericUpDown.Size = new System.Drawing.Size(150, 27);
|
||||
this.FullnessnumericUpDown.TabIndex = 7;
|
||||
//
|
||||
// Fullness
|
||||
//
|
||||
this.Fullness.AutoSize = true;
|
||||
this.Fullness.Location = new System.Drawing.Point(469, 64);
|
||||
this.Fullness.Name = "Fullness";
|
||||
this.Fullness.Size = new System.Drawing.Size(103, 20);
|
||||
this.Fullness.TabIndex = 8;
|
||||
this.Fullness.Text = "Ограничение";
|
||||
//
|
||||
// FormShopCar
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(853, 664);
|
||||
this.Controls.Add(this.Fullness);
|
||||
this.Controls.Add(this.FullnessnumericUpDown);
|
||||
this.Controls.Add(this.DateOpenPicker);
|
||||
this.Controls.Add(this.ComponentsGroupBox);
|
||||
this.Controls.Add(this.AdressTextBox);
|
||||
this.Controls.Add(this.ShopNameTextBox);
|
||||
this.Controls.Add(this.AdressLabel);
|
||||
this.Controls.Add(this.ShopNameLabel);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormShopCar";
|
||||
this.Text = "Изделие";
|
||||
this.Load += new System.EventHandler(this.FormCar_Load);
|
||||
this.ComponentsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.FullnessnumericUpDown)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label ShopNameLabel;
|
||||
private Label AdressLabel;
|
||||
private TextBox ShopNameTextBox;
|
||||
private TextBox AdressTextBox;
|
||||
private GroupBox ComponentsGroupBox;
|
||||
private Button UpdateButton;
|
||||
private DataGridView DataGridView;
|
||||
private Button ButtonCancel;
|
||||
private Button SaveButton;
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn ComponentNameField;
|
||||
private DataGridViewTextBoxColumn CountField;
|
||||
private DateTimePicker DateOpenPicker;
|
||||
private NumericUpDown FullnessnumericUpDown;
|
||||
private Label Fullness;
|
||||
}
|
||||
}
|
||||
142
AutomobilePlant/AutomobilePlant/FormShopCar.cs
Normal file
142
AutomobilePlant/AutomobilePlant/FormShopCar.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
public partial class FormShopCar : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarShopLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (ICarModel, int)> _cars;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormShopCar(ILogger<FormCar> logger, ICarShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_cars = new Dictionary<int, (ICarModel, int)>();
|
||||
}
|
||||
private void FormCar_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделия");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new CarShopSearchModel
|
||||
{
|
||||
Id =
|
||||
_id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
ShopNameTextBox.Text = view.ShopName;
|
||||
AdressTextBox.Text = view.Adress;
|
||||
DateOpenPicker.Value = view.DateOpen;
|
||||
FullnessnumericUpDown.Value = view.Fullness;
|
||||
_cars = view.Cars ?? new
|
||||
Dictionary<int, (ICarModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка компонент изделия");
|
||||
try
|
||||
{
|
||||
if (_cars != null)
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
foreach (var pc in _cars)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.CarName, pc.Value.Item2 });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ShopNameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(AdressTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение изделия");
|
||||
try
|
||||
{
|
||||
var model = new CarShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = ShopNameTextBox.Text,
|
||||
DateOpen = DateTime.SpecifyKind(DateOpenPicker.Value, DateTimeKind.Utc) ,
|
||||
Adress = AdressTextBox.Text,
|
||||
Fullness = (int)FullnessnumericUpDown.Value,
|
||||
Cars = _cars
|
||||
};
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
60
AutomobilePlant/AutomobilePlant/FormShopCar.resx
Normal file
60
AutomobilePlant/AutomobilePlant/FormShopCar.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>
|
||||
123
AutomobilePlant/AutomobilePlant/FormShopCreate.Designer.cs
generated
Normal file
123
AutomobilePlant/AutomobilePlant/FormShopCreate.Designer.cs
generated
Normal file
@@ -0,0 +1,123 @@
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
partial class FormShopCreate
|
||||
{
|
||||
/// <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.ShopNameLabel = new System.Windows.Forms.Label();
|
||||
this.ShopNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AdressLabel = new System.Windows.Forms.Label();
|
||||
this.AdressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ShopNameLabel
|
||||
//
|
||||
this.ShopNameLabel.AutoSize = true;
|
||||
this.ShopNameLabel.Location = new System.Drawing.Point(22, 20);
|
||||
this.ShopNameLabel.Name = "ShopNameLabel";
|
||||
this.ShopNameLabel.Size = new System.Drawing.Size(84, 20);
|
||||
this.ShopNameLabel.TabIndex = 0;
|
||||
this.ShopNameLabel.Text = "Название: ";
|
||||
//
|
||||
// ShopNameTextBox
|
||||
//
|
||||
this.ShopNameTextBox.Location = new System.Drawing.Point(103, 16);
|
||||
this.ShopNameTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ShopNameTextBox.Name = "ShopNameTextBox";
|
||||
this.ShopNameTextBox.Size = new System.Drawing.Size(238, 27);
|
||||
this.ShopNameTextBox.TabIndex = 2;
|
||||
//
|
||||
// AdressLabel
|
||||
//
|
||||
this.AdressLabel.AutoSize = true;
|
||||
this.AdressLabel.Location = new System.Drawing.Point(46, 72);
|
||||
this.AdressLabel.Name = "AdressLabel";
|
||||
this.AdressLabel.Size = new System.Drawing.Size(58, 20);
|
||||
this.AdressLabel.TabIndex = 3;
|
||||
this.AdressLabel.Text = "Адресс";
|
||||
//
|
||||
// AdressTextBox
|
||||
//
|
||||
this.AdressTextBox.Location = new System.Drawing.Point(103, 68);
|
||||
this.AdressTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.AdressTextBox.Name = "AdressTextBox";
|
||||
this.AdressTextBox.Size = new System.Drawing.Size(238, 27);
|
||||
this.AdressTextBox.TabIndex = 4;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(154, 120);
|
||||
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(95, 31);
|
||||
this.SaveButton.TabIndex = 5;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(256, 120);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(86, 31);
|
||||
this.ButtonCancel.TabIndex = 6;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormShopCreate
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(375, 167);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.SaveButton);
|
||||
this.Controls.Add(this.AdressTextBox);
|
||||
this.Controls.Add(this.AdressLabel);
|
||||
this.Controls.Add(this.ShopNameTextBox);
|
||||
this.Controls.Add(this.ShopNameLabel);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormShopCreate";
|
||||
this.Text = "Магазин";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label ShopNameLabel;
|
||||
private TextBox ShopNameTextBox;
|
||||
private Label AdressLabel;
|
||||
private TextBox AdressTextBox;
|
||||
private Button SaveButton;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
||||
108
AutomobilePlant/AutomobilePlant/FormShopCreate.cs
Normal file
108
AutomobilePlant/AutomobilePlant/FormShopCreate.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
public partial class FormShopCreate : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarShopLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormShopCreate(ILogger<FormShopCreate> logger, ICarShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormShopCreate_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение магазина");
|
||||
|
||||
var view = _logic.ReadElement(new CarShopSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
ShopNameTextBox.Text = view.ShopName;
|
||||
AdressTextBox.Text = view.Adress.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ShopNameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(AdressTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
|
||||
try
|
||||
{
|
||||
var model = new CarShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = ShopNameTextBox.Text,
|
||||
Adress = AdressTextBox.Text,
|
||||
DateOpen = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc)
|
||||
};
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
AutomobilePlant/AutomobilePlant/FormShopCreate.resx
Normal file
60
AutomobilePlant/AutomobilePlant/FormShopCreate.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>
|
||||
118
AutomobilePlant/AutomobilePlant/FormShopSell.Designer.cs
generated
Normal file
118
AutomobilePlant/AutomobilePlant/FormShopSell.Designer.cs
generated
Normal file
@@ -0,0 +1,118 @@
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
partial class FormShopSell
|
||||
{
|
||||
/// <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.Carlabel = new System.Windows.Forms.Label();
|
||||
this.Countlabel = new System.Windows.Forms.Label();
|
||||
this.CarComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.CountnumericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.Sellbutton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.CountnumericUpDown)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Carlabel
|
||||
//
|
||||
this.Carlabel.AutoSize = true;
|
||||
this.Carlabel.Location = new System.Drawing.Point(42, 41);
|
||||
this.Carlabel.Name = "Carlabel";
|
||||
this.Carlabel.Size = new System.Drawing.Size(68, 20);
|
||||
this.Carlabel.TabIndex = 0;
|
||||
this.Carlabel.Text = "Машина";
|
||||
//
|
||||
// Countlabel
|
||||
//
|
||||
this.Countlabel.AutoSize = true;
|
||||
this.Countlabel.Location = new System.Drawing.Point(42, 101);
|
||||
this.Countlabel.Name = "Countlabel";
|
||||
this.Countlabel.Size = new System.Drawing.Size(90, 20);
|
||||
this.Countlabel.TabIndex = 1;
|
||||
this.Countlabel.Text = "Количество";
|
||||
//
|
||||
// CarComboBox
|
||||
//
|
||||
this.CarComboBox.FormattingEnabled = true;
|
||||
this.CarComboBox.Location = new System.Drawing.Point(161, 38);
|
||||
this.CarComboBox.Name = "CarComboBox";
|
||||
this.CarComboBox.Size = new System.Drawing.Size(151, 28);
|
||||
this.CarComboBox.TabIndex = 2;
|
||||
//
|
||||
// CountnumericUpDown
|
||||
//
|
||||
this.CountnumericUpDown.Location = new System.Drawing.Point(175, 99);
|
||||
this.CountnumericUpDown.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.CountnumericUpDown.Name = "CountnumericUpDown";
|
||||
this.CountnumericUpDown.Size = new System.Drawing.Size(137, 27);
|
||||
this.CountnumericUpDown.TabIndex = 3;
|
||||
this.CountnumericUpDown.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// Sellbutton
|
||||
//
|
||||
this.Sellbutton.Location = new System.Drawing.Point(123, 160);
|
||||
this.Sellbutton.Name = "Sellbutton";
|
||||
this.Sellbutton.Size = new System.Drawing.Size(94, 66);
|
||||
this.Sellbutton.TabIndex = 4;
|
||||
this.Sellbutton.Text = "Продать";
|
||||
this.Sellbutton.UseVisualStyleBackColor = true;
|
||||
this.Sellbutton.Click += new System.EventHandler(this.Sellbutton_Click);
|
||||
//
|
||||
// FormShopSell
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(362, 238);
|
||||
this.Controls.Add(this.Sellbutton);
|
||||
this.Controls.Add(this.CountnumericUpDown);
|
||||
this.Controls.Add(this.CarComboBox);
|
||||
this.Controls.Add(this.Countlabel);
|
||||
this.Controls.Add(this.Carlabel);
|
||||
this.Name = "FormShopSell";
|
||||
this.Text = "FormShopSell";
|
||||
((System.ComponentModel.ISupportInitialize)(this.CountnumericUpDown)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label Carlabel;
|
||||
private Label Countlabel;
|
||||
private ComboBox CarComboBox;
|
||||
private NumericUpDown CountnumericUpDown;
|
||||
private Button Sellbutton;
|
||||
}
|
||||
}
|
||||
56
AutomobilePlant/AutomobilePlant/FormShopSell.cs
Normal file
56
AutomobilePlant/AutomobilePlant/FormShopSell.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
public partial class FormShopSell : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarLogic _carLogic;
|
||||
private readonly List<CarViewModel>? _listCars;
|
||||
private readonly ICarShopStorage _carShopStorage;
|
||||
public FormShopSell(ILogger<FormShopAdd> logger, ICarLogic carLogic, ICarShopStorage carShopStorage)
|
||||
{
|
||||
InitializeComponent();
|
||||
_carLogic = carLogic;
|
||||
_logger = logger;
|
||||
_carShopStorage = carShopStorage;
|
||||
_listCars = carLogic.ReadList(null);
|
||||
if (_listCars != null)
|
||||
{
|
||||
CarComboBox.DisplayMember = "CarName";
|
||||
CarComboBox.ValueMember = "Id";
|
||||
CarComboBox.DataSource = _listCars;
|
||||
CarComboBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Sellbutton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var car = _carLogic.ReadElement(new CarSearchModel { Id = (int)CarComboBox.SelectedValue });
|
||||
bool Faith = _carShopStorage.TrySell(car, (int)CountnumericUpDown.Value);
|
||||
if(Faith)
|
||||
MessageBox.Show("Все ок!");
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ууууу, шо-то ты перестарался");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
60
AutomobilePlant/AutomobilePlant/FormShopSell.resx
Normal file
60
AutomobilePlant/AutomobilePlant/FormShopSell.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>
|
||||
135
AutomobilePlant/AutomobilePlant/FormShops.Designer.cs
generated
Normal file
135
AutomobilePlant/AutomobilePlant/FormShops.Designer.cs
generated
Normal file
@@ -0,0 +1,135 @@
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
partial class FormShops
|
||||
{
|
||||
/// <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.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ChangeButton = new System.Windows.Forms.Button();
|
||||
this.DeleteButton = new System.Windows.Forms.Button();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
this.SeeButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.DataGridView.Location = new System.Drawing.Point(1, 1);
|
||||
this.DataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.DataGridView.Name = "DataGridView";
|
||||
this.DataGridView.RowHeadersWidth = 51;
|
||||
this.DataGridView.RowTemplate.Height = 25;
|
||||
this.DataGridView.Size = new System.Drawing.Size(642, 660);
|
||||
this.DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
this.AddButton.Location = new System.Drawing.Point(669, 16);
|
||||
this.AddButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.AddButton.Name = "AddButton";
|
||||
this.AddButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.AddButton.TabIndex = 1;
|
||||
this.AddButton.Text = "Добавить";
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
this.ChangeButton.Location = new System.Drawing.Point(669, 95);
|
||||
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ChangeButton.Name = "ChangeButton";
|
||||
this.ChangeButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.ChangeButton.TabIndex = 2;
|
||||
this.ChangeButton.Text = "Изменить";
|
||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
this.DeleteButton.Location = new System.Drawing.Point(669, 173);
|
||||
this.DeleteButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.DeleteButton.Name = "DeleteButton";
|
||||
this.DeleteButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.DeleteButton.TabIndex = 3;
|
||||
this.DeleteButton.Text = "Удалить";
|
||||
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
this.UpdateButton.Location = new System.Drawing.Point(669, 255);
|
||||
this.UpdateButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.UpdateButton.Name = "UpdateButton";
|
||||
this.UpdateButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.UpdateButton.TabIndex = 4;
|
||||
this.UpdateButton.Text = "Обновить";
|
||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||
//
|
||||
// SeeButton
|
||||
//
|
||||
this.SeeButton.Location = new System.Drawing.Point(669, 338);
|
||||
this.SeeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SeeButton.Name = "SeeButton";
|
||||
this.SeeButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.SeeButton.TabIndex = 5;
|
||||
this.SeeButton.Text = "Посмотреть";
|
||||
this.SeeButton.UseVisualStyleBackColor = true;
|
||||
this.SeeButton.Click += new System.EventHandler(this.SeeButton_Click);
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(819, 669);
|
||||
this.Controls.Add(this.SeeButton);
|
||||
this.Controls.Add(this.UpdateButton);
|
||||
this.Controls.Add(this.DeleteButton);
|
||||
this.Controls.Add(this.ChangeButton);
|
||||
this.Controls.Add(this.AddButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormShops";
|
||||
this.Text = "Магазины";
|
||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
private Button SeeButton;
|
||||
}
|
||||
}
|
||||
140
AutomobilePlant/AutomobilePlant/FormShops.cs
Normal file
140
AutomobilePlant/AutomobilePlant/FormShops.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AutomobilePlant
|
||||
{
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarShopLogic _logic;
|
||||
|
||||
public FormShops(ILogger<FormShops> logger, ICarShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormComponents_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["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["Adress"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["DateOpen"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["Cars"].Visible = false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShopCar));
|
||||
|
||||
if (service is FormShopCar form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShopCar));
|
||||
|
||||
if (service is FormShopCar form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DeleteButton_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 CarShopBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void SeeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
|
||||
if (service is FormShop form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
60
AutomobilePlant/AutomobilePlant/FormShops.resx
Normal file
60
AutomobilePlant/AutomobilePlant/FormShops.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,7 +1,7 @@
|
||||
using AutomobilePlantBusinessLogic.BusinessLogics;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantListImplement.Implements;
|
||||
using AutomobilePlantDataBaseImplements.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
@@ -37,9 +37,13 @@ namespace AutomobilePlant
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ICarStorage, CarStorage>();
|
||||
services.AddTransient<ICarShopStorage, CarShopStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ICarLogic, CarLogic>();
|
||||
services.AddTransient<ICarShopLogic, CarShopLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
@@ -47,6 +51,12 @@ namespace AutomobilePlant
|
||||
services.AddTransient<FormCar>();
|
||||
services.AddTransient<FormCarComponent>();
|
||||
services.AddTransient<FormCars>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShopCar>();
|
||||
services.AddTransient<FormShopAdd>();
|
||||
services.AddTransient<FormShopCreate>();
|
||||
services.AddTransient<FormShopSell>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using AutomobilePlantDataBaseImplements.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements
|
||||
{
|
||||
public class AutoPlantDataBase : DbContext
|
||||
{
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Server=PostgreSQL;Host=localhost;Port=5432;Database=AutoPlantDataBaseHard;Username=postgres;Password=postgres");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Component> Components { set; get; }
|
||||
|
||||
public virtual DbSet<Car> Cars { set; get; }
|
||||
|
||||
public virtual DbSet<CarComponent> CarComponents { set; get; }
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<CarShop> CarShops { set; get; }
|
||||
public virtual DbSet<ShopCar> ShopCars { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractAutoContracts\AutomobilePlantContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,173 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataBaseImplements.Models;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Implements
|
||||
{
|
||||
public class CarShopStorage : ICarShopStorage
|
||||
{
|
||||
public CarShopViewModel? Delete(CarShopBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
var element = context.CarShops
|
||||
.Include(x => x.ShopCars)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.CarShops.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CarShopViewModel? GetElement(CarShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.CarShops
|
||||
.Include(x => x.ShopCars)
|
||||
.ThenInclude(x => x.Car)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName.Contains(model.ShopName)) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<CarShopViewModel> GetFilteredList(CarShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.CarShops
|
||||
.Include(x => x.ShopCars)
|
||||
.ThenInclude(x => x.Car)
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CarShopViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.CarShops
|
||||
.Include(x => x.ShopCars)
|
||||
.ThenInclude(x => x.Car)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CarShopViewModel? Insert(CarShopBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
var newShop = CarShop.Create(context, model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.CarShops.Add(newShop);
|
||||
context.SaveChanges();
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public bool TrySell(ICarModel car, int quantity)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
var shops = GetFullList();
|
||||
bool check = false;
|
||||
try
|
||||
{
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
if (shop.Cars.ContainsKey(car.Id))
|
||||
{
|
||||
if (shop.Cars[car.Id].Item2 > quantity)
|
||||
{
|
||||
shop.Cars[car.Id] = (shop.Cars[car.Id].Item1, shop.Cars[car.Id].Item2 - quantity);
|
||||
quantity = 0;
|
||||
check = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
quantity -= shop.Cars[car.Id].Item2;
|
||||
shop.Cars.Remove(car.Id);
|
||||
|
||||
}
|
||||
var shopFromDB = context.CarShops.FirstOrDefault(rec => rec.Id == shop.Id);
|
||||
shopFromDB.UpdateCars(context, new CarShopBindingModel
|
||||
{
|
||||
ShopName = shop.ShopName,
|
||||
Adress = shop.Adress,
|
||||
DateOpen = shop.DateOpen,
|
||||
Fullness = shop.Fullness,
|
||||
Id = shop.Id,
|
||||
Cars = shop.Cars,
|
||||
});
|
||||
if (check)
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (quantity == 0)
|
||||
{
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public CarShopViewModel? Update(CarShopBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var shop = context.CarShops.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
shop.Update(model);
|
||||
context.SaveChanges();
|
||||
shop.UpdateCars(context, model);
|
||||
transaction.Commit();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataBaseImplements.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Implements
|
||||
{
|
||||
public class CarStorage : ICarStorage
|
||||
{
|
||||
public List<CarViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Cars
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CarViewModel> GetFilteredList(CarSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.CarName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Cars
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.CarName.Contains(model.CarName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CarViewModel? GetElement(CarSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.CarName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Cars
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.CarName) && x.CarName == model.CarName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public CarViewModel? Insert(CarBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
var newCar = Car.Create(context, model);
|
||||
if (newCar == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Cars.Add(newCar);
|
||||
context.SaveChanges();
|
||||
return newCar.GetViewModel;
|
||||
}
|
||||
|
||||
public CarViewModel? Update(CarBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var car = context.Cars.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (car == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
car.Update(model);
|
||||
context.SaveChanges();
|
||||
car.UpdateComponents(context, model);
|
||||
transaction.Commit();
|
||||
return car.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public CarViewModel? Delete(CarBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
var element = context.Cars
|
||||
.Include(x => x.Components)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Cars.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataBaseImplements.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Implements
|
||||
{
|
||||
public class ComponentStorage : IComponentStorage
|
||||
{
|
||||
public List<ComponentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Components
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Components
|
||||
.Where(x => x.ComponentName.Contains(model.ComponentName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Components
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||
{
|
||||
var newComponent = Component.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
context.Components.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Components.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataBaseImplements.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Orders
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
return context.Orders
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoPlantDataBase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new AutoPlantDataBase();
|
||||
var element = context.Orders
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
175
AutomobilePlant/AutomobilePlantDataBaseImplements/Migrations/20230419145215_InitialMigration.Designer.cs
generated
Normal file
175
AutomobilePlant/AutomobilePlantDataBaseImplements/Migrations/20230419145215_InitialMigration.Designer.cs
generated
Normal file
@@ -0,0 +1,175 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutomobilePlantDataBaseImplements;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoPlantDataBase))]
|
||||
[Migration("20230419145215_InitialMigration")]
|
||||
partial class InitialMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CarName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("CarComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("CarName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarComponent", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "Car")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Component", "Component")
|
||||
.WithMany("CarComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "car")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("car");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("CarComponents");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cars",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CarName = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cars", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ComponentName = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CarId = table.Column<int>(type: "integer", nullable: false),
|
||||
CarName = table.Column<string>(type: "text", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Cars_CarId",
|
||||
column: x => x.CarId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CarId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarComponents_Cars_CarId",
|
||||
column: x => x.CarId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarComponents_CarId",
|
||||
table: "CarComponents",
|
||||
column: "CarId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarComponents_ComponentId",
|
||||
table: "CarComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_CarId",
|
||||
table: "Orders",
|
||||
column: "CarId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cars");
|
||||
}
|
||||
}
|
||||
}
|
||||
254
AutomobilePlant/AutomobilePlantDataBaseImplements/Migrations/20230502080521_Shops.Designer.cs
generated
Normal file
254
AutomobilePlant/AutomobilePlantDataBaseImplements/Migrations/20230502080521_Shops.Designer.cs
generated
Normal file
@@ -0,0 +1,254 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutomobilePlantDataBaseImplements;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoPlantDataBase))]
|
||||
[Migration("20230502080521_Shops")]
|
||||
partial class Shops
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CarName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("CarComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarShop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Adress")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Fullness")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CarShops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("CarName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.ShopCar", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarComponent", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "Car")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Component", "Component")
|
||||
.WithMany("CarComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "car")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("car");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.ShopCar", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "Car")
|
||||
.WithMany("ShopCars")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.CarShop", "CarShop")
|
||||
.WithMany("ShopCars")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("CarShop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("ShopCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarShop", b =>
|
||||
{
|
||||
b.Navigation("ShopCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("CarComponents");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Shops : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarShops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ShopName = table.Column<string>(type: "text", nullable: false),
|
||||
Adress = table.Column<string>(type: "text", nullable: false),
|
||||
DateOpen = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Fullness = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarShops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopCars",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ShopId = table.Column<int>(type: "integer", nullable: false),
|
||||
CarId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopCars", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopCars_CarShops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "CarShops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopCars_Cars_CarId",
|
||||
column: x => x.CarId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopCars_CarId",
|
||||
table: "ShopCars",
|
||||
column: "CarId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopCars_ShopId",
|
||||
table: "ShopCars",
|
||||
column: "ShopId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopCars");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarShops");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutomobilePlantDataBaseImplements;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoPlantDataBase))]
|
||||
partial class AutoPlantDataBaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CarName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("CarComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarShop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Adress")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Fullness")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CarShops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("CarName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.ShopCar", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarComponent", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "Car")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Component", "Component")
|
||||
.WithMany("CarComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "car")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("car");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.ShopCar", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.Car", "Car")
|
||||
.WithMany("ShopCars")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDataBaseImplements.Models.CarShop", "CarShop")
|
||||
.WithMany("ShopCars")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("CarShop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("ShopCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.CarShop", b =>
|
||||
{
|
||||
b.Navigation("ShopCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDataBaseImplements.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("CarComponents");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
106
AutomobilePlant/AutomobilePlantDataBaseImplements/Models/Car.cs
Normal file
106
AutomobilePlant/AutomobilePlantDataBaseImplements/Models/Car.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Models
|
||||
{
|
||||
public class Car : ICarModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string CarName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _carComponents = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> CarComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_carComponents == null)
|
||||
{
|
||||
_carComponents = Components
|
||||
.ToDictionary(recPC => recPC.ComponentId, recPC => (recPC.Component as IComponentModel, recPC.Count));
|
||||
}
|
||||
return _carComponents;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("CarId")]
|
||||
public virtual List<CarComponent> Components { get; set; } = new();
|
||||
|
||||
[ForeignKey("CarId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
[ForeignKey("CarId")]
|
||||
public virtual List<ShopCar> ShopCars { get; set; } = new();
|
||||
|
||||
public static Car Create(AutoPlantDataBase context, CarBindingModel model)
|
||||
{
|
||||
return new Car()
|
||||
{
|
||||
Id = model.Id,
|
||||
CarName = model.CarName,
|
||||
Price = model.Price,
|
||||
Components = model.CarComponents.Select(x => new CarComponent
|
||||
{
|
||||
Component = context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CarBindingModel model)
|
||||
{
|
||||
CarName = model.CarName;
|
||||
Price = model.Price;
|
||||
}
|
||||
|
||||
public CarViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CarName = CarName,
|
||||
Price = Price,
|
||||
CarComponents = CarComponents
|
||||
};
|
||||
|
||||
public void UpdateComponents(AutoPlantDataBase context, CarBindingModel model)
|
||||
{
|
||||
var carComponents = context.CarComponents.Where(rec => rec.CarId == model.Id).ToList();
|
||||
if (carComponents != null && carComponents.Count > 0)
|
||||
{
|
||||
context.CarComponents.RemoveRange(carComponents.Where(rec => !model.CarComponents.ContainsKey(rec.ComponentId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateComponent in carComponents)
|
||||
{
|
||||
updateComponent.Count = model.CarComponents[updateComponent.ComponentId].Item2;
|
||||
model.CarComponents.Remove(updateComponent.ComponentId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var car = context.Cars.First(x => x.Id == Id);
|
||||
foreach (var pc in model.CarComponents)
|
||||
{
|
||||
context.CarComponents.Add(new CarComponent
|
||||
{
|
||||
Car = car,
|
||||
Component = context.Components.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_carComponents = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Models
|
||||
{
|
||||
public class CarComponent
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CarId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ComponentId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Component Component { get; set; } = new();
|
||||
|
||||
public virtual Car Car { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Models
|
||||
{
|
||||
public class CarShop : ICarShop
|
||||
{
|
||||
[Required]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Adress { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime DateOpen { get; set; }
|
||||
[Required]
|
||||
public int Fullness { get; set; }
|
||||
public Dictionary<int, (ICarModel, int)> _ShopCars = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (ICarModel, int)> Cars
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ShopCars == null)
|
||||
{
|
||||
_ShopCars = ShopCars
|
||||
.ToDictionary(recPC => recPC.CarId, recPC => (recPC.Car as ICarModel, recPC.Count));
|
||||
}
|
||||
return _ShopCars;
|
||||
}
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("ShopId")]
|
||||
public virtual List<ShopCar> ShopCars { get; set; } = new();
|
||||
public static CarShop Create(AutoPlantDataBase context, CarShopBindingModel model)
|
||||
{
|
||||
return new CarShop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Adress = model.Adress,
|
||||
DateOpen = model.DateOpen,
|
||||
Fullness = model.Fullness,
|
||||
ShopCars = model.Cars.Select(x => new ShopCar
|
||||
{
|
||||
Car = context.Cars.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CarShopBindingModel model)
|
||||
{
|
||||
ShopName = model.ShopName;
|
||||
Adress = model.Adress;
|
||||
Fullness = model.Fullness;
|
||||
|
||||
}
|
||||
|
||||
public CarShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Adress = Adress,
|
||||
DateOpen = DateOpen,
|
||||
Fullness = Fullness,
|
||||
Cars = Cars
|
||||
};
|
||||
|
||||
public void UpdateCars(AutoPlantDataBase context, CarShopBindingModel model)
|
||||
{
|
||||
var shopCars = context.ShopCars.Where(rec => rec.ShopId == model.Id).ToList();
|
||||
if (shopCars != null && shopCars.Count > 0)
|
||||
{
|
||||
context.ShopCars.RemoveRange(shopCars.Where(rec => !model.Cars.ContainsKey(rec.CarId)));
|
||||
context.SaveChanges();
|
||||
shopCars = context.ShopCars.Where(rec => rec.ShopId == model.Id).ToList();
|
||||
foreach (var updateCar in shopCars)
|
||||
{
|
||||
updateCar.Count = model.Cars[updateCar.CarId].Item2;
|
||||
model.Cars.Remove(updateCar.CarId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
var shop = context.CarShops.First(x => x.Id == Id);
|
||||
foreach (var pc in model.Cars)
|
||||
{
|
||||
context.ShopCars.Add(new ShopCar
|
||||
{
|
||||
CarShop = shop,
|
||||
Car = context.Cars.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_ShopCars = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<CarComponent> CarComponents { get; set; } = new();
|
||||
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
|
||||
public static Component Create(ComponentViewModel model)
|
||||
{
|
||||
return new Component
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComponentName = model.ComponentName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Enums;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int CarId { get; private set; }
|
||||
public string CarName { get; private set; }
|
||||
public Car car { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
CarId = model.CarId,
|
||||
CarName = model.CarName,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CarId = CarId,
|
||||
CarName = CarName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataBaseImplements.Models
|
||||
{
|
||||
public class ShopCar
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ShopId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CarId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual CarShop CarShop { get; set; } = new();
|
||||
|
||||
public virtual Car Car { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractAutoContracts\AutomobilePlantContracts.csproj" />
|
||||
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,67 @@
|
||||
using AutomomilePlantFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutomomilePlantFileImplement
|
||||
{
|
||||
public class DataFileSingleton
|
||||
{
|
||||
private static DataFileSingleton? instance;
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string CarFileName = "Car.xml";
|
||||
private readonly string CarShopFileName = "CarShop.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Car> Cars { get; private set; }
|
||||
public List<CarShop> CarShops { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new DataFileSingleton();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName,
|
||||
"Components", x => x.GetXElement);
|
||||
public void SaveCars() => SaveData(Cars, CarFileName,
|
||||
"Cars", x => x.GetXElement);
|
||||
public void SaveCarShops() => SaveData(CarShops, CarShopFileName,
|
||||
"CarShops", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x
|
||||
=> x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x =>
|
||||
Component.Create(x)!)!;
|
||||
Cars = LoadData(CarFileName, "Car", x =>
|
||||
Car.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
CarShops = LoadData(CarShopFileName, "CarShop", x => CarShop.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||
Func<XElement, T> selectFunction)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
return
|
||||
XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
||||
}
|
||||
return new List<T>();
|
||||
}
|
||||
private static void SaveData<T>(List<T> data, string filename, string
|
||||
xmlNodeName, Func<T, XElement> selectFunction)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
new XDocument(new XElement(xmlNodeName,
|
||||
data.Select(selectFunction).ToArray())).Save(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using AutomomilePlantFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Implements
|
||||
{
|
||||
public class CarShopStorage : ICarShopStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public CarShopStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CarShopViewModel? Delete(CarShopBindingModel model)
|
||||
{
|
||||
var element = source.CarShops.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.CarShops.Remove(element);
|
||||
source.SaveCarShops();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CarShopViewModel? GetElement(CarShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.CarShops
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName ==
|
||||
model.ShopName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<CarShopViewModel> GetFilteredList(CarShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.CarShops
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CarShopViewModel> GetFullList()
|
||||
{
|
||||
return source.CarShops
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
}
|
||||
|
||||
public CarShopViewModel? Insert(CarShopBindingModel model)
|
||||
{
|
||||
model.Id = source.CarShops.Count > 0 ? source.CarShops.Max(x =>
|
||||
x.Id) + 1 : 1;
|
||||
var newCarShop = CarShop.Create(model);
|
||||
if (newCarShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.CarShops.Add(newCarShop);
|
||||
source.SaveCarShops();
|
||||
return newCarShop.GetViewModel;
|
||||
}
|
||||
|
||||
public bool TrySell(ICarModel car, int quantity)
|
||||
{
|
||||
List<CarShopViewModel> carShops = new List<CarShopViewModel>();
|
||||
int fakeQuantity = quantity;
|
||||
foreach (var shop in GetFullList())
|
||||
{
|
||||
if (shop.Cars.ContainsKey(car.Id) )
|
||||
{
|
||||
carShops.Add(shop);
|
||||
fakeQuantity -= shop.Cars[car.Id].Item2;
|
||||
if(fakeQuantity < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fakeQuantity > 0)
|
||||
return false;
|
||||
foreach(var shop in carShops)
|
||||
{
|
||||
if(quantity-shop.Cars[car.Id].Item2 < 0)
|
||||
{
|
||||
shop.Cars[car.Id] = (shop.Cars[car.Id].Item1, shop.Cars[car.Id].Item2 - quantity);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
quantity -= shop.Cars[car.Id].Item2;
|
||||
shop.Cars.Remove(car.Id);
|
||||
}
|
||||
Update(new CarShopBindingModel
|
||||
{
|
||||
ShopName = shop.ShopName,
|
||||
Adress = shop.Adress,
|
||||
DateOpen = shop.DateOpen,
|
||||
Fullness = shop.Fullness,
|
||||
Id = shop.Id,
|
||||
Cars = shop.Cars
|
||||
});
|
||||
}
|
||||
; return true;
|
||||
}
|
||||
|
||||
public CarShopViewModel? Update(CarShopBindingModel model)
|
||||
{
|
||||
var shop = source.CarShops.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
shop.Update(model);
|
||||
source.SaveCarShops();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomomilePlantFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Implements
|
||||
{
|
||||
public class CarStorage : ICarStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public CarStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public CarViewModel? Delete(CarBindingModel model)
|
||||
{
|
||||
var element = source.Cars.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Cars.Remove(element);
|
||||
source.SaveCars();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CarViewModel? GetElement(CarSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.CarName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Cars
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.CarName) && x.CarName ==
|
||||
model.CarName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<CarViewModel> GetFilteredList(CarSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.CarName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Cars
|
||||
.Where(x => x.CarName.Contains(model.CarName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CarViewModel> GetFullList()
|
||||
{
|
||||
return source.Cars
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CarViewModel? Insert(CarBindingModel model)
|
||||
{
|
||||
model.Id = source.Cars.Count > 0 ? source.Cars.Max(x =>
|
||||
x.Id) + 1 : 1;
|
||||
var newCar = Car.Create(model);
|
||||
if (newCar == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Cars.Add(newCar);
|
||||
source.SaveCars();
|
||||
return newCar.GetViewModel;
|
||||
}
|
||||
|
||||
public CarViewModel? Update(CarBindingModel model)
|
||||
{
|
||||
var car = source.Cars.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (car == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
car.Update(model);
|
||||
source.SaveCars();
|
||||
return car.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomomilePlantFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Implements
|
||||
{
|
||||
public class ComponentStorage : IComponentStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public ComponentStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<ComponentViewModel> GetFullList()
|
||||
{
|
||||
return source.Components
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
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();
|
||||
}
|
||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
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)
|
||||
{
|
||||
model.Id = source.Components.Count > 0 ? source.Components.Max(x =>
|
||||
x.Id) + 1 : 1;
|
||||
var newComponent = Component.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Components.Add(newComponent);
|
||||
source.SaveComponents();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||
{
|
||||
var component = source.Components.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
source.SaveComponents();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||
{
|
||||
var element = source.Components.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Components.Remove(element);
|
||||
source.SaveComponents();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomomilePlantFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public OrderStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
var element = source.Orders.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Orders.Remove(element);
|
||||
source.SaveOrders();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Orders
|
||||
.FirstOrDefault(x =>
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x =>
|
||||
x.Id) + 1 : 1;
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Orders.Add(newOrder);
|
||||
source.SaveOrders();
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
var order = source.Orders.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
source.SaveOrders();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
100
AutomobilePlant/AutomomilePlantFileImplement/Models/Car.cs
Normal file
100
AutomobilePlant/AutomomilePlantFileImplement/Models/Car.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Models
|
||||
{
|
||||
public class Car : ICarModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string CarName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, int> Components { get; private set; } = new();
|
||||
private Dictionary<int, (IComponentModel, int)>? _carComponents =
|
||||
null;
|
||||
public Dictionary<int, (IComponentModel, int)> CarComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_carComponents == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_carComponents = Components.ToDictionary(x => x.Key, y =>
|
||||
((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!,
|
||||
y.Value));
|
||||
}
|
||||
return _carComponents;
|
||||
}
|
||||
}
|
||||
public static Car? Create(CarBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Car()
|
||||
{
|
||||
Id = model.Id,
|
||||
CarName = model.CarName,
|
||||
Price = model.Price,
|
||||
Components = model.CarComponents.ToDictionary(x => x.Key, x
|
||||
=> x.Value.Item2)
|
||||
};
|
||||
}
|
||||
public static Car? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Car()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
CarName = element.Element("CarName")!.Value,
|
||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
||||
Components =
|
||||
element.Element("CarComponents")!.Elements("CarComponent")
|
||||
.ToDictionary(x =>
|
||||
Convert.ToInt32(x.Element("Key")?.Value), x =>
|
||||
Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
public void Update(CarBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CarName = model.CarName;
|
||||
Price = model.Price;
|
||||
Components = model.CarComponents.ToDictionary(x => x.Key, x =>
|
||||
x.Value.Item2);
|
||||
_carComponents = null;
|
||||
}
|
||||
public CarViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CarName = CarName,
|
||||
Price = Price,
|
||||
CarComponents = CarComponents
|
||||
};
|
||||
public XElement GetXElement => new("Car",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("CarName", CarName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("CarComponents", Components.Select(x =>
|
||||
new XElement("CarComponent",
|
||||
|
||||
new XElement("Key", x.Key),
|
||||
|
||||
new XElement("Value", x.Value)))
|
||||
|
||||
.ToArray()));
|
||||
}
|
||||
}
|
||||
117
AutomobilePlant/AutomomilePlantFileImplement/Models/CarShop.cs
Normal file
117
AutomobilePlant/AutomomilePlantFileImplement/Models/CarShop.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Models
|
||||
{
|
||||
public class CarShop : ICarShop
|
||||
|
||||
{
|
||||
public string ShopName {get; set;} = String.Empty;
|
||||
|
||||
public string Adress { get; set; } = String.Empty;
|
||||
|
||||
public DateTime DateOpen { get; set; }
|
||||
|
||||
public int Fullness { get; set; }
|
||||
|
||||
public Dictionary<int, int> ShopCars { get; set; } = new();
|
||||
private Dictionary<int, (ICarModel, int)> _cars = null;
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, (ICarModel, int)> Cars
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cars == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_cars = ShopCars.ToDictionary(x => x.Key, y =>
|
||||
((source.Cars.FirstOrDefault(z => z.Id == y.Key) as ICarModel)!,
|
||||
y.Value));
|
||||
}
|
||||
return _cars;
|
||||
}
|
||||
}
|
||||
public static CarShop? Create(CarShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new CarShop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Fullness = model.Fullness,
|
||||
Adress = model.Adress,
|
||||
DateOpen = model.DateOpen,
|
||||
ShopCars = model.Cars.ToDictionary(x => x.Key, x
|
||||
=> x.Value.Item2)
|
||||
};
|
||||
}
|
||||
public static CarShop? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new CarShop()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Adress = element.Element("Adress")!.Value,
|
||||
DateOpen = DateTime.Parse(element.Element("DateOpen")!.Value),
|
||||
Fullness = Convert.ToInt32(element.Element("Fullness")!.Value),
|
||||
ShopCars =
|
||||
element.Element("Cars")!.Elements("ShopCar")
|
||||
.ToDictionary(x =>
|
||||
Convert.ToInt32(x.Element("Key")?.Value), x =>
|
||||
Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
public void Update(CarShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Adress = model.Adress;
|
||||
Fullness = model.Fullness;
|
||||
ShopCars = model.Cars.ToDictionary(x => x.Key, x =>
|
||||
x.Value.Item2);
|
||||
_cars = null;
|
||||
}
|
||||
public CarShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Adress = Adress,
|
||||
DateOpen = DateOpen,
|
||||
Fullness = Fullness,
|
||||
Cars = Cars
|
||||
};
|
||||
public XElement GetXElement => new("CarShop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Adress", Adress),
|
||||
new XElement("DateOpen", DateOpen.ToString()),
|
||||
new XElement("Fullness", Fullness.ToString()),
|
||||
new XElement("Cars", ShopCars.Select(x =>
|
||||
new XElement("ShopCar",
|
||||
|
||||
new XElement("Key", x.Key),
|
||||
|
||||
new XElement("Value", x.Value)))
|
||||
|
||||
.ToArray()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public static Component? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ComponentName = element.Element("ComponentName")!.Value,
|
||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
||||
};
|
||||
}
|
||||
public void Update(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComponentName = model.ComponentName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
};
|
||||
public XElement GetXElement => new("Component",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ComponentName", ComponentName),
|
||||
new XElement("Cost", Cost.ToString())
|
||||
);
|
||||
}
|
||||
}
|
||||
100
AutomobilePlant/AutomomilePlantFileImplement/Models/Order.cs
Normal file
100
AutomobilePlant/AutomomilePlantFileImplement/Models/Order.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using AutomobilePlantDataModels.Enums;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutomomilePlantFileImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int CarId { get; private set; }
|
||||
|
||||
public string CarName { get; private set; } = string.Empty;
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; } = null;
|
||||
|
||||
public int Id { get; private set; }
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
CarId = model.CarId,
|
||||
CarName = model.CarName,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Id = model.Id
|
||||
};
|
||||
}
|
||||
public static Order? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
CarId = Convert.ToInt32(element.Element("CarId")!.Value),
|
||||
CarName= element.Element("CarName")!.Value,
|
||||
Count= Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum= Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status= (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
DateCreate=DateTime.Parse(element.Element("DateCreate")!.Value),
|
||||
DateImplement= string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : DateTime.Parse(element.Element("DateImplement")!.Value)
|
||||
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CarId = CarId,
|
||||
CarName = CarName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
public XElement GetXElement => new("Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("CarId", CarId.ToString()),
|
||||
new XElement("CarName", CarName),
|
||||
new XElement("Count", Count.ToString()),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("Status", Status.ToString()),
|
||||
new XElement("DateCreate", DateCreate.ToString()),
|
||||
new XElement("DateImplement", DateImplement.ToString())
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user