Reports init, changed 1 relation

This commit is contained in:
the 2023-05-18 22:18:40 +04:00
parent 49b8f15517
commit 2b48d804a5
17 changed files with 1044 additions and 57 deletions

View File

@ -1,6 +1,10 @@
using ComputerShopContracts.BindingModels; using ComputerShopBusinessLogic.OfficePackage;
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.BusinessLogicContracts; using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.StorageContracts;
using ComputerShopContracts.ViewModels; using ComputerShopContracts.ViewModels;
using ComputerShopContracts.SearchModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -9,37 +13,83 @@ using System.Threading.Tasks;
namespace ComputerShopBusinessLogic.BusinessLogics namespace ComputerShopBusinessLogic.BusinessLogics
{ {
//public class ReportLogic : IReportLogic public class ReportLogic : IReportLogic
//{ {
// private readonly IBlankStorage _blankStorage; private readonly IComponentStorage _componentStorage;
// private readonly IDocumentStorage _documentStorage; private readonly ISupplyStorage _supplyStorage;
// private readonly IOrderStorage _orderStorage; private readonly IAssemblyStorage _assemblyStorage;
// private readonly AbstractSaveToExcel _saveToExcel; private readonly IEquipmentReceivingStorage _receivingStorage;
// private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToExcel _saveToExcel;
// private readonly AbstractSaveToPdf _saveToPdf; private readonly AbstractSaveToWord _saveToWord;
// public List<ReportPurchaseReceivingViewModel> GetPurchaseReceiving() private readonly AbstractSaveToPdf _saveToPdf;
// {
// throw new NotImplementedException();
// }
// public List<ReportPurchaseSupplyViewModel> GetPurchaseSupply() public ReportLogic(IComponentStorage componentStorage, IAssemblyStorage assemblyStorage, IEquipmentReceivingStorage receivingStorage, ISupplyStorage supplyStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
// { {
// throw new NotImplementedException(); _componentStorage = componentStorage;
// } _assemblyStorage = assemblyStorage;
_receivingStorage = receivingStorage;
// public void SaveOrdersToPdfFile(ReportBindingModel model) _supplyStorage = supplyStorage;
// { _saveToExcel = saveToExcel;
// throw new NotImplementedException(); _saveToWord = saveToWord;
// } _saveToPdf = saveToPdf;
}
// public void SavePackagesToWordFile(ReportBindingModel model)
// { public List<ReportComponentReceivingViewModel> GetComponentReceivings(List<int> ids)
// throw new NotImplementedException(); {
// } var result = new List<ReportComponentReceivingViewModel>();
// public void SaveProductComponentToExcelFile(ReportBindingModel model) List<ComponentViewModel> components = new List<ComponentViewModel>();
// { foreach (int id in ids)
// throw new NotImplementedException(); {
// } var component = _componentStorage.GetElement(new ComponentSearchModel()
//} {
Id = id,
});
if (component != null) components.Add(component);
}
return result;
}
public void SaveReceivingComponentsToWordFile(ReportBindingModel model)
{
//_saveToWord.CreateDoc(new WordInfoProvider
//{
// FileName = model.FileName,
// Title = "Список получений по компонентам",
// ComponentReceivings = GetComponentReceivings(model.Ids)
//});
}
public void SaveReceivingComponentsToXmlFile(ReportBindingModel mode)
{
}
public List<ReportPurchaseReceivingViewModel> GetPurchaseReceiving()
{
throw new NotImplementedException();
}
public List<ReportPurchaseSupplyViewModel> GetPurchaseSupply()
{
throw new NotImplementedException();
}
public void SaveOrdersToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SavePackagesToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveProductComponentToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
} }

View File

@ -1,4 +1,6 @@
using System; using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -8,5 +10,53 @@ namespace ComputerShopBusinessLogic.OfficePackage
{ {
public class AbstractSaveToWord public class AbstractSaveToWord
{ {
public void CreateDoc(WordInfoProvider info)
{
//CreateWord(info);
//CreateParagraph(new WordParagraph
//{
// Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
// TextProperties = new WordTextProperties
// {
// Size = "24",
// JustificationType = WordJustificationType.Center
// }
//});
//foreach (var mc in info.MemberConferences)
//{
// CreateParagraph(new WordParagraph
// {
// Texts = new List<(string, WordTextProperties)>
// { (mc.MemberFIO, new WordTextProperties { Size = "20", Bold=true})},
// TextProperties = new WordTextProperties
// {
// Size = "24",
// JustificationType = WordJustificationType.Both
// }
// });
// foreach (var conference in mc.Conferences)
// {
// CreateParagraph(new WordParagraph
// {
// Texts = new List<(string, WordTextProperties)>
// { (conference.Item1 + " - ", new WordTextProperties { Size = "16", Bold=false}),
// (conference.Item2.ToShortDateString(), new WordTextProperties { Size = "16", Bold=false})},
// TextProperties = new WordTextProperties
// {
// Size = "24",
// JustificationType = WordJustificationType.Both
// }
// });
// }
//}
//SaveWord(info);
}
//protected abstract void CreateWord(WordInfoOrganiser info);
//protected abstract void CreateParagraph(WordParagraph paragraph);
//protected abstract void SaveWord(WordInfoOrganiser info);
} }
} }

