круд получения

This commit is contained in:
devil_1nc 2023-12-01 19:59:06 +04:00
parent 86cc47df10
commit 17c52d0eba
34 changed files with 1042 additions and 199 deletions

View File

@ -108,10 +108,10 @@ namespace ComputerShopBusinessLogic.BusinessLogics
{
throw new Exception($"В качестве логина должна быть указана почта");
}
if (!Regex.IsMatch(model.Password, @"^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$"))
{
throw new Exception($"Пароль должен состоять из цифр, букв и небуквенных символов");
}
//if (!Regex.IsMatch(model.Password, @"^[\w\.]{1,30}@{1}[^\d\W]+\.{1}[^\d\W]{2,4}$"))
//{
// throw new Exception($"Пароль должен состоять из цифр, букв и небуквенных символов");
//}
_logger.LogInformation("Client. Id: {Id}, FIO: {fio}, email: {email}", model.Id, model.ClientFIO, model.Email);
var element = _clientStorage.GetElement(new ClientSearchModel
{

View File

@ -52,12 +52,19 @@ namespace ComputerShopBusinessLogic.BusinessLogics
return true;
}
public bool TakeInWork(EquipmentReceivingBindingModel model)
{
return StatusUpdate(model, EquipmentReceivingStatus.Ожидается);
}
public bool Delete(EquipmentReceivingBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_receivingStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Finish(EquipmentReceivingBindingModel model)
public bool Finish(EquipmentReceivingBindingModel model)
{
return StatusUpdate(model, EquipmentReceivingStatus.Получено);
}

View File

@ -141,25 +141,25 @@ namespace ComputerShopBusinessLogic.BusinessLogics
}
_logger.LogInformation("AddAssemblyToOrder. AssemblyName:{AssemblyName}.Id:{ Id}", assemblymodel.AssemblyName, model.Id);
var element = _orderStorage.GetElement(model);
var order = _orderStorage.GetElement(model);
var assembly = _assemblyStorage.GetElement(assemblymodel);
if (element == null || assembly == null)
if (order == null || assembly == null)
{
return false;
}
_logger.LogInformation("AddAssemblyToOrder find. Id:{Id}", element.Id);
_logger.LogInformation("AddAssemblyToOrder find. Id:{Id}", order.Id);
element.AssemblyOrders[assembly.Id] = (assembly, amount);
order.OrderAssemblies[assembly.Id] = (assembly, amount);
_orderStorage.Update(new()
{
Id = element.Id,
Status = element.Status,
Sum = element.Sum + assembly.Price * amount,
ClientId = element.ClientId,
AssemblyOrders = element.AssemblyOrders
Id = order.Id,
Status = order.Status,
Sum = order.Sum + assembly.Price * amount,
ClientId = order.ClientId,
AssemblyOrders = order.OrderAssemblies
});
return true;

View File

@ -18,12 +18,14 @@ namespace ComputerShopBusinessLogic.BusinessLogics
private readonly ILogger _logger;
private readonly ISupplyStorage _supplyStorage;
private readonly IOrderStorage _orderStorage;
private readonly IComponentStorage _componentStorage;
public SupplyLogic(ILogger logger, ISupplyStorage supplyStorage, IOrderStorage orderStorage)
public SupplyLogic(ILogger logger, ISupplyStorage supplyStorage, IOrderStorage orderStorage, IComponentStorage componentStorage)
{
_logger = logger;
_supplyStorage = supplyStorage;
_orderStorage = orderStorage;
_componentStorage = componentStorage;
}
public bool Create(SupplyBindingModel model)
{
@ -71,7 +73,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics
}
public bool Finish(SupplyBindingModel model)
{
return StatusUpdate(model, SupplyStatus.Отправлено);
return StatusUpdate(model, SupplyStatus.Поставлено);
}
public bool Update(SupplyBindingModel model)
{
@ -101,7 +103,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics
return false;
}
model.Status = _newStatus;
if (model.Status == SupplyStatus.Отправлено) model.DateImplement = DateTime.Now;
if (model.Status == SupplyStatus.Поставлено) model.DateImplement = DateTime.Now;
else
{
model.DateImplement = viewModel.DateImplement;
@ -131,7 +133,32 @@ namespace ComputerShopBusinessLogic.BusinessLogics
return false;
}
order.SupplyOrders[order.Id] = order;
supply.SupplyOrders[supply.Id] = order;
_supplyStorage.Update(new()
{
Id = supply.Id,
SupplyOrders = supply.SupplyOrders,
});
return true;
}
public bool AddComponent(SupplySearchModel supplymodel, ComponentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var component = _componentStorage.GetElement(model);
var supply = _supplyStorage.GetElement(supplymodel);
if (component == null || supply == null)
{
return false;
}
supply.SupplyComponents[supply.Id] = component;
_supplyStorage.Update(new()
{

View File

@ -12,8 +12,8 @@ namespace ComputerShopContracts.BindingModels
{
public int Id { get; set; }
public int ClientId { get; set; }
public int? ReceivingId { get; set; }
public int? ComponentId { get; set; }
public SupplyStatus Status { get; set; } = SupplyStatus.Неизвестен;
public DateTime DateCreate { get; set; } = DateTime.Now;
@ -25,11 +25,5 @@ namespace ComputerShopContracts.BindingModels
get;
set;
} = new();
public Dictionary<int, IComponentModel> SupplyComponents
{
get;
set;
} = new();
}
}

View File

@ -12,8 +12,8 @@ namespace ComputerShopContracts.BusinessLogicContracts
public interface IEquipmentReceivingLogic
{
List<EquipmentReceivingViewModel>? ReadList(EquipmentReceivingSearchModel? model);
bool Create(EquipmentReceivingBindingModel model);
bool TakeInWork(EquipmentReceivingBindingModel model);
bool Delete(EquipmentReceivingBindingModel model);
bool Create(EquipmentReceivingBindingModel model);
bool Finish(EquipmentReceivingBindingModel model);
}
}

