Спокойной ночи, малыши))
This commit is contained in:
parent
a254af4259
commit
24f1159217
@ -6,4 +6,13 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -6,4 +6,15 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -25,12 +25,12 @@ namespace BankContracts.ViewModels
|
|||||||
$"Сделка, созданная {DatePurchase}, включает в себя операции:");
|
$"Сделка, созданная {DatePurchase}, включает в себя операции:");
|
||||||
for (int i = 0; i < OperationViewModels.Count; i++)
|
for (int i = 0; i < OperationViewModels.Count; i++)
|
||||||
{
|
{
|
||||||
var car = OperationViewModels[i];
|
var operation = OperationViewModels[i];
|
||||||
if (car == null)
|
if (operation == null)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result.Append($"\n\t{i + 1}. {car.Mark} {car.Model} стоимостью {car.Price}");
|
result.Append($"\n\t{i + 1}. {operation.Mark} {operation.Model} стоимостью {operation.Price}");
|
||||||
}
|
}
|
||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,22 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -98,14 +98,14 @@ namespace BankDatabaseImplement.Implements
|
|||||||
public OperationViewModel? Update(OperationBindingModel model)
|
public OperationViewModel? Update(OperationBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new BankDB();
|
using var context = new BankDB();
|
||||||
var car = context.Operations.FirstOrDefault(x => x.Id == model.Id);
|
var operation = context.Operations.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (car == null)
|
if (operation == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
car.Update(model);
|
operation.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return car.GetViewModel;
|
return operation.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,15 +44,15 @@ namespace BankDatabaseImplement.Implements
|
|||||||
throw new ArgumentNullException(nameof(modelOperation), "Получена поисковая модель без Id");
|
throw new ArgumentNullException(nameof(modelOperation), "Получена поисковая модель без Id");
|
||||||
}
|
}
|
||||||
using var context = new BankDB();
|
using var context = new BankDB();
|
||||||
var carByPurchase = context.OperationByPurchases
|
var operationByPurchase = context.OperationByPurchases
|
||||||
.Include(x => x.Payments)
|
.Include(x => x.Payments)
|
||||||
.FirstOrDefault(x => x.OperationId == modelOperation.Id && x.PurchaseId == modelPurchase.Id);
|
.FirstOrDefault(x => x.OperationId == modelOperation.Id && x.PurchaseId == modelPurchase.Id);
|
||||||
if (carByPurchase?.Payments == null)
|
if (operationByPurchase?.Payments == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"Не существует связи между данной операции(Id={modelOperation.Id}) и покупкой(Id={modelPurchase.Id})");
|
$"Не существует связи между данной операции(Id={modelOperation.Id}) и покупкой(Id={modelPurchase.Id})");
|
||||||
}
|
}
|
||||||
return carByPurchase.Payments.Select(payment => payment.GetViewModel).ToList();
|
return operationByPurchase.Payments.Select(payment => payment.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
|
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
|
||||||
|
Loading…
Reference in New Issue
Block a user