Compare commits
No commits in common. "LabWork03" and "main" have entirely different histories.
@ -1,9 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,17 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,118 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AbstractSoftwareInstallationDataModels;
|
||||
|
||||
namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage OrderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = OrderStorage;
|
||||
}
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.PackageId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор у суши", nameof(model.PackageId));
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество суши в заказе должно быть больше 0", nameof(model.Count));
|
||||
}
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
_logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. PackageId: { PackageId}", model.Id, model.Sum, model.PackageId);
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Orderid:{ Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (model.Status != OrderStatus.Неизвестен)
|
||||
{
|
||||
_logger.LogWarning("Order status is incorrect");
|
||||
return false;
|
||||
}
|
||||
model.Status = OrderStatus.Принят;
|
||||
model.DateCreate = DateTime.Now;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
model.Status = OrderStatus.Неизвестен;
|
||||
_logger.LogWarning("Failed to insert order into a storage");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus _newStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (viewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (viewModel.Status + 1 != _newStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + _newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
model.Status = _newStatus;
|
||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
else
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
CheckModel(model, false);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Готов);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class PackageLogic : IPackageLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPackageStorage _packageStorage;
|
||||
public PackageLogic(ILogger<PackageLogic> logger, IPackageStorage PackageStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_packageStorage = PackageStorage;
|
||||
}
|
||||
public List<PackageViewModel>? ReadList(PackageSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. PackageName:{PackageName}.Id:{ Id}", model?.PackageName, model?.Id);
|
||||
var list = model == null ? _packageStorage.GetFullList() : _packageStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public PackageViewModel? ReadElement(PackageSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. PackageName:{PackageName}.Id:{ Id}", model.PackageName, model.Id);
|
||||
var element = _packageStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(PackageBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_packageStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
public bool Update(PackageBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_packageStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(PackageBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_packageStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(PackageBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PackageName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия пакета",
|
||||
nameof(model.PackageName));
|
||||
}
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена пакета должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
_logger.LogInformation("Package. PackageName:{PackageName}.Price:{Price}. Id: {Id}", model.PackageName, model.Price, model.Id);
|
||||
var element = _packageStorage.GetElement(new PackageSearchModel
|
||||
{
|
||||
PackageName = model.PackageName
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Пакет с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace AbstractSoftwareInstallationBusinessLogic
|
||||
{
|
||||
public class SoftwareLogic : ISoftwareLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISoftwareStorage _softwareStorage;
|
||||
public SoftwareLogic(ILogger<SoftwareLogic> logger, ISoftwareStorage SoftwareStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_softwareStorage = SoftwareStorage;
|
||||
}
|
||||
public List<SoftwareViewModel>? ReadList(SoftwareSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. SoftwareName:{SoftwareName}.Id:{ Id}", model?.SoftwareName, model?.Id);
|
||||
var list = model == null ? _softwareStorage.GetFullList() : _softwareStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public SoftwareViewModel? ReadElement(SoftwareSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. SoftwareName:{SoftwareName}.Id:{ Id}", model.SoftwareName, model.Id);
|
||||
var element = _softwareStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(SoftwareBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_softwareStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
public bool Update(SoftwareBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_softwareStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(SoftwareBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_softwareStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(SoftwareBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.SoftwareName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия ПО", nameof(model.SoftwareName));
|
||||
}
|
||||
if (model.Cost <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена ПО должна быть больше 0", nameof(model.Cost));
|
||||
}
|
||||
_logger.LogInformation("Software. SoftwareName:{SoftwareName}.Cost:{ Cost}. Id: { Id}", model.SoftwareName, model.Cost, model.Id);
|
||||
var element = _softwareStorage.GetElement(new SoftwareSearchModel
|
||||
{
|
||||
SoftwareName = model.SoftwareName
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("ПО с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}}
|
@ -1,13 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,21 +0,0 @@
|
||||
using AbstractSoftwareInstallationDataModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
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? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.BindingModels
|
||||
{
|
||||
public class PackageBindingModel : IPackageModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string PackageName { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware{get;set;} = new();
|
||||
public object PackageSoftwares { get; set; }
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.BindingModels
|
||||
{
|
||||
public class SoftwareBindingModel : ISoftwareModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string SoftwareName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IPackageLogic
|
||||
{
|
||||
List<PackageViewModel>? ReadList(PackageSearchModel? model);
|
||||
PackageViewModel? ReadElement(PackageSearchModel model);
|
||||
bool Create(PackageBindingModel model);
|
||||
bool Update(PackageBindingModel model);
|
||||
bool Delete(PackageBindingModel model);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ISoftwareLogic
|
||||
{
|
||||
List<SoftwareViewModel>? ReadList(SoftwareSearchModel? model);
|
||||
SoftwareViewModel? ReadElement(SoftwareSearchModel model);
|
||||
bool Create(SoftwareBindingModel model);
|
||||
bool Update(SoftwareBindingModel model);
|
||||
bool Delete(SoftwareBindingModel model);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.SearchModels
|
||||
{
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.SearchModels
|
||||
{
|
||||
public class PackageSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? PackageName { get; set; }
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.SearchModels
|
||||
{
|
||||
public class SoftwareSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? SoftwareName { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.StoragesContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.StoragesContracts
|
||||
{
|
||||
public interface IPackageStorage
|
||||
{
|
||||
List<PackageViewModel> GetFullList();
|
||||
List<PackageViewModel> GetFilteredList(PackageSearchModel model);
|
||||
PackageViewModel? GetElement(PackageSearchModel model);
|
||||
PackageViewModel? Insert(PackageBindingModel model);
|
||||
PackageViewModel? Update(PackageBindingModel model);
|
||||
PackageViewModel? Delete(PackageBindingModel model);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.StoragesContracts
|
||||
{
|
||||
public interface ISoftwareStorage
|
||||
{
|
||||
List<SoftwareViewModel> GetFullList();
|
||||
List<SoftwareViewModel> GetFilteredList(SoftwareSearchModel model);
|
||||
SoftwareViewModel? GetElement(SoftwareSearchModel model);
|
||||
SoftwareViewModel? Insert(SoftwareBindingModel model);
|
||||
SoftwareViewModel? Update(SoftwareBindingModel model);
|
||||
SoftwareViewModel? Delete(SoftwareBindingModel model);
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using AbstractSoftwareInstallationDataModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
|
||||
[DisplayName("Номер заказа")]
|
||||
public int Id { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
[DisplayName("Пакет")]
|
||||
public string PackageName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выдачи")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.ViewModels
|
||||
{
|
||||
public class PackageViewModel : IPackageModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя пакета")]
|
||||
public string PackageName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationContracts.ViewModels
|
||||
{
|
||||
public class SoftwareViewModel : ISoftwareModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название")]
|
||||
public string SoftwareName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int PackageId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDataModels.Models
|
||||
{
|
||||
public interface IPackageModel : IId
|
||||
{
|
||||
string PackageName { get; }
|
||||
double Price { get; }
|
||||
Dictionary<int, (ISoftwareModel, int)> PackageSoftware { get; }
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDataModels.Models
|
||||
{
|
||||
public interface ISoftwareModel : IId
|
||||
{
|
||||
string SoftwareName { get; }
|
||||
double Cost { get; }
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
namespace AbstractSoftwareInstallationDataModels
|
||||
{
|
||||
public enum OrderStatus
|
||||
{
|
||||
Неизвестен = -1,
|
||||
Принят = 0,
|
||||
Выполняется = 1,
|
||||
Готов = 2,
|
||||
Выдан = 3
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using AbstractPackageInstallationDatabaseImplement.Models;
|
||||
using AbstractSoftwareInstallationDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement
|
||||
{
|
||||
public class AbstractSoftwareInstallationDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder
|
||||
optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-QA8P9OJ;Initial Catalog=SogtwareInstallation;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Software> Softwares { set; get; }
|
||||
public virtual DbSet<Package> Packages { set; get; }
|
||||
public virtual DbSet<PackageSoftware> PackageSoftwares { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<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.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<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="..\AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj" />
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,91 +0,0 @@
|
||||
using AbstractPackageInstallationDatabaseImplement.Models;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Orders.Include(x => x.Package).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Package)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Package)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
var newOrder = Order.Create(model);
|
||||
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Package).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Package).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement.Implements
|
||||
{
|
||||
public class PackageStorage : IPackageStorage
|
||||
{
|
||||
public List<PackageViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Packages
|
||||
.Include(x => x.Softwares)
|
||||
.ThenInclude(x => x.Software)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PackageViewModel> GetFilteredList(PackageSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PackageName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Packages
|
||||
.Include(x => x.Softwares)
|
||||
.ThenInclude(x => x.Software)
|
||||
.Where(x => x.PackageName.Contains(model.PackageName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PackageViewModel? GetElement(PackageSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PackageName) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Packages
|
||||
.Include(x => x.Softwares)
|
||||
.ThenInclude(x => x.Software)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.PackageName)
|
||||
&& x.PackageName == model.PackageName)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public PackageViewModel? Insert(PackageBindingModel model)
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
var newPackage = Package.Create(context, model);
|
||||
if (newPackage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Packages.Add(newPackage);
|
||||
context.SaveChanges();
|
||||
return newPackage.GetViewModel;
|
||||
}
|
||||
|
||||
public PackageViewModel? Update(PackageBindingModel model)
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var Package = context.Packages.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (Package == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Package.Update(model);
|
||||
context.SaveChanges();
|
||||
Package.UpdateSoftwares(context, model);
|
||||
transaction.Commit();
|
||||
return Package.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public PackageViewModel? Delete(PackageBindingModel model)
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
var element = context.Packages
|
||||
.Include(x => x.Softwares)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Packages.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement.Implements
|
||||
{
|
||||
public class SoftwareStorage : ISoftwareStorage
|
||||
{
|
||||
public List<SoftwareViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Softwares
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<SoftwareViewModel> GetFilteredList(SoftwareSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SoftwareName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Softwares
|
||||
.Where(x => x.SoftwareName.Contains(model.SoftwareName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public SoftwareViewModel? GetElement(SoftwareSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SoftwareName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Softwares
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SoftwareName)
|
||||
&& x.SoftwareName == model.SoftwareName)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public SoftwareViewModel? Insert(SoftwareBindingModel model)
|
||||
{
|
||||
var newSoftware = Software.Create(model);
|
||||
if (newSoftware == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
context.Softwares.Add(newSoftware);
|
||||
context.SaveChanges();
|
||||
return newSoftware.GetViewModel;
|
||||
}
|
||||
|
||||
public SoftwareViewModel? Update(SoftwareBindingModel model)
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
var Software = context.Softwares.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Software == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Software.Update(model);
|
||||
context.SaveChanges();
|
||||
return Software.GetViewModel;
|
||||
}
|
||||
|
||||
public SoftwareViewModel? Delete(SoftwareBindingModel model)
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
var element = context.Softwares.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Softwares.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AbstractSoftwareInstallationDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AbstractSoftwareInstallationDatabase))]
|
||||
[Migration("20230419141439_Init")]
|
||||
partial class Init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AbstractPackageInstallationDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PackageName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Packages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.PackageSoftware", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SoftwareId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.HasIndex("SoftwareId");
|
||||
|
||||
b.ToTable("PackageSoftwares");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Software", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("SoftwareName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Softwares");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractPackageInstallationDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Package");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.PackageSoftware", b =>
|
||||
{
|
||||
b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Softwares")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Software", "Software")
|
||||
.WithMany("PackageSoftwares")
|
||||
.HasForeignKey("SoftwareId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Package");
|
||||
|
||||
b.Navigation("Software");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Softwares");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Software", b =>
|
||||
{
|
||||
b.Navigation("PackageSoftwares");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Packages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PackageName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Packages", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Softwares",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SoftwareName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Softwares", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PackageId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Packages_PackageId",
|
||||
column: x => x.PackageId,
|
||||
principalTable: "Packages",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PackageSoftwares",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PackageId = table.Column<int>(type: "int", nullable: false),
|
||||
SoftwareId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PackageSoftwares", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PackageSoftwares_Packages_PackageId",
|
||||
column: x => x.PackageId,
|
||||
principalTable: "Packages",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PackageSoftwares_Softwares_SoftwareId",
|
||||
column: x => x.SoftwareId,
|
||||
principalTable: "Softwares",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_PackageId",
|
||||
table: "Orders",
|
||||
column: "PackageId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PackageSoftwares_PackageId",
|
||||
table: "PackageSoftwares",
|
||||
column: "PackageId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PackageSoftwares_SoftwareId",
|
||||
table: "PackageSoftwares",
|
||||
column: "SoftwareId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PackageSoftwares");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Packages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Softwares");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AbstractSoftwareInstallationDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AbstractSoftwareInstallationDatabase))]
|
||||
partial class AbstractSoftwareInstallationDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AbstractPackageInstallationDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PackageName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Packages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.PackageSoftware", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SoftwareId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.HasIndex("SoftwareId");
|
||||
|
||||
b.ToTable("PackageSoftwares");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Software", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("SoftwareName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Softwares");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractPackageInstallationDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Package");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.PackageSoftware", b =>
|
||||
{
|
||||
b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Softwares")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Software", "Software")
|
||||
.WithMany("PackageSoftwares")
|
||||
.HasForeignKey("SoftwareId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Package");
|
||||
|
||||
b.Navigation("Software");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Softwares");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Software", b =>
|
||||
{
|
||||
b.Navigation("PackageSoftwares");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDatabaseImplement;
|
||||
using AbstractSoftwareInstallationDatabaseImplement.Models;
|
||||
using AbstractSoftwareInstallationDataModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractPackageInstallationDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int PackageId { 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.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public virtual Package Package { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order
|
||||
{
|
||||
PackageId = model.PackageId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Id = model.Id
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PackageId = PackageId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
PackageName = Package.PackageName
|
||||
};
|
||||
}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
using AbstractPackageInstallationDatabaseImplement.Models;
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDatabaseImplement.Models;
|
||||
using AbstractSoftwareInstallationDataModels;
|
||||
using AbstractSoftwareInstallationDataModels.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 AbstractSoftwareInstallationDatabaseImplement.Models
|
||||
{
|
||||
public class Package : IPackageModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string PackageName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; private set; }
|
||||
|
||||
private Dictionary<int, (ISoftwareModel, int)>? _packageSoftwares = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_packageSoftwares == null)
|
||||
{
|
||||
_packageSoftwares = Softwares.ToDictionary(recPC => recPC.SoftwareId, recPC => (recPC.Software as ISoftwareModel, recPC.Count));
|
||||
}
|
||||
return _packageSoftwares;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("PackageId")]
|
||||
public virtual List<PackageSoftware> Softwares { get; set; } = new();
|
||||
[ForeignKey("PackageId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
||||
|
||||
public static Package? Create(AbstractSoftwareInstallationDatabase context, PackageBindingModel model)
|
||||
{
|
||||
var Softwares = context.Softwares;
|
||||
|
||||
return new Package()
|
||||
{
|
||||
Id = model.Id,
|
||||
PackageName = model.PackageName,
|
||||
Price = model.Price,
|
||||
Softwares = model.PackageSoftware.Select(x => new PackageSoftware
|
||||
{
|
||||
Software = context.Softwares.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(PackageBindingModel model)
|
||||
{
|
||||
PackageName = model.PackageName;
|
||||
Price = model.Price;
|
||||
}
|
||||
public PackageViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PackageName = PackageName,
|
||||
Price = Price,
|
||||
PackageSoftware = PackageSoftware
|
||||
};
|
||||
|
||||
public void UpdateSoftwares(AbstractSoftwareInstallationDatabase context, PackageBindingModel model)
|
||||
{
|
||||
var packageSoftwares = context.PackageSoftwares
|
||||
.Where(rec => rec.PackageId == model.Id).ToList();
|
||||
if (packageSoftwares != null && packageSoftwares.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.PackageSoftwares.RemoveRange(packageSoftwares.Where(rec => !model.PackageSoftware.ContainsKey(rec.SoftwareId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateSoftware in packageSoftwares)
|
||||
{
|
||||
updateSoftware.Count = model.PackageSoftware[updateSoftware.SoftwareId].Item2;
|
||||
model.PackageSoftware.Remove(updateSoftware.SoftwareId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var package = context.Packages.First(x => x.Id == Id);
|
||||
foreach (var pc in model.PackageSoftware)
|
||||
{
|
||||
context.PackageSoftwares.Add(new PackageSoftware
|
||||
{
|
||||
Package = package,
|
||||
Software = context.Softwares.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_packageSoftwares = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationDatabaseImplement.Models
|
||||
{
|
||||
public class PackageSoftware
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int PackageId { get; set; }
|
||||
[Required]
|
||||
public int SoftwareId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Software Software { get; set; } = new();
|
||||
public virtual Package Package { get; set; } = new();
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels.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 AbstractSoftwareInstallationDatabaseImplement.Models
|
||||
{
|
||||
public class Software : ISoftwareModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string SoftwareName { get; private set; } = String.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[ForeignKey("SoftwareId")]
|
||||
public virtual List<PackageSoftware> PackageSoftwares { get; set; } = new();
|
||||
public static Software? Create(SoftwareBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Software()
|
||||
{
|
||||
Id = model.Id,
|
||||
SoftwareName = model.SoftwareName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public void Update(SoftwareBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SoftwareName = model.SoftwareName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public SoftwareViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SoftwareName = SoftwareName,
|
||||
Cost = Cost
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj" />
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,50 +0,0 @@
|
||||
using AbstractSoftwareInstallationFileImplement.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AbstractSoftwareInstallationFileImplement
|
||||
{
|
||||
internal class DataFileSingleton
|
||||
{
|
||||
|
||||
private static DataFileSingleton? instance;
|
||||
private readonly string SoftwareFileName = "Software.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string PackageFileName = "Package.xml";
|
||||
public List<Software> Softwares { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Package> Packages { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new DataFileSingleton();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public void SaveSoftwares() => SaveData(Softwares, SoftwareFileName, "Softwares", x => x.GetXElement);
|
||||
public void SavePackages() => SaveData(Packages, PackageFileName, "Packages", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Softwares = LoadData(SoftwareFileName, "Software", x => Software.Create(x)!)!;
|
||||
Packages = LoadData(PackageFileName, "Package", x => Package.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationFileImplement.Models;
|
||||
|
||||
namespace AbstractSoftwareInstallationFileImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public OrderStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return GetViewModel(source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders.Select(x => GetViewModel(x)).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 GetViewModel(newOrder);
|
||||
}
|
||||
|
||||
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 GetViewModel(order);
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Orders.Remove(order);
|
||||
source.SaveOrders();
|
||||
return GetViewModel(order);
|
||||
}
|
||||
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var package = source.Packages.FirstOrDefault(x => x.Id == order.PackageId);
|
||||
if (package != null)
|
||||
{
|
||||
viewModel.PackageName = package.PackageName;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationFileImplement.Implements
|
||||
{
|
||||
public class PackageStorage : IPackageStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public PackageStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public PackageViewModel? GetElement(PackageSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Packages
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.PackageName)
|
||||
&& x.PackageName == model.PackageName)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<PackageViewModel> GetFilteredList(PackageSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PackageName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Packages
|
||||
.Where(x => x.PackageName.Contains(model.PackageName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PackageViewModel> GetFullList()
|
||||
{
|
||||
return source.Packages.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public PackageViewModel? Insert(PackageBindingModel model)
|
||||
{
|
||||
model.Id = source.Packages.Count > 0 ? source.Packages.Max(x => x.Id) + 1 : 1;
|
||||
var newPackage = Package.Create(model);
|
||||
if (newPackage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Packages.Add(newPackage);
|
||||
source.SavePackages();
|
||||
return newPackage.GetViewModel;
|
||||
}
|
||||
|
||||
public PackageViewModel? Update(PackageBindingModel model)
|
||||
{
|
||||
var Package = source.Packages.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Package == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Package.Update(model);
|
||||
source.SavePackages();
|
||||
return Package.GetViewModel;
|
||||
}
|
||||
public PackageViewModel? Delete(PackageBindingModel model)
|
||||
{
|
||||
var Package = source.Packages.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Package == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Packages.Remove(Package);
|
||||
source.SavePackages();
|
||||
return Package.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationFileImplement.Models;
|
||||
|
||||
namespace AbstractSoftwareInstallationFileImplement.Implements
|
||||
{
|
||||
public class SoftwareStorage : ISoftwareStorage
|
||||
{
|
||||
private readonly DataFileSingleton _source;
|
||||
public SoftwareStorage()
|
||||
{
|
||||
_source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<SoftwareViewModel> GetFullList()
|
||||
{
|
||||
return _source.Softwares.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<SoftwareViewModel> GetFilteredList(SoftwareSearchModel
|
||||
model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SoftwareName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.Softwares.Where(x => x.SoftwareName.Contains(model.SoftwareName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public SoftwareViewModel? GetElement(SoftwareSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SoftwareName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _source.Softwares.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.SoftwareName)
|
||||
&& x.SoftwareName == model.SoftwareName)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public SoftwareViewModel? Insert(SoftwareBindingModel model)
|
||||
{
|
||||
model.Id = _source.Softwares.Count > 0 ? _source.Softwares.Max(x => x.Id) + 1 : 1;
|
||||
var newSoftware = Software.Create(model);
|
||||
if (newSoftware == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Softwares.Add(newSoftware);
|
||||
_source.SaveSoftwares();
|
||||
return newSoftware.GetViewModel;
|
||||
}
|
||||
public SoftwareViewModel? Update(SoftwareBindingModel model)
|
||||
{
|
||||
var software = _source.Softwares.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (software == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
software.Update(model);
|
||||
_source.SaveSoftwares();
|
||||
return software.GetViewModel;
|
||||
}
|
||||
public SoftwareViewModel? Delete(SoftwareBindingModel model)
|
||||
{
|
||||
var software = _source.Softwares.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (software == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Softwares.Remove(software);
|
||||
_source.SaveSoftwares();
|
||||
return software.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AbstractSoftwareInstallationFileImplement.Models
|
||||
{
|
||||
internal class Order : IOrderModel
|
||||
{
|
||||
public int PackageId { get; private set; }
|
||||
|
||||
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; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Order
|
||||
{
|
||||
PackageId = model.PackageId,
|
||||
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),
|
||||
PackageId = Convert.ToInt32(element.Element("PackageId")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : Convert.ToDateTime(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,
|
||||
PackageId = PackageId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
public XElement GetXElement => new(
|
||||
"Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("PackageId", PackageId.ToString()),
|
||||
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())
|
||||
);
|
||||
}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AbstractSoftwareInstallationFileImplement.Models
|
||||
{
|
||||
internal class Package : IPackageModel
|
||||
{
|
||||
public string PackageName { get; private set; } = string.Empty;
|
||||
|
||||
public double Price { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public Dictionary<int, int> Softwares { get; private set; } = new();
|
||||
|
||||
private Dictionary<int, (ISoftwareModel, int)>? _PackageSoftware = null;
|
||||
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_PackageSoftware == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_PackageSoftware = Softwares.ToDictionary(
|
||||
x => x.Key,
|
||||
y => ((source.Softwares.FirstOrDefault(z => z.Id == y.Key) as ISoftwareModel)!, y.Value)
|
||||
);
|
||||
}
|
||||
return _PackageSoftware;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Package? Create(PackageBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Package()
|
||||
{
|
||||
Id = model.Id,
|
||||
PackageName = model.PackageName,
|
||||
Price = model.Price,
|
||||
Softwares = model.PackageSoftware.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||
};
|
||||
}
|
||||
|
||||
public static Package? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Package()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
PackageName = element.Element("PackageName")!.Value,
|
||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
||||
Softwares = element.Element("PackageSoftware")!.Elements("PackageSoftware").ToDictionary(
|
||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void Update(PackageBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PackageName = model.PackageName;
|
||||
Price = model.Price;
|
||||
Softwares = model.PackageSoftware.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_PackageSoftware = null;
|
||||
}
|
||||
public PackageViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PackageName = PackageName,
|
||||
Price = Price,
|
||||
PackageSoftware = PackageSoftware
|
||||
};
|
||||
|
||||
public XElement GetXElement => new(
|
||||
"Package",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("PackageName", PackageName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("PackageSoftware", Softwares.Select(x =>
|
||||
new XElement("PackageSoftware",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value)))
|
||||
.ToArray()));
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AbstractSoftwareInstallationFileImplement.Models
|
||||
{
|
||||
internal class Software : ISoftwareModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string SoftwareName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public static Software? Create(SoftwareBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Software()
|
||||
{
|
||||
Id = model.Id,
|
||||
SoftwareName = model.SoftwareName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public static Software? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Software()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
SoftwareName = element.Element("SoftwareName")!.Value,
|
||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
||||
};
|
||||
}
|
||||
public void Update(SoftwareBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SoftwareName = model.SoftwareName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public SoftwareViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SoftwareName = SoftwareName,
|
||||
Cost = Cost
|
||||
};
|
||||
public XElement GetXElement => new("Software",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("SoftwareName", SoftwareName),
|
||||
new XElement("Cost", Cost.ToString()));
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj" />
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,31 +0,0 @@
|
||||
using AbstractSoftwareInstallationListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationListImplement
|
||||
{
|
||||
public class DataListSingleton
|
||||
{
|
||||
private static DataListSingleton? _instance;
|
||||
public List<Software> Softwares { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Package> Packages { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Softwares = new List<Software>();
|
||||
Orders = new List<Order>();
|
||||
Packages = new List<Package>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new DataListSingleton();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationListImplement;
|
||||
using AbstractSoftwareInstallationListImplement.Models;
|
||||
|
||||
namespace AbstractOrderInstallationListImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
public OrderStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
{
|
||||
return GetViewModel(order);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id <= order.Id)
|
||||
{
|
||||
model.Id = order.Id + 1;
|
||||
}
|
||||
}
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Orders.Add(newOrder);
|
||||
return GetViewModel(newOrder);
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
order.Update(model);
|
||||
return GetViewModel(order);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Orders.Count; ++i)
|
||||
{
|
||||
if (_source.Orders[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Orders[i];
|
||||
_source.Orders.RemoveAt(i);
|
||||
return GetViewModel(element);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
foreach (var package in _source.Packages)
|
||||
{
|
||||
if (package.Id == order.PackageId)
|
||||
{
|
||||
viewModel.PackageName = package.PackageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationListImplement;
|
||||
using AbstractSoftwareInstallationListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractPackageInstallationListImplement.Implements
|
||||
{
|
||||
public class PackageStorage : IPackageStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public PackageStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<PackageViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<PackageViewModel>();
|
||||
foreach (var package in _source.Packages)
|
||||
{
|
||||
result.Add(package.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<PackageViewModel> GetFilteredList(PackageSearchModel
|
||||
model)
|
||||
{
|
||||
var result = new List<PackageViewModel>();
|
||||
if (string.IsNullOrEmpty(model.PackageName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var package in _source.Packages)
|
||||
{
|
||||
if (package.PackageName.Contains(model.PackageName))
|
||||
{
|
||||
result.Add(package.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public PackageViewModel? GetElement(PackageSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var package in _source.Packages)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.PackageName) &&
|
||||
package.PackageName == model.PackageName) ||
|
||||
(model.Id.HasValue && package.Id == model.Id))
|
||||
{
|
||||
return package.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public PackageViewModel? Insert(PackageBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var package in _source.Packages)
|
||||
{
|
||||
if (model.Id <= package.Id)
|
||||
{
|
||||
model.Id = package.Id + 1;
|
||||
}
|
||||
}
|
||||
var newPackage = Package.Create(model);
|
||||
if (newPackage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Packages.Add(newPackage);
|
||||
return newPackage.GetViewModel;
|
||||
}
|
||||
public PackageViewModel? Update(PackageBindingModel model)
|
||||
{
|
||||
foreach (var package in _source.Packages)
|
||||
{
|
||||
if (package.Id == model.Id)
|
||||
{
|
||||
package.Update(model);
|
||||
return package.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public PackageViewModel? Delete(PackageBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Packages.Count; ++i)
|
||||
{
|
||||
if (_source.Packages[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Packages[i];
|
||||
_source.Packages.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationListImplement.Models;
|
||||
|
||||
namespace AbstractSoftwareInstallationListImplement.Implements
|
||||
{
|
||||
public class SoftwareStorage : ISoftwareStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public SoftwareStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<SoftwareViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<SoftwareViewModel>();
|
||||
foreach (var component in _source.Softwares)
|
||||
{
|
||||
result.Add(component.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<SoftwareViewModel> GetFilteredList(SoftwareSearchModel
|
||||
model)
|
||||
{
|
||||
var result = new List<SoftwareViewModel>();
|
||||
if (string.IsNullOrEmpty(model.SoftwareName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var component in _source.Softwares)
|
||||
{
|
||||
if (component.SoftwareName.Contains(model.SoftwareName))
|
||||
{
|
||||
result.Add(component.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public SoftwareViewModel? GetElement(SoftwareSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SoftwareName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var software in _source.Softwares)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.SoftwareName) &&
|
||||
software.SoftwareName == model.SoftwareName) ||
|
||||
(model.Id.HasValue && software.Id == model.Id))
|
||||
{
|
||||
return software.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public SoftwareViewModel? Insert(SoftwareBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var software in _source.Softwares)
|
||||
{
|
||||
if (model.Id <= software.Id)
|
||||
{
|
||||
model.Id = software.Id + 1;
|
||||
}
|
||||
}
|
||||
var newSoftware = Software.Create(model);
|
||||
if (newSoftware == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Softwares.Add(newSoftware);
|
||||
return newSoftware.GetViewModel;
|
||||
}
|
||||
public SoftwareViewModel? Update(SoftwareBindingModel model)
|
||||
{
|
||||
foreach (var component in _source.Softwares)
|
||||
{
|
||||
if (component.Id == model.Id)
|
||||
{
|
||||
component.Update(model);
|
||||
return component.GetViewModel;
|
||||
}
|
||||
throw new ArgumentNullException("Новая цена", nameof(model.Cost));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public SoftwareViewModel? Delete(SoftwareBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Softwares.Count; ++i)
|
||||
{
|
||||
if (_source.Softwares[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Softwares[i];
|
||||
_source.Softwares.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
|
||||
namespace AbstractSoftwareInstallationListImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int PackageId { get; private set; }
|
||||
|
||||
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; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Order
|
||||
{
|
||||
PackageId = model.PackageId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Id = model.Id,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PackageId = PackageId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractSoftwareInstallationListImplement.Models
|
||||
{
|
||||
public class Package : IPackageModel
|
||||
{
|
||||
public string PackageName { get; private set; } = string.Empty;
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware { get; private set; } = new Dictionary<int, (ISoftwareModel, int)>();
|
||||
|
||||
public int Id { get; private set; }
|
||||
public static Package? Create(PackageBindingModel? model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Package
|
||||
{
|
||||
Id = model.Id,
|
||||
PackageName = model.PackageName,
|
||||
Price = model.Price,
|
||||
PackageSoftware = model.PackageSoftware
|
||||
};
|
||||
}
|
||||
public void Update(PackageBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PackageName = model.PackageName;
|
||||
Price = model.Price;
|
||||
PackageSoftware = model.PackageSoftware;
|
||||
}
|
||||
public PackageViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PackageName = PackageName,
|
||||
Price = Price,
|
||||
PackageSoftware = PackageSoftware
|
||||
};
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
|
||||
namespace AbstractSoftwareInstallationListImplement.Models
|
||||
{
|
||||
public class Software : ISoftwareModel
|
||||
{
|
||||
public string SoftwareName { get; private set; } = String.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
public static Software? Create(SoftwareBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Software()
|
||||
{
|
||||
Id = model.Id,
|
||||
SoftwareName = model.SoftwareName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public void Update(SoftwareBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SoftwareName = model.SoftwareName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public SoftwareViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SoftwareName = SoftwareName,
|
||||
Cost = Cost
|
||||
};
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationView", "SoftwareInstallation\SoftwareInstallationView.csproj", "{18A0C203-2758-444C-AF35-2635F88FDB35}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationDataModels", "AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj", "{A883A624-D446-4834-9C5F-6364F0E66314}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationContracts", "AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj", "{4DA94347-C949-462B-B361-18D297C65CC2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationBusinessLogic", "AbstractSoftwareInstallationBusinessLogic\AbstractSoftwareInstallationBusinessLogic.csproj", "{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationListImplement", "AbstractSoftwareInstallationListImplement\AbstractSoftwareInstallationListImplement.csproj", "{31AD2872-9651-476A-9868-C4404FEEB0E4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationFileImplement", "AbstractSoftwareInstallationFileImplement\AbstractSoftwareInstallationFileImplement.csproj", "{BEE13C3F-1BB8-46B4-BC87-CFC367E52A77}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationDatabaseImplement", "AbstractSoftwareInstallationDatabaseImplement\AbstractSoftwareInstallationDatabaseImplement.csproj", "{7631EF04-BAD9-44D7-80C5-6017EDEA7E14}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{18A0C203-2758-444C-AF35-2635F88FDB35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{18A0C203-2758-444C-AF35-2635F88FDB35}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{18A0C203-2758-444C-AF35-2635F88FDB35}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{18A0C203-2758-444C-AF35-2635F88FDB35}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A883A624-D446-4834-9C5F-6364F0E66314}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A883A624-D446-4834-9C5F-6364F0E66314}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A883A624-D446-4834-9C5F-6364F0E66314}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A883A624-D446-4834-9C5F-6364F0E66314}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4DA94347-C949-462B-B361-18D297C65CC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4DA94347-C949-462B-B361-18D297C65CC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4DA94347-C949-462B-B361-18D297C65CC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4DA94347-C949-462B-B361-18D297C65CC2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BEE13C3F-1BB8-46B4-BC87-CFC367E52A77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BEE13C3F-1BB8-46B4-BC87-CFC367E52A77}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BEE13C3F-1BB8-46B4-BC87-CFC367E52A77}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BEE13C3F-1BB8-46B4-BC87-CFC367E52A77}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7631EF04-BAD9-44D7-80C5-6017EDEA7E14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7631EF04-BAD9-44D7-80C5-6017EDEA7E14}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7631EF04-BAD9-44D7-80C5-6017EDEA7E14}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7631EF04-BAD9-44D7-80C5-6017EDEA7E14}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {65E51AEC-89CD-4164-8821-934839107D27}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,145 +0,0 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer Softwares = 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 && (Softwares != null))
|
||||
{
|
||||
Softwares.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 InitializeSoftware()
|
||||
{
|
||||
this.comboBoxPackage = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
||||
this.labelPackage = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelSum = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comboBoxPackage
|
||||
//
|
||||
this.comboBoxPackage.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.comboBoxPackage.FormattingEnabled = true;
|
||||
this.comboBoxPackage.Location = new System.Drawing.Point(110, 24);
|
||||
this.comboBoxPackage.Name = "comboBoxPackage";
|
||||
this.comboBoxPackage.Size = new System.Drawing.Size(310, 23);
|
||||
this.comboBoxPackage.TabIndex = 0;
|
||||
this.comboBoxPackage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged);
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(110, 62);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(310, 23);
|
||||
this.textBoxCount.TabIndex = 1;
|
||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
this.textBoxSum.Location = new System.Drawing.Point(110, 101);
|
||||
this.textBoxSum.Name = "textBoxSum";
|
||||
this.textBoxSum.Size = new System.Drawing.Size(310, 23);
|
||||
this.textBoxSum.TabIndex = 2;
|
||||
//
|
||||
// labelPackage
|
||||
//
|
||||
this.labelPackage.AutoSize = true;
|
||||
this.labelPackage.Location = new System.Drawing.Point(29, 27);
|
||||
this.labelPackage.Name = "labelPackage";
|
||||
this.labelPackage.Size = new System.Drawing.Size(42, 15);
|
||||
this.labelPackage.TabIndex = 3;
|
||||
this.labelPackage.Text = "Пакет:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(29, 65);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||
this.labelCount.TabIndex = 4;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// labelSum
|
||||
//
|
||||
this.labelSum.AutoSize = true;
|
||||
this.labelSum.Location = new System.Drawing.Point(29, 104);
|
||||
this.labelSum.Name = "labelSum";
|
||||
this.labelSum.Size = new System.Drawing.Size(48, 15);
|
||||
this.labelSum.TabIndex = 5;
|
||||
this.labelSum.Text = "Сумма:";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(247, 132);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(345, 132);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отменить";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(450, 167);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.labelSum);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelPackage);
|
||||
this.Controls.Add(this.textBoxSum);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxPackage);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Заказ";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxPackage;
|
||||
private TextBox textBoxCount;
|
||||
private TextBox textBoxSum;
|
||||
private Label labelPackage;
|
||||
private Label labelCount;
|
||||
private Label labelSum;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPackageLogic _logicP;
|
||||
private readonly IOrderLogic _logicO;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPackageLogic logicP, IOrderLogic logicO)
|
||||
{
|
||||
InitializeSoftware();
|
||||
_logger = logger;
|
||||
_logicP = logicP;
|
||||
_logicO = logicO;
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка пакетов для заказа");
|
||||
try
|
||||
{
|
||||
var list = _logicP.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxPackage.DisplayMember = "PackageName";
|
||||
comboBoxPackage.ValueMember = "Id";
|
||||
comboBoxPackage.DataSource = list;
|
||||
comboBoxPackage.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки пакетов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxPackage.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxPackage.SelectedValue);
|
||||
var product = _logicP.ReadElement(new PackageSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
private void ComboBoxProduct_SelectedIndexChanged(object sender,
|
||||
EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxPackage.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
PackageId = Convert.ToInt32(comboBoxPackage.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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,174 +0,0 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer Softwares = 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 && (Softwares != null))
|
||||
{
|
||||
Softwares.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 InitializeSoftware()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.guideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.packageToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.storageToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(1, 31);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(602, 230);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(628, 31);
|
||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
this.buttonCreateOrder.Size = new System.Drawing.Size(153, 23);
|
||||
this.buttonCreateOrder.TabIndex = 2;
|
||||
this.buttonCreateOrder.Text = "Создать заказ";
|
||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(628, 75);
|
||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(153, 23);
|
||||
this.buttonTakeOrderInWork.TabIndex = 3;
|
||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click);
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(628, 123);
|
||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
||||
this.buttonOrderReady.Size = new System.Drawing.Size(153, 23);
|
||||
this.buttonOrderReady.TabIndex = 4;
|
||||
this.buttonOrderReady.Text = "Заказ готов";
|
||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click);
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(628, 171);
|
||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(153, 23);
|
||||
this.buttonIssuedOrder.TabIndex = 5;
|
||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click);
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(628, 219);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(153, 23);
|
||||
this.buttonRef.TabIndex = 6;
|
||||
this.buttonRef.Text = "Обновить список";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.guideToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(803, 24);
|
||||
this.menuStrip1.TabIndex = 1;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// guideToolStripMenuItem
|
||||
//
|
||||
this.guideToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.packageToolStripMenuItem2,
|
||||
this.storageToolStripMenuItem3});
|
||||
this.guideToolStripMenuItem.Name = "guideToolStripMenuItem";
|
||||
this.guideToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.guideToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// packageToolStripMenuItem2
|
||||
//
|
||||
this.packageToolStripMenuItem2.Name = "packageToolStripMenuItem2";
|
||||
this.packageToolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
|
||||
this.packageToolStripMenuItem2.Text = "Пакеты";
|
||||
this.packageToolStripMenuItem2.Click += new System.EventHandler(this.packageToolStripMenuItem_Click);
|
||||
//
|
||||
// storageToolStripMenuItem3
|
||||
//
|
||||
this.storageToolStripMenuItem3.Name = "storageToolStripMenuItem3";
|
||||
this.storageToolStripMenuItem3.Size = new System.Drawing.Size(180, 22);
|
||||
this.storageToolStripMenuItem3.Text = "ПО";
|
||||
this.storageToolStripMenuItem3.Click += new System.EventHandler(this.softwareToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(803, 263);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonIssuedOrder);
|
||||
this.Controls.Add(this.buttonOrderReady);
|
||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
||||
this.Controls.Add(this.buttonCreateOrder);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Магазин программного обеспечения";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateOrder;
|
||||
private Button buttonTakeOrderInWork;
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRef;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem guideToolStripMenuItem;
|
||||
private ToolStripMenuItem packageToolStripMenuItem2;
|
||||
private ToolStripMenuItem storageToolStripMenuItem3;
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallation;
|
||||
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 SoftwareInstallationView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||
{
|
||||
InitializeSoftware();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["PackageId"].Visible = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void buttonOrderReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{ Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new
|
||||
OrderBindingModel
|
||||
{ Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void softwareToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSoftwares));
|
||||
if (service is FormSoftwares form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void packageToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPackages));
|
||||
if (service is FormPackages form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void buttonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<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>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,225 +0,0 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormPackage
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer Softwares = 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 && (Softwares != null))
|
||||
{
|
||||
Softwares.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 InitializeSoftware()
|
||||
{
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnSoftware = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.groupBoxSoftware = new System.Windows.Forms.GroupBox();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonEdit = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.labelPrice = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.groupBoxSoftware.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(131, 12);
|
||||
this.textBoxName.Name = "textBox1";
|
||||
this.textBoxName.Size = new System.Drawing.Size(343, 23);
|
||||
this.textBoxName.TabIndex = 0;
|
||||
//
|
||||
// textBox2
|
||||
//
|
||||
this.textBoxPrice.Location = new System.Drawing.Point(131, 57);
|
||||
this.textBoxPrice.Name = "textBox2";
|
||||
this.textBoxPrice.Size = new System.Drawing.Size(174, 23);
|
||||
this.textBoxPrice.TabIndex = 1;
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnId,
|
||||
this.ColumnSoftware,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Location = new System.Drawing.Point(6, 22);
|
||||
this.dataGridView.Name = "dataGridView1";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(444, 299);
|
||||
this.dataGridView.TabIndex = 2;
|
||||
//
|
||||
// ColumnId
|
||||
//
|
||||
this.ColumnId.HeaderText = "Id";
|
||||
this.ColumnId.Name = "ColumnId";
|
||||
this.ColumnId.Visible = false;
|
||||
//
|
||||
// ColumnSoftware
|
||||
//
|
||||
this.ColumnSoftware.HeaderText = "ПО";
|
||||
this.ColumnSoftware.Name = "ColumnSoftware";
|
||||
this.ColumnSoftware.Width = 300;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
this.ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// groupBoxSoftware
|
||||
//
|
||||
this.groupBoxSoftware.Controls.Add(this.buttonUpdate);
|
||||
this.groupBoxSoftware.Controls.Add(this.buttonDelete);
|
||||
this.groupBoxSoftware.Controls.Add(this.dataGridView);
|
||||
this.groupBoxSoftware.Controls.Add(this.buttonEdit);
|
||||
this.groupBoxSoftware.Controls.Add(this.buttonAdd);
|
||||
this.groupBoxSoftware.Location = new System.Drawing.Point(21, 105);
|
||||
this.groupBoxSoftware.Name = "groupBoxSoftware";
|
||||
this.groupBoxSoftware.Size = new System.Drawing.Size(586, 327);
|
||||
this.groupBoxSoftware.TabIndex = 3;
|
||||
this.groupBoxSoftware.TabStop = false;
|
||||
this.groupBoxSoftware.Text = "ПО";
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(473, 22);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(98, 29);
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
this.buttonEdit.Location = new System.Drawing.Point(473, 75);
|
||||
this.buttonEdit.Name = "buttonEdit";
|
||||
this.buttonEdit.Size = new System.Drawing.Size(98, 31);
|
||||
this.buttonEdit.TabIndex = 1;
|
||||
this.buttonEdit.Text = "Изменить";
|
||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||
this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(473, 135);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(98, 31);
|
||||
this.buttonDelete.TabIndex = 3;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(473, 194);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(98, 29);
|
||||
this.buttonUpdate.TabIndex = 4;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(376, 438);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(98, 23);
|
||||
this.buttonSave.TabIndex = 5;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(494, 438);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(98, 23);
|
||||
this.buttonCancel.TabIndex = 6;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(55, 15);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelName.TabIndex = 7;
|
||||
this.labelName.Text = "Название:";
|
||||
//
|
||||
// labelPrice
|
||||
//
|
||||
this.labelPrice.AutoSize = true;
|
||||
this.labelPrice.Location = new System.Drawing.Point(55, 60);
|
||||
this.labelPrice.Name = "labelPrice";
|
||||
this.labelPrice.Size = new System.Drawing.Size(70, 15);
|
||||
this.labelPrice.TabIndex = 8;
|
||||
this.labelPrice.Text = "Стоимость:";
|
||||
//
|
||||
// FormPackage
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(633, 472);
|
||||
this.Controls.Add(this.labelPrice);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.textBoxPrice);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.groupBoxSoftware);
|
||||
this.Name = "FormPackage";
|
||||
this.Text = "Пакет";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.groupBoxSoftware.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxPrice;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnId;
|
||||
private DataGridViewTextBoxColumn ColumnSoftware;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private GroupBox groupBoxSoftware;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonEdit;
|
||||
private Button buttonAdd;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelName;
|
||||
private Label labelPrice;
|
||||
}
|
||||
}
|
@ -1,228 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallation;
|
||||
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
public partial class FormPackage : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPackageLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (ISoftwareModel, int)> _packageSoftwares;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormPackage(ILogger<FormPackage> logger, IPackageLogic logic)
|
||||
{
|
||||
InitializeSoftware();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_packageSoftwares = new Dictionary<int, (ISoftwareModel, int)>();
|
||||
}
|
||||
private void FormPackage_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка ПО");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new PackageSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.PackageName;
|
||||
textBoxPrice.Text = view.Price.ToString();
|
||||
_packageSoftwares = view.PackageSoftware ?? new Dictionary<int, (ISoftwareModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки ПО");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка ПО пакета");
|
||||
|
||||
try
|
||||
{
|
||||
if (_packageSoftwares != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var pc in _packageSoftwares)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[]
|
||||
{
|
||||
pc.Key,
|
||||
pc.Value.Item1.
|
||||
SoftwareName,
|
||||
pc.Value.Item2 });
|
||||
}
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки ПО пакета");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPackageSoftware));
|
||||
|
||||
if (service is FormPackageSoftware form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.SoftwareModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление нового ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
|
||||
|
||||
if (_packageSoftwares.ContainsKey(form.Id))
|
||||
{
|
||||
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_packageSoftwares.Add(form.Id, (form.SoftwareModel, form.Count));
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPackageSoftware));
|
||||
|
||||
if (service is FormPackageSoftware form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _packageSoftwares[id].Item2;
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.SoftwareModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Изменение ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
|
||||
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Удаление ПО: { SoftwareName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
||||
_packageSoftwares?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_packageSoftwares == null || _packageSoftwares.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните ПО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение пакета");
|
||||
|
||||
try
|
||||
{
|
||||
var model = new PackageBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
PackageName = textBoxName.Text,
|
||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения пакета");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
private double CalcPrice()
|
||||
{
|
||||
double price = 0;
|
||||
|
||||
foreach (var elem in _packageSoftwares)
|
||||
{
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
|
||||
return Math.Round(price * 1.1, 2);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
<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>
|
||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnSoftware.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnSoftware.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,119 +0,0 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormPackageSoftware
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer Softwares = 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 && (Softwares != null))
|
||||
{
|
||||
Softwares.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 InitializeSoftware()
|
||||
{
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxSoftware = new System.Windows.Forms.ComboBox();
|
||||
this.labelSoftware = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(101, 65);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(273, 23);
|
||||
this.textBox1.TabIndex = 0;
|
||||
//
|
||||
// comboBoxSoftware
|
||||
//
|
||||
this.comboBoxSoftware.FormattingEnabled = true;
|
||||
this.comboBoxSoftware.Location = new System.Drawing.Point(101, 24);
|
||||
this.comboBoxSoftware.Name = "comboBoxSoftware";
|
||||
this.comboBoxSoftware.Size = new System.Drawing.Size(273, 23);
|
||||
this.comboBoxSoftware.TabIndex = 1;
|
||||
//
|
||||
// labelSoftware
|
||||
//
|
||||
this.labelSoftware.AutoSize = true;
|
||||
this.labelSoftware.Location = new System.Drawing.Point(20, 27);
|
||||
this.labelSoftware.Name = "labelSoftware";
|
||||
this.labelSoftware.Size = new System.Drawing.Size(28, 15);
|
||||
this.labelSoftware.TabIndex = 2;
|
||||
this.labelSoftware.Text = "ПО:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(20, 68);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||
this.labelCount.TabIndex = 3;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(195, 103);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 27);
|
||||
this.buttonSave.TabIndex = 4;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(299, 103);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 27);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormPackageSoftware
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(403, 142);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelSoftware);
|
||||
this.Controls.Add(this.comboBoxSoftware);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.Name = "FormPackageSoftware";
|
||||
this.Text = "ПО пакета";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBox1;
|
||||
private ComboBox comboBoxSoftware;
|
||||
private Label labelSoftware;
|
||||
private Label labelCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.ViewModels;
|
||||
using AbstractSoftwareInstallationDataModels.Models;
|
||||
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
public partial class FormPackageSoftware : Form
|
||||
{
|
||||
private readonly List<SoftwareViewModel>? _list;
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxSoftware.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxSoftware.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
public ISoftwareModel? SoftwareModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _list)
|
||||
{
|
||||
if (elem.Id == Id)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(textBox1.Text); }
|
||||
set
|
||||
{ textBox1.Text = value.ToString(); }
|
||||
}
|
||||
|
||||
public FormPackageSoftware(ISoftwareLogic logic)
|
||||
{
|
||||
InitializeSoftware();
|
||||
_list = logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxSoftware.DisplayMember = "SoftwareName";
|
||||
comboBoxSoftware.ValueMember = "Id";
|
||||
comboBoxSoftware.DataSource = _list;
|
||||
comboBoxSoftware.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBox1.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxSoftware.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите компонент", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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,126 +0,0 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormPackages
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer Softwares = 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 && (Softwares != null))
|
||||
{
|
||||
Softwares.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 InitializeSoftware()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonEdit = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnId});
|
||||
this.dataGridView.Location = new System.Drawing.Point(1, 1);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(445, 373);
|
||||
this.dataGridView.TabIndex = 10;
|
||||
//
|
||||
// ColumnId
|
||||
//
|
||||
this.ColumnId.FillWeight = 200F;
|
||||
this.ColumnId.HeaderText = "Id";
|
||||
this.ColumnId.Name = "ColumnId";
|
||||
this.ColumnId.Visible = false;
|
||||
this.ColumnId.Width = 200;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(461, 193);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonUpdate.TabIndex = 9;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(461, 135);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonDelete.TabIndex = 8;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
this.buttonEdit.Location = new System.Drawing.Point(461, 79);
|
||||
this.buttonEdit.Name = "buttonEdit";
|
||||
this.buttonEdit.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonEdit.TabIndex = 7;
|
||||
this.buttonEdit.Text = "Изменить";
|
||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||
this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(461, 22);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonAdd.TabIndex = 6;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// FormPackages
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(565, 374);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonDelete);
|
||||
this.Controls.Add(this.buttonEdit);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Name = "FormPackages";
|
||||
this.Text = "Пакеты";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonEdit;
|
||||
private Button buttonAdd;
|
||||
private DataGridViewTextBoxColumn ColumnId;
|
||||
}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallation;
|
||||
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
public partial class FormPackages : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPackageLogic _logic;
|
||||
public FormPackages(ILogger<FormPackages> logger, IPackageLogic logic)
|
||||
{
|
||||
InitializeSoftware();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
LoadData();
|
||||
}
|
||||
private void FormPackages_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["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["PackageSoftware"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка пакетов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки пакетов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
|
||||
|
||||
if (service is FormPackage form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление изделия");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new PackageBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
|
||||
|
||||
if (service is FormPackage form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<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>
|
||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,118 +0,0 @@
|
||||
namespace SoftwareInstallation
|
||||
{
|
||||
partial class FormSoftware
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer Softwares = 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 && (Softwares != null))
|
||||
{
|
||||
Softwares.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 InitializeSoftware()
|
||||
{
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.labelCost = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(94, 28);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(316, 23);
|
||||
this.textBoxName.TabIndex = 0;
|
||||
//
|
||||
// textBoxCost
|
||||
//
|
||||
this.textBoxCost.Location = new System.Drawing.Point(94, 76);
|
||||
this.textBoxCost.Name = "textBoxCost";
|
||||
this.textBoxCost.Size = new System.Drawing.Size(156, 23);
|
||||
this.textBoxCost.TabIndex = 1;
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(29, 28);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelName.TabIndex = 2;
|
||||
this.labelName.Text = "Название:";
|
||||
//
|
||||
// labelCost
|
||||
//
|
||||
this.labelCost.AutoSize = true;
|
||||
this.labelCost.Location = new System.Drawing.Point(29, 76);
|
||||
this.labelCost.Name = "labelCost";
|
||||
this.labelCost.Size = new System.Drawing.Size(38, 15);
|
||||
this.labelCost.TabIndex = 3;
|
||||
this.labelCost.Text = "Цена:";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(195, 115);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(103, 26);
|
||||
this.buttonSave.TabIndex = 4;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(307, 115);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(103, 26);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отменить";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// FormSoftware
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(441, 153);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.labelCost);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Controls.Add(this.textBoxCost);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Name = "FormSoftware";
|
||||
this.Text = "Программное обеспечение";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxCost;
|
||||
private Label labelName;
|
||||
private Label labelCost;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SoftwareInstallation
|
||||
{
|
||||
public partial class FormSoftware : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISoftwareLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormSoftware(ILogger<FormSoftware> logger, ISoftwareLogic logic)
|
||||
{
|
||||
InitializeSoftware();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormSoftware_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Ïîëó÷åíèå êîìïîíåíòà");
|
||||
var view = _logic.ReadElement(new SoftwareSearchModel
|
||||
{
|
||||
Id =
|
||||
_id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.SoftwareName;
|
||||
textBoxCost.Text = view.Cost.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Îøèáêà ïîëó÷åíèÿ êîìïîíåíòà");
|
||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Çàïîëíèòå íàçâàíèå", "Îøèáêà",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Ñîõðàíåíèå êîìïîíåíòà");
|
||||
try
|
||||
{
|
||||
var model = new SoftwareBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
SoftwareName = textBoxName.Text,
|
||||
Cost = Convert.ToDouble(textBoxCost.Text)
|
||||
};
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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,125 +0,0 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormSoftwares
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer Softwares = 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 && (Softwares != null))
|
||||
{
|
||||
Softwares.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 InitializeSoftware()
|
||||
{
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonEdit = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(461, 23);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonAdd.TabIndex = 1;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
this.buttonEdit.Location = new System.Drawing.Point(461, 80);
|
||||
this.buttonEdit.Name = "buttonEdit";
|
||||
this.buttonEdit.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonEdit.TabIndex = 2;
|
||||
this.buttonEdit.Text = "Изменить";
|
||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(461, 136);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonDelete.TabIndex = 3;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(461, 194);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(97, 30);
|
||||
this.buttonUpdate.TabIndex = 4;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnId});
|
||||
this.dataGridView.Location = new System.Drawing.Point(1, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(445, 410);
|
||||
this.dataGridView.TabIndex = 5;
|
||||
//
|
||||
// ColumnId
|
||||
//
|
||||
this.ColumnId.FillWeight = 200F;
|
||||
this.ColumnId.HeaderText = "Id";
|
||||
this.ColumnId.Name = "ColumnId";
|
||||
this.ColumnId.Visible = false;
|
||||
this.ColumnId.Width = 200;
|
||||
//
|
||||
// FormSoftwares
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(581, 413);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonDelete);
|
||||
this.Controls.Add(this.buttonEdit);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Name = "FormSoftwares";
|
||||
this.Text = "Программные обеспечения";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Button buttonAdd;
|
||||
private Button buttonEdit;
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnId;
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
using AbstractSoftwareInstallationContracts.BindingModels;
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallation;
|
||||
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
public partial class FormSoftwares : Form
|
||||
{
|
||||
public FormSoftwares(ILogger<FormSoftwares> logger, ISoftwareLogic logic)
|
||||
{
|
||||
InitializeSoftware();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
LoadData();
|
||||
}
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISoftwareLogic _logic;
|
||||
|
||||
private void FormSoftwares_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["SoftwareName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSoftware));
|
||||
if (service is FormSoftware form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление ПО");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new SoftwareBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении.Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления ПО");
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSoftware));
|
||||
|
||||
if (service is FormSoftware form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<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>
|
||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,52 +0,0 @@
|
||||
using AbstractSoftwareInstallationDatabaseImplement.Implements;
|
||||
using AbstractSoftwareInstallationBusinessLogic;
|
||||
using AbstractSoftwareInstallationBusinessLogic.BusinessLogic;
|
||||
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using AbstractSoftwareInstallationContracts.StoragesContracts;
|
||||
using SoftwareInstallationView;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
|
||||
namespace SoftwareInstallation
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<ISoftwareStorage, SoftwareStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IPackageStorage, PackageStorage>();
|
||||
services.AddTransient<ISoftwareLogic, SoftwareLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IPackageLogic, PackageLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormSoftware>();
|
||||
services.AddTransient<FormSoftwares>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormPackage>();
|
||||
services.AddTransient<FormPackageSoftware>();
|
||||
services.AddTransient<FormPackages>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,29 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationBusinessLogic\AbstractSoftwareInstallationBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj" />
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationDatabaseImplement\AbstractSoftwareInstallationDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationFileImplement\AbstractSoftwareInstallationFileImplement.csproj" />
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationListImplement\AbstractSoftwareInstallationListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user