PIbd-23 Dolgov D. A. Lab Work 5 #8
@ -113,7 +113,7 @@ namespace AbstractShowClientApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.Products = APIClient.GetRequest<List<PackageViewModel>>("api/main/getproductlist");
|
||||
ViewBag.Packages = APIClient.GetRequest<List<PackageViewModel>>("api/main/getpackagelist");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ namespace AbstractShowClientApp.Controllers
|
||||
}
|
||||
APIClient.PostRequest("api/main/createorder", new OrderBindingModel
|
||||
{
|
||||
//ClientId = APIClient.Client.Id,
|
||||
ClientId = APIClient.Client.Id,
|
||||
PackageId = package,
|
||||
Count = count,
|
||||
Sum = Calc(count, package)
|
||||
@ -141,7 +141,7 @@ namespace AbstractShowClientApp.Controllers
|
||||
[HttpPost]
|
||||
public double Calc(int count, int package)
|
||||
{
|
||||
var prod = APIClient.GetRequest<PackageViewModel>($"api/main/getproduct?productId={package}");
|
||||
var prod = APIClient.GetRequest<PackageViewModel>($"api/main/getpackage?packageId={package}");
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
using AbstractSoftwareInstallationClientApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// 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())
|
||||
|
@ -7,5 +7,5 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"IPAddress": "http://localhost:7208/"
|
||||
"IPAddress": "http://localhost:5208/"
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ namespace AbstractSoftwareInstallationContracts.ViewModels
|
||||
[DisplayName("Пакет")]
|
||||
public string PackageName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Логин клиента")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
|
@ -34,16 +34,26 @@ namespace AbstractSoftwareInstallationDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Orders.Include(x => x.Package).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Package).Include(x => x.Client).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
|
||||
if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Package)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return context.Orders
|
||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||
.Include(x => x.Package)
|
||||
.Include(x => x.Package).Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
@ -53,7 +63,7 @@ namespace AbstractSoftwareInstallationDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new AbstractSoftwareInstallationDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Package)
|
||||
.Include(x => x.Package).Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -69,7 +79,7 @@ namespace AbstractSoftwareInstallationDatabaseImplement.Implements
|
||||
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;
|
||||
return context.Orders.Include(x => x.Package).Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
|
||||
}
|
||||
|
||||
@ -83,7 +93,7 @@ namespace AbstractSoftwareInstallationDatabaseImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Package).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Package).Include(x => x.Client).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,8 @@ namespace AbstractPackageInstallationDatabaseImplement.Models
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
PackageName = Package.PackageName
|
||||
PackageName = Package.PackageName,
|
||||
Email = Client.Email
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -81,10 +81,15 @@ namespace AbstractSoftwareInstallationFileImplement.Implements
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var package = source.Packages.FirstOrDefault(x => x.Id == order.PackageId);
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||
if (package != null)
|
||||
{
|
||||
viewModel.PackageName = package.PackageName;
|
||||
}
|
||||
if (client != null)
|
||||
{
|
||||
viewModel.Email = client.Email;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,14 @@ namespace AbstractOrderInstallationListImplement.Implements
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Id == order.ClientId)
|
||||
{
|
||||
viewModel.Email = client.Email;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -17,4 +17,19 @@
|
||||
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -32,21 +32,21 @@ namespace AbstractSoftwareInstallationRestApi.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
||||
_logger.LogError(ex, "Ошибка получения списка пакетов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PackageViewModel? GetPackage(int productId)
|
||||
public PackageViewModel? GetPackage(int packageId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _package.ReadElement(new PackageSearchModel { Id = productId });
|
||||
return _package.ReadElement(new PackageSearchModel { Id = packageId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения продукта по id={Id}", productId);
|
||||
_logger.LogError(ex, "Ошибка получения продукта по id={Id}", packageId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AbstractSoftwareInstallationRestApi v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
63
SoftwareInstallation/AbstractSoftwareInstallationRestApi/Properties/Resources.Designer.cs
generated
Normal file
63
SoftwareInstallation/AbstractSoftwareInstallationRestApi/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AbstractSoftwareInstallationRestApi.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AbstractSoftwareInstallationRestApi.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<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" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</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>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -43,6 +43,7 @@
|
||||
this.buttonRef.TabIndex = 7;
|
||||
this.buttonRef.Text = "Обновить";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
@ -53,6 +54,7 @@
|
||||
this.buttonDel.TabIndex = 6;
|
||||
this.buttonDel.Text = "Удалить";
|
||||
this.buttonDel.UseVisualStyleBackColor = true;
|
||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
@ -82,6 +84,7 @@
|
||||
this.Text = "FormClients";
|
||||
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.Load += new EventHandler(FormClients_Load);
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace SoftwareInstallationView
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ namespace SoftwareInstallationView
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["PackageId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user
Заголовок формы оформлен неверно