View File

@ -11,8 +11,7 @@ namespace ComputerShopContracts.SearchModels
{
public int? Id { get; set; }
public int? ClientId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public SupplySearchModel? Supply { get; set; }
public DateTime? DateImplement { get; set; }
public int? Status { get; set; }
}
}

View File

@ -21,11 +21,6 @@ namespace ComputerShopContracts.ViewModels
get;
set;
} = new();
public Dictionary<int, (IOrderModel, int)> AssemblyOrders
{
get;
set;
} = new();
public int ClientId { get; set; }
[DisplayName("ФИО клиента")]

View File

@ -19,17 +19,11 @@ namespace ComputerShopContracts.ViewModels
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now;
public Dictionary<int, (IAssemblyModel, int)> AssemblyOrders
public Dictionary<int, (IAssemblyModel, int)> OrderAssemblies
{
get;
set;
} = new();
public Dictionary<int, IOrderModel> SupplyOrders
{
get;
set;
} = new();
[DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; }

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace ComputerShopContracts.ViewModels
@ -27,16 +28,28 @@ namespace ComputerShopContracts.ViewModels
public int ClientId { get; set; }
[DisplayName("Номер получения")]
public int? ReceivingId { get; set; }
[DisplayName("Номер комплектующего")]
public int? ComponentId { get; set; }
public Dictionary<int, IOrderModel> SupplyOrders
{
get;
set;
} = new();
public Dictionary<int, IComponentModel> SupplyComponents
{
get;
set;
} = new();
[JsonConstructor]
public SupplyViewModel(Dictionary<int, IOrderModel> SupplyOrders)
{
this.SupplyOrders = SupplyOrders;
}
public SupplyViewModel()
{
}
}
}

View File

@ -4,6 +4,6 @@
{
Неизвестен = -1,
Отправляется = 0,
Отправлено = 1
Поставлено = 1
}
}

View File

@ -8,6 +8,7 @@ namespace ComputerShopDataModels.Models
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
int? ReceivingId { get; }
int? ComponentId { get; }
Dictionary<int, IOrderModel> SupplyOrders { get; }
}
}

View File

@ -15,7 +15,7 @@ namespace ComputerShopDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseCWW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-QA8P9OJ;Initial Catalog=ComputerShopDatabaseCWW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
@ -28,7 +28,7 @@ namespace ComputerShopDatabaseImplement
public virtual DbSet<SupplyOrder> SupplyOrders { set; get; }
public virtual DbSet<EquipmentReceiving> EquipmentReceivings { set; get; }
public virtual DbSet<ComponentSupply> ComponentSupplies { set; get; }
public virtual DbSet<AssemblyOrder> AssemblyOrders { set; get; }
public virtual DbSet<OrderAssembly> AssemblyOrders { set; get; }
public virtual DbSet<Client> Clients { set; get; }
}
}

View File

@ -35,21 +35,35 @@ namespace ComputerShopDatabaseImplement.Implements
}
using var context = new ComputerShopDatabase();
return context.EquipmentReceivings
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
.GetViewModel;
}
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<EquipmentReceivingViewModel> GetFilteredList(EquipmentReceivingSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && !model.ClientId.HasValue && !model.DateImplement.HasValue && !model.Status.HasValue)
{
return new();
}
using var context = new ComputerShopDatabase();
if (model.DateImplement.HasValue)
return context.EquipmentReceivings
.Where(x => x.DateImplement == model.DateImplement)
.Select(x => x.GetViewModel)
.ToList();
if (model.ClientId.HasValue)
{
return context.EquipmentReceivings
.Include(x => x.Client)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
return context.EquipmentReceivings
.Where(x => x.Id == model.Supply.Component.Id)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public List<EquipmentReceivingViewModel> GetFullList()

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace ComputerShopDatabaseImplement.Implements
{
internal class OrderStorage : IOrderStorage
public class OrderStorage : IOrderStorage
{
public OrderViewModel? Delete(OrderBindingModel model)
{

View File

@ -0,0 +1,546 @@
// <auto-generated />
using System;
using ComputerShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
[DbContext(typeof(ComputerShopDatabase))]
[Migration("20231007140302_fix2")]
partial class fix2
{
/// <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("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AssemblyName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Assemblies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("ComponentId");
b.ToTable("AssemblyComponents");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Components");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SupplyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("SupplyId");
b.ToTable("ComponentSupplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("EquipmentReceivings");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.ToTable("Purchases");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int?>("ComponentId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ReceivingId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.HasIndex("ReceivingId");
b.ToTable("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("SupplyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("SupplyId");
b.ToTable("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Assemblies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Components")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("AssemblyComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Components")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Supplies")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("Components")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Orders")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Assemblies")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Purchases")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Purchases")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
b.Navigation("Component");
b.Navigation("Receiving");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("SupplyOrders")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("Orders")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Navigation("Assemblies");
b.Navigation("Components");
b.Navigation("EquipmentReceivings");
b.Navigation("Orders");
b.Navigation("Purchases");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Navigation("AssemblyComponents");
b.Navigation("Purchases");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.Navigation("Assemblies");
b.Navigation("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,89 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class fix2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Supplies_EquipmentReceivings_ReceivingId",
table: "Supplies");
migrationBuilder.AlterColumn<int>(
name: "ReceivingId",
table: "Supplies",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddColumn<int>(
name: "ComponentId",
table: "Supplies",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Supplies_ComponentId",
table: "Supplies",
column: "ComponentId");
migrationBuilder.AddForeignKey(
name: "FK_Supplies_Components_ComponentId",
table: "Supplies",
column: "ComponentId",
principalTable: "Components",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Supplies_EquipmentReceivings_ReceivingId",
table: "Supplies",
column: "ReceivingId",
principalTable: "EquipmentReceivings",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Supplies_Components_ComponentId",
table: "Supplies");
migrationBuilder.DropForeignKey(
name: "FK_Supplies_EquipmentReceivings_ReceivingId",
table: "Supplies");
migrationBuilder.DropIndex(
name: "IX_Supplies_ComponentId",
table: "Supplies");
migrationBuilder.DropColumn(
name: "ComponentId",
table: "Supplies");
migrationBuilder.AlterColumn<int>(
name: "ReceivingId",
table: "Supplies",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Supplies_EquipmentReceivings_ReceivingId",
table: "Supplies",
column: "ReceivingId",
principalTable: "EquipmentReceivings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -73,32 +73,6 @@ namespace ComputerShopDatabaseImplement.Migrations
b.ToTable("AssemblyComponents");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
@ -229,6 +203,32 @@ namespace ComputerShopDatabaseImplement.Migrations
b.ToTable("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.Property<int>("Id")
@ -282,6 +282,9 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int?>("ComponentId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
@ -289,7 +292,6 @@ namespace ComputerShopDatabaseImplement.Migrations
.HasColumnType("datetime2");
b.Property<int?>("ReceivingId")
.IsRequired()
.HasColumnType("int");
b.Property<int>("Status")
@ -299,6 +301,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.HasIndex("ReceivingId");
b.ToTable("Supplies");
@ -360,25 +364,6 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Orders")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Assemblies")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
@ -397,7 +382,7 @@ namespace ComputerShopDatabaseImplement.Migrations
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("ComponentSupplies")
.WithMany("Components")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -425,6 +410,25 @@ namespace ComputerShopDatabaseImplement.Migrations
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Orders")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Assemblies")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
@ -452,11 +456,15 @@ namespace ComputerShopDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("ReceivingId");
b.Navigation("Component");
b.Navigation("Receiving");
});
@ -525,7 +533,7 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("ComponentSupplies");
b.Navigation("Components");
b.Navigation("Orders");
});

View File

@ -37,11 +37,9 @@ namespace ComputerShopDatabaseImplement.Models
}
}
private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null;
[ForeignKey("AssemblyId")]
public virtual List<AssemblyComponent> Components { get; set; } = new();
[ForeignKey("AssemblyId")]
public virtual List<AssemblyOrder> Orders { get; set; } = new();
public virtual List<OrderAssembly> Orders { get; set; } = new();
public virtual Client Client { get; set; }
public static Assembly Create(ComputerShopDatabase context, AssemblyBindingModel model)
{
@ -58,7 +56,7 @@ namespace ComputerShopDatabaseImplement.Models
Count = x.Value.Item2
}).ToList(),
Orders = model.AssemblyOrders.Select(x => new
AssemblyOrder
OrderAssembly
{
Order = context.Orders.First(y => y.Id == x.Key),
Count = x.Value.Item2

View File

@ -15,7 +15,7 @@ namespace ComputerShopDatabaseImplement.Models
internal class EquipmentReceiving : IEquipmentReceivingModel
{
public DateTime? DateImplement { get; private set; }
public DateTime? DateImplement { get; set; }
public int Id { get; set; }
public EquipmentReceivingStatus Status { get; private set; } = EquipmentReceivingStatus.Неизвестен;
@ -25,6 +25,7 @@ namespace ComputerShopDatabaseImplement.Models
[Required]
public int ClientId { get; set; }
public virtual Client Client { get; set; }
public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model)
{
if (model == null)
@ -52,10 +53,10 @@ namespace ComputerShopDatabaseImplement.Models
public EquipmentReceivingViewModel GetViewModel => new()
{
DateImplement = DateImplement,
Id = Id,
Status = Status,
ClientId = ClientId
Status = Status,
DateImplement = DateImplement,
ClientId = ClientId
};
}
}

View File

@ -27,7 +27,7 @@ namespace ComputerShopDatabaseImplement.Models
public virtual List<SupplyOrder> SupplyOrders { get; set; } = new();
[ForeignKey("OrderId")]
public virtual List<AssemblyOrder> Assemblies { get; set; } = new();
public virtual List<OrderAssembly> Assemblies { get; set; } = new();
private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null;
[NotMapped]

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace ComputerShopDatabaseImplement.Models
{
internal class AssemblyOrder
internal class OrderAssembly
{
public int Id { get; set; }
[Required]

View File

@ -25,11 +25,12 @@ namespace ComputerShopDatabaseImplement.Models
public int ClientId { get; set; }
public int? ReceivingId { get; set; }
public virtual EquipmentReceiving Receiving { get; set; }
public virtual EquipmentReceiving? Receiving { get; set; }
public int? ComponentId { get; set; }
public virtual Component? Component { get; set; }
private Dictionary<int, IOrderModel>? _supplyOrders =
null;
private Dictionary<int, IComponentModel>? _supplyComponents = null;
[NotMapped]
public Dictionary<int, IOrderModel> SupplyOrders
{
@ -43,19 +44,6 @@ namespace ComputerShopDatabaseImplement.Models
return _supplyOrders;
}
}
[NotMapped]
public Dictionary<int, IComponentModel> SupplyComponents
{
get
{
if (_supplyComponents == null)
{
_supplyComponents = Components
.ToDictionary(recPC => recPC.SupplyId, recPC => recPC.Component as IComponentModel);
}
return _supplyComponents;
}
}
[ForeignKey("SupplyId")]
public virtual List<SupplyOrder> Orders { get; set; } = new();
[ForeignKey("SupplyId")]
@ -71,16 +59,12 @@ namespace ComputerShopDatabaseImplement.Models
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
ReceivingId = model.ReceivingId,
ComponentId = model.ComponentId,
Orders = model.SupplyOrders.Select(x => new
SupplyOrder
{
Order = context.Orders.First(y => y.Id == x.Key),
}).ToList(),
Components = model.SupplyComponents.Select(x => new
ComponentSupply
{
Component = context.Components.First(y => y.Id == x.Key),
}).ToList()
};
}
public void Update(SupplyBindingModel model)
@ -99,9 +83,9 @@ namespace ComputerShopDatabaseImplement.Models
DateCreate = DateCreate,
DateImplement = DateImplement,
SupplyOrders = SupplyOrders,
SupplyComponents = SupplyComponents,
ReceivingId = ReceivingId,
ClientId = ClientId
ClientId = ClientId,
ComponentId = ComponentId,
};
public void UpdateOrders(ComputerShopDatabase context, SupplyBindingModel model)
{

View File

@ -13,8 +13,10 @@
<ItemGroup>
<ProjectReference Include="..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj" />
<ProjectReference Include="..\ComputerShopClientApp\ComputerShopClientApp.csproj" />
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
<ProjectReference Include="..\ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj" />
<ProjectReference Include="..\OrdererClientApp\OrdererClientApp.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,10 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.StorageContracts;
using ComputerShopContracts.ViewModels;
using ComputerShopDatabaseImplement.Implements;
using DocumentFormat.OpenXml.Office2010.Excel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -13,24 +16,14 @@ namespace ComputerShopRestApi.Controllers
{
private readonly ILogger _logger;
private readonly IEquipmentReceivingLogic _equipmentReceiving;
public EquipmentReceivingController(ILogger<MainController> logger, IEquipmentReceivingLogic equipmentReceiving)
private readonly IEquipmentReceivingStorage _equipmentReceivingStorage;
public EquipmentReceivingController(ILogger<MainController> logger, IEquipmentReceivingLogic equipmentReceiving, IEquipmentReceivingStorage equipmentReceivingStorage)
{
_logger = logger;
_equipmentReceiving = equipmentReceiving;
}
[HttpGet]
public List<EquipmentReceivingViewModel>? GetReceivingList()
{
try
{
return _equipmentReceiving.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка компонентов");
throw;
}
}
_equipmentReceivingStorage = equipmentReceivingStorage;
}
[HttpGet]
public List<EquipmentReceivingViewModel>? GetReceivings(int clientId)
@ -48,7 +41,30 @@ namespace ComputerShopRestApi.Controllers
throw;
}
}
[HttpPost]
[HttpPost]
public void SetFinish(int id)
{
try
{
var receiving = _equipmentReceivingStorage.GetElement(new() { Id = id });
EquipmentReceivingBindingModel model = new EquipmentReceivingBindingModel()
{
Id = id,
ClientId = receiving.ClientId,
DateImplement = receiving.DateImplement,
Status = receiving.Status
};
_equipmentReceiving.Finish(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
throw;
}
}
[HttpPost]
public void CreateReceiving(EquipmentReceivingBindingModel model)
{
try
@ -61,5 +77,26 @@ namespace ComputerShopRestApi.Controllers
throw;
}
}
}
[HttpPost]
public void DeleteReceiving(int id)
{
try
{
var receiving = _equipmentReceivingStorage.GetElement(new() { Id = id });
_equipmentReceiving.Delete(new()
{
Id = id,
ClientId = receiving.ClientId,
DateImplement = receiving.DateImplement,
Status = receiving.Status
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления");
throw;
}
}
}
}

View File

@ -14,30 +14,30 @@ namespace ComputerShopRestApi.Controllers
private readonly ILogger _logger;
private readonly ISupplyLogic _supply;
private readonly IOrderLogic _order;
private readonly IEquipmentReceivingLogic _equipmentReceiving;
private readonly IComponentLogic _component;
public SupplyController(ILogger<SupplyController> logger, ISupplyLogic supply, IOrderLogic order, IEquipmentReceivingLogic equipmentReceiving)
public SupplyController(ILogger<SupplyController> logger, ISupplyLogic supply, IOrderLogic order, IComponentLogic component)
{
_logger = logger;
_supply = supply;
_order = order;
_equipmentReceiving = equipmentReceiving;
_component = component;
}
[HttpGet]
public List<EquipmentReceivingViewModel>? GetReceivingList(int clientId)
public List<ComponentViewModel>? GetReceivingList(int clientId)
{
try
{
return _equipmentReceiving.ReadList(new EquipmentReceivingSearchModel
return _component.ReadList(new ComponentSearchModel
{
ClientId = clientId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка поставок клиента id ={ Id}", clientId);
_logger.LogError(ex, "Ошибка получения списка комплектующих клиента id ={ Id}", clientId);
throw;
}
}

View File

@ -21,6 +21,7 @@ builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
builder.Services.AddTransient<IAssemblyStorage, AssemblyStorage>();
builder.Services.AddTransient<IEquipmentReceivingStorage, EquipmentReceivingStorage>();
builder.Services.AddTransient<ISupplyStorage, SupplyStorage>();
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
@ -28,6 +29,8 @@ builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
builder.Services.AddTransient<IAssemblyLogic, AssemblyLogic>();
builder.Services.AddTransient<IEquipmentReceivingLogic, EquipmentReceivingLogic>();
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();

View File

@ -1,7 +1,9 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.ViewModels;
using DocumentFormat.OpenXml.Office2010.Excel;
using Microsoft.AspNetCore.Mvc;
using OrdererClientApp.Models;
using System.ComponentModel;
using System.Diagnostics;
namespace OrdererClientApp.Controllers
@ -21,16 +23,16 @@ namespace OrdererClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<PurchaseViewModel>>($"api/main/getreceivings?clientId={APIClient.Client.Id}"));
return View(APIClient.GetRequest<List<EquipmentReceivingViewModel>>($"api/equipmentreceiving/getreceivings?clientId={APIClient.Client.Id}"));
}
public IActionResult Order()
public IActionResult Order()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/component/getorderlist"));
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/component/order"));
}
public IActionResult Supply()
{
@ -38,7 +40,7 @@ namespace OrdererClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/getsupplylist"));
return View(APIClient.GetRequest<List<SupplyViewModel>>($"api/supply/getsupplylist"));
}
[HttpGet]
@ -127,29 +129,46 @@ namespace OrdererClientApp.Controllers
}
[HttpGet]
public IActionResult CreateEquipmentReceiving()
{
ViewBag.EquipmentReceivings = APIClient.GetRequest<List<EquipmentReceivingViewModel>>("api/main/getreceivingslist");
return View();
public IActionResult CreateReceiving()
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest("api/equipmentreceiving/createreceiving", new EquipmentReceivingBindingModel
{
ClientId = APIClient.Client.Id
});
Response.Redirect("Index");
return View();
}
[HttpPost]
public void CreateSupply(int receiving)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
[HttpPost]
public void SetFinish(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/equipmentreceiving/setfinish?id={id}", id);
Response.Redirect("Index");
}
APIClient.PostRequest("api/main/createreceiving", new SupplyBindingModel
{
ClientId = APIClient.Client.Id,
ReceivingId = receiving,
});
Response.Redirect("Index");
}
[HttpPost]
public void DeleteReceiving(int receiving)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/equipmentreceiving/deletereceiving?id={receiving}", receiving);
Response.Redirect("Index");
[HttpGet]
}
[HttpGet]
public IActionResult CreateOrder()
{
return View();
@ -182,7 +201,7 @@ namespace OrdererClientApp.Controllers
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest("api/component/deleteorder", new ComponentBindingModel
APIClient.PostRequest("api/order/deleteorder", new ComponentBindingModel
{
Id = order
});

View File

@ -11,7 +11,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj" />
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
<ProjectReference Include="..\ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj" />
<ProjectReference Include="..\ComputerShopDataModels\ComputerShopDataModels.csproj" />
</ItemGroup>

View File

@ -1,10 +1,32 @@
using ComputerShopBusinessLogic.BusinessLogics;
using ComputerShopBusinessLogic.OfficePackage;
using ComputerShopBusinessLogic.OfficePackage.Implements;
using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.StorageContracts;
using ComputerShopDatabaseImplement.Implements;
using OrdererClientApp;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
builder.Services.AddTransient<ISupplyStorage, SupplyStorage>();
builder.Services.AddTransient<IAssemblyStorage, AssemblyStorage>();
builder.Services.AddTransient<IEquipmentReceivingStorage, EquipmentReceivingStorage>();
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
builder.Services.AddTransient<ClientStorage, ClientStorage>();
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{

View File

@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

View File

@ -1,8 +1,74 @@
@{
ViewData["Title"] = "Home Page";
@using ComputerShopContracts.ViewModels
@model List<EquipmentReceivingViewModel>
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
<h1 class="display-4">Список получений техники</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateReceiving" class="btn btn-primary">Создать новое получение</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
ID клиента
</th>
<th>
Дата получения
</th>
<th>
Статус
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ClientId)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateImplement)
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
<form action="SetFinish" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-primary">Получено</button>
</form>
<td>
<form action="DeleteReceiving" method="post">
<input type="hidden" name="receiving" value="@item.Id" />
<button type="submit" class="btn btn-danger">Отменить</button>
</form>
<td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -12,7 +12,7 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">OrdererClientApp</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -20,11 +20,27 @@
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Получения компонентов</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Order">Заказы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Supply">Закупки</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-
area="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчёты</a>
</li>
</ul>
</div>
</div>

View File

@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"IPAddress": "http://localhost:5216/"
}