PIbd - 21 Bakalskaya E.D. LabWork05 BASE #11
@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
|
@ -106,7 +106,7 @@ namespace SushiBarClientApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.Sushis = APIClient.GetRequest<List<SushiViewModel>>("api/main/getsushislist");
|
||||
ViewBag.Sushis = APIClient.GetRequest<List<SushiViewModel>>("api/main/getsushilist");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
@ -132,8 +132,9 @@ namespace SushiBarClientApp.Controllers
|
||||
[HttpPost]
|
||||
public double Calc(int count, int sushi)
|
||||
{
|
||||
var sush = APIClient.GetRequest<SushiViewModel>($"api/main/getsushi?sushiId={sushi}");
|
||||
return count * (sush?.Price ?? 1);
|
||||
var prod = APIClient.GetRequest<SushiViewModel>($"api/main/getsushi?sushiId={sushi}"
|
||||
);
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,4 +18,4 @@ app.UseAuthorization();
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
app.Run();
|
||||
app.Run();
|
@ -1,31 +1,22 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:41478",
|
||||
"sslPort": 44302
|
||||
}
|
||||
},
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5222",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5222"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7084;http://localhost:5222",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7084;http://localhost:5222"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
@ -34,5 +25,14 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:41478",
|
||||
"sslPort": 44302
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.26" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -8,7 +8,12 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Суши:</div>
|
||||
<div class="col-8">
|
||||
<select id="sushi" name="sushi" class="form-control" aspitems="@(new SelectList(@ViewBag.Sushis,"Id", "SushiName"))"></select>
|
||||
<select id="sushi" name="sushi" class="form-control">
|
||||
@foreach (var sushi in ViewBag.Sushis)
|
||||
{
|
||||
<option value="@sushi.Id">@sushi.SushiName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -46,7 +51,8 @@
|
||||
url: "/Home/Calc",
|
||||
data: { count: count, sushi: sushi },
|
||||
success: function (result) {
|
||||
$("#sum").val(result);
|
||||
var roundedResult = parseFloat(result).toFixed(2);
|
||||
$("#sum").val(roundedResult);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarContracts.BindingModel;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using SushiBarContracts.BindingModel;
|
||||
using SushiBarContracts.SearchModel;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
@ -45,16 +46,30 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue) { return null; }
|
||||
using var context = new SushiBarDatabase();
|
||||
return context.Clients.FirstOrDefault(x => (!(string.IsNullOrEmpty(model.Email)) && model.Email == x.Email) || (model.Id.HasValue && model.Id == x.Id))?.GetViewModel;
|
||||
return GetFilteredList(model).FirstOrDefault();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email)) { return new(); }
|
||||
using var context = new SushiBarDatabase();
|
||||
return context.Clients.Where(x => x.Email.Contains(model.Email)).Select(x => x.GetViewModel).ToList();
|
||||
var clients = context.Clients.Select(x => x.GetViewModel).ToList();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
clients = clients.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
if (!model.Email.IsNullOrEmpty())
|
||||
{
|
||||
clients = clients.Where(x => x.Email == model.Email).ToList();
|
||||
}
|
||||
if (!model.Password.IsNullOrEmpty())
|
||||
{
|
||||
clients = clients.Where(x => x.Password == model.Password).ToList();
|
||||
}
|
||||
if (!model.ClientFIO.IsNullOrEmpty())
|
||||
{
|
||||
clients = clients.Where(x => x.ClientFIO == model.ClientFIO).ToList();
|
||||
}
|
||||
return clients;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFullList()
|
||||
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
|
||||
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.12" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.12" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user