View File

@ -0,0 +1,16 @@
using ComputerShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerShopBusinessLogic.OfficePackage.HelperModels
{
public class WordInfoProvider
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public Dictionary<ComponentViewModel, List<EquipmentReceivingViewModel>> ComponentReceivings { get; set; } = new();
}
}

View File

@ -43,6 +43,24 @@ namespace ComputerShopClientApp.Controllers
return View(APIClient.GetRequest<List<AssemblyViewModel>>($"api/Assembly/getassemblylist?clientId={APIClient.Client.Id}")); return View(APIClient.GetRequest<List<AssemblyViewModel>>($"api/Assembly/getassemblylist?clientId={APIClient.Client.Id}"));
} }
public IActionResult Report()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
public IActionResult ReportDocXml()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<ComponentViewModel>>($"api/Component/getcomponentlist?clientId={APIClient.Client.Id}"));
}
[HttpGet] [HttpGet]
public IActionResult Privacy() public IActionResult Privacy()
{ {
@ -84,6 +102,51 @@ namespace ComputerShopClientApp.Controllers
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
} }
[HttpPost]
public void ListMemberConferenceToFile(int[] Ids, string type)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (Ids.Length <= 0)
{
throw new Exception("Количество должно быть больше 0");
}
if (string.IsNullOrEmpty(type))
{
throw new Exception("Неверный тип отчета");
}
List<int> res = new List<int>();
foreach (var item in Ids)
{
res.Add(item);
}
if (type == "docx")
{
APIClient.PostRequest("api/report/createdocreport", new ReportBindingModel
{
Ids = res,
FileName = "F:\\ReportsCourseWork\\wordfile.docx"
});
Response.Redirect("GetWordFile");
}
else
{
APIClient.PostRequest("api/report/createxmlreport", new ReportBindingModel
{
Ids = res,
FileName = "F:\\ReportsCourseWork\\excelfile.xlsx"
});
Response.Redirect("GetExcelFile");
}
}
[HttpGet] [HttpGet]
public IActionResult Enter() public IActionResult Enter()
{ {

View File

@ -0,0 +1,17 @@

<div class="text-center">
<h1 class="display-4">Отчёты</h1>
</div>
<div class="text-center">
@{
<p>
<a asp-action="ReportDocXml">Получения техники по компонентам (docx/xls)</a>
</p>
<p>
<a asp-action="ReportPdf">Связанные закупки и поставки (pdf)</a>
</p>
}
</div>

View File

@ -0,0 +1,89 @@
@using ComputerShopContracts.ViewModels
@model List<ComponentViewModel>
@{
ViewData["Title"] = "ReportDocXml";
}
<div class="text-center">
<h2
class="u-text u-text-custom-color-1 u-text-default u-text-1"
>
Создание отчета по компонентам
</h2>
</div>
<div class="text-center">
<form method="post">
<div>
<label class="u-label u-text-custom-color-1 u-label-1">
Выберите формат файла:
</label>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="docx" id="docx">
<label class="u-label u-text-custom-color-1 u-label-1" for="docx">
Word-файл
</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx" checked>
<label class="u-label u-text-custom-color-1 u-label-1" for="xlsx">
Excel-файл
</label>
</div>
</div>
<div class="u-container-style u-layout-cell u-size-48 u-layout-cell-1">
<div class="u-container-layout u-container-layout-1">
<div class="u-table u-table-responsive u-table-1">
<table class="u-table-entity">
<colgroup>
<col width="9.8%" />
<col width="62.9%" />
<col width="27.3%" />
</colgroup>
<thead
class="u-custom-color-1 u-table-header u-table-header-1">
<tr style="height: 31px">
<th class="u-border-1 u-border-grey-50 u-table-cell">
</th>
<th class="u-border-1 u-border-grey-50 u-table-cell">
Название компонента
</th>
<th class="u-border-1 u-border-grey-50 u-table-cell">
Цена
</th>
</tr>
</thead>
<tbody class="u-table-body">
@foreach (var item in Model)
{
<tr style="height: 75px">
<td
class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell">
<input type="checkbox" class="form-check-input" name="Ids[]" value="@item.Id" id="@item.Id">
</td>
<td
class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell"
>
@Html.DisplayFor(modelItem => item.ComponentName)
</td>
<td
class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell"
>
@Html.DisplayFor(modelItem => item.Cost)
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
<div class="u-align-center u-form-group u-form-submit u-label-top" style="padding-bottom: 120px">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать файл" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1"/></div>
</div>
</form>
</div>

View File

@ -6,8 +6,15 @@
<title>@ViewData["Title"] - ComputerShopClientApp</title> <title>@ViewData["Title"] - ComputerShopClientApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" /> <link rel="stylesheet" href="~/css/site.css" />
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap/bootstrap-dropdown.js"></script>
<script>
$(document).ready(function () {
$('.dropdown-toggle').dropdown()
});
</script>
</head> </head>
<body> <body>
<header> <header>
@ -20,7 +27,7 @@
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse"> <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Закупки</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Component">Компоненты</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Component">Компоненты</a>
@ -38,6 +45,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li> </li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчёты</a>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -9,6 +9,7 @@ namespace ComputerShopContracts.BindingModels
public class ReportBindingModel public class ReportBindingModel
{ {
public string FileName { get; set; } = string.Empty; public string FileName { get; set; } = string.Empty;
public List<int>? Ids { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
} }

View File

@ -20,5 +20,7 @@ namespace ComputerShopContracts.BusinessLogicContracts
void SaveProductComponentToExcelFile(ReportBindingModel model); void SaveProductComponentToExcelFile(ReportBindingModel model);
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
void SaveOrdersToPdfFile(ReportBindingModel model); void SaveOrdersToPdfFile(ReportBindingModel model);
void SaveReceivingComponentsToWordFile(ReportBindingModel model);
void SaveReceivingComponentsToXmlFile(ReportBindingModel model);
} }
} }

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerShopContracts.ViewModels
{
public class ReportComponentReceivingViewModel
{
public string ComponentName { get; set; } = string.Empty;
public List<string> Receivings { get; set; } = new();
}
}

View File

@ -0,0 +1,530 @@
// <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("20230518181418_supplymig")]
partial class supplymig
{
/// <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.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")
.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.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<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int?>("ReceivingId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
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.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)
.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("ComponentSupplies")
.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");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId");
});
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");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", null)
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
});
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("ComponentSupplies");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,95 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class supplymig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_EquipmentReceivings_Supplies_SupplyId",
table: "EquipmentReceivings");
migrationBuilder.DropIndex(
name: "IX_EquipmentReceivings_SupplyId",
table: "EquipmentReceivings");
migrationBuilder.DropColumn(
name: "SupplyId",
table: "EquipmentReceivings");
migrationBuilder.AlterColumn<int>(
name: "ReceivingId",
table: "Supplies",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.CreateIndex(
name: "IX_Supplies_ReceivingId",
table: "Supplies",
column: "ReceivingId");
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_EquipmentReceivings_ReceivingId",
table: "Supplies");
migrationBuilder.DropIndex(
name: "IX_Supplies_ReceivingId",
table: "Supplies");
migrationBuilder.AlterColumn<int>(
name: "ReceivingId",
table: "Supplies",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "SupplyId",
table: "EquipmentReceivings",
type: "int",
nullable: true);
migrationBuilder.AlterColumn<int>(
name: "ClientId",
table: "Assemblies",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.CreateIndex(
name: "IX_EquipmentReceivings_SupplyId",
table: "EquipmentReceivings",
column: "SupplyId");
migrationBuilder.AddForeignKey(
name: "FK_EquipmentReceivings_Supplies_SupplyId",
table: "EquipmentReceivings",
column: "SupplyId",
principalTable: "Supplies",
principalColumn: "Id");
}
}
}

View File

@ -34,7 +34,7 @@ namespace ComputerShopDatabaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int?>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<double>("Price") b.Property<double>("Price")
@ -192,15 +192,10 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int?>("SupplyId")
.HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("SupplyId");
b.ToTable("EquipmentReceivings"); b.ToTable("EquipmentReceivings");
}); });
@ -296,7 +291,7 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Property<int>("OrderId") b.Property<int>("OrderId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("ReceivingId") b.Property<int?>("ReceivingId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("Status") b.Property<int>("Status")
@ -306,6 +301,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("ReceivingId");
b.ToTable("Supplies"); b.ToTable("Supplies");
}); });
@ -337,9 +334,13 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{ {
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Assemblies") .WithMany("Assemblies")
.HasForeignKey("ClientId"); .HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
}); });
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
@ -398,7 +399,7 @@ namespace ComputerShopDatabaseImplement.Migrations
.IsRequired(); .IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply") b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("Supplies") .WithMany("ComponentSupplies")
.HasForeignKey("SupplyId") .HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
@ -413,10 +414,6 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("EquipmentReceivings") .WithMany("EquipmentReceivings")
.HasForeignKey("ClientId"); .HasForeignKey("ClientId");
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", null)
.WithMany("Receivings")
.HasForeignKey("SupplyId");
}); });
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
@ -450,6 +447,10 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Supplies") .WithMany("Supplies")
.HasForeignKey("ClientId"); .HasForeignKey("ClientId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", null)
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
}); });
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
@ -502,6 +503,11 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Navigation("Supplies"); b.Navigation("Supplies");
}); });
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{ {
b.Navigation("Assemblies"); b.Navigation("Assemblies");
@ -511,11 +517,9 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{ {
b.Navigation("ComponentSupplies");
b.Navigation("Orders"); b.Navigation("Orders");
b.Navigation("Receivings");
b.Navigation("Supplies");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View File

@ -5,6 +5,7 @@ using ComputerShopDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -19,6 +20,9 @@ namespace ComputerShopDatabaseImplement.Models
public int Id { get; set; } public int Id { get; set; }
public EquipmentReceivingStatus Status { get; private set; } = EquipmentReceivingStatus.Неизвестен; public EquipmentReceivingStatus Status { get; private set; } = EquipmentReceivingStatus.Неизвестен;
[ForeignKey("ReceivingId")]
public List<Supply> Supplies { get; set; } = new();
public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model) public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model)
{ {
if (model == null) if (model == null)

View File

@ -25,7 +25,6 @@ namespace ComputerShopDatabaseImplement.Models
public int OrderId { get; set; } public int OrderId { get; set; }
public int ReceivingId { get; set; }
private Dictionary<int, (IOrderModel, int)>? _supplyOrders = private Dictionary<int, (IOrderModel, int)>? _supplyOrders =
null; null;
[NotMapped] [NotMapped]
@ -45,9 +44,7 @@ namespace ComputerShopDatabaseImplement.Models
[ForeignKey("SupplyId")] [ForeignKey("SupplyId")]
public virtual List<SupplyOrder> Orders { get; set; } = new(); public virtual List<SupplyOrder> Orders { get; set; } = new();
[ForeignKey("SupplyId")] [ForeignKey("SupplyId")]
public virtual List<EquipmentReceiving> Receivings { get; set; } = new(); public virtual List<ComponentSupply> ComponentSupplies { get; set; } = new();
[ForeignKey("SupplyId")]
public virtual List<ComponentSupply> Supplies { get; set; } = new();
public static Supply Create(ComputerShopDatabase context, SupplyBindingModel model) public static Supply Create(ComputerShopDatabase context, SupplyBindingModel model)
{ {

View File

@ -11,8 +11,7 @@ public class ClientController : Controller
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IClientLogic _logic; private readonly IClientLogic _logic;
public ClientController(IClientLogic logic, ILogger<ClientController> public ClientController(IClientLogic logic, ILogger<ClientController> logger)
logger)
{ {
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;

View File

@ -0,0 +1,46 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
using ComputerShopBusinessLogic.BusinessLogics;
using Microsoft.AspNetCore.Mvc;
using ComputerShopContracts.BusinessLogicContracts;
[Route("api/[controller]/[action]")]
[ApiController]
public class ReportController : Controller
{
private readonly ILogger _logger;
private readonly IReportLogic _reportLogic;
public ReportController(ILogger<ReportController> logger, IReportLogic reportLogic)
{
_logger = logger;
_reportLogic = reportLogic;
}
[HttpPost]
public void CreateDocReport(ReportBindingModel model)
{
try
{
_reportLogic.SaveReceivingComponentsToWordFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateXmlReport(ReportBindingModel model)
{
try
{
_reportLogic.SaveReceivingComponentsToXmlFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
}