fix
This commit is contained in:
parent
5f5c290acf
commit
d4e4e44d4c
@ -12,5 +12,6 @@ namespace CanteenContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int VisitorId { get; set; }
|
public int VisitorId { get; set; }
|
||||||
public string TablewareName { get; set; } = string.Empty;
|
public string TablewareName { get; set; } = string.Empty;
|
||||||
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ namespace CanteenContracts.View
|
|||||||
|
|
||||||
[DisplayName("Название прибора")]
|
[DisplayName("Название прибора")]
|
||||||
public string TablewareName { get; set; } = string.Empty;
|
public string TablewareName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Количество")]
|
||||||
|
public int Count { get; set; }
|
||||||
[DisplayName("ID прибора")]
|
[DisplayName("ID прибора")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace CanteenDataModels.Models
|
|||||||
{
|
{
|
||||||
int VisitorId { get; }
|
int VisitorId { get; }
|
||||||
string TablewareName { get; }
|
string TablewareName { get; }
|
||||||
|
int Count { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace CanteenDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-AOSK1F5\SQLEXPRESS;Initial Catalog=CanteenDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-A68O3K0;Initial Catalog=CanteenDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
public int VisitorId { get; private set; }
|
public int VisitorId { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string TablewareName { get; private set; } = string.Empty;
|
public string TablewareName { get; private set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int Count { get; private set; }
|
||||||
[ForeignKey("TablewareId")]
|
[ForeignKey("TablewareId")]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
public virtual Visitor Visitor { get; set; }
|
public virtual Visitor Visitor { get; set; }
|
||||||
@ -33,7 +35,8 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
VisitorId = model.VisitorId,
|
VisitorId = model.VisitorId,
|
||||||
TablewareName = model.TablewareName
|
TablewareName = model.TablewareName,
|
||||||
|
Count = model.Count
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using CanteenContracts.BindingModels;
|
||||||
using CanteenContracts.BusinessLogicsContracts;
|
using CanteenContracts.BusinessLogicsContracts;
|
||||||
using CanteenContracts.View;
|
using CanteenContracts.View;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -12,13 +13,15 @@ namespace CanteenRestApi.Controllers
|
|||||||
private readonly ICookLogic _cook;
|
private readonly ICookLogic _cook;
|
||||||
private readonly IDishLogic _dish;
|
private readonly IDishLogic _dish;
|
||||||
private readonly IProductLogic _product;
|
private readonly IProductLogic _product;
|
||||||
|
private readonly ITablewareLogic _tableware;
|
||||||
|
|
||||||
public MainController(ILogger<MainController> logger, ICookLogic cook, IDishLogic dish, IProductLogic product)
|
public MainController(ILogger<MainController> logger, ICookLogic cook, IDishLogic dish, IProductLogic product, ITablewareLogic tableware)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_cook = cook;
|
_cook = cook;
|
||||||
_dish = dish;
|
_dish = dish;
|
||||||
_product = product;
|
_product = product;
|
||||||
|
_tableware = tableware;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -34,5 +37,31 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public List<TablewareViewModel>? GetTablewareList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _tableware.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateTableware(TablewareBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_tableware.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,11 +14,13 @@ builder.Services.AddTransient<IManagerStorage, ManagerStorage>();
|
|||||||
builder.Services.AddTransient<ICookStorage, CookStorage>();
|
builder.Services.AddTransient<ICookStorage, CookStorage>();
|
||||||
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
||||||
builder.Services.AddTransient<IDishStorage, DishStorage>();
|
builder.Services.AddTransient<IDishStorage, DishStorage>();
|
||||||
|
builder.Services.AddTransient<ITablewareStorage, TablewareStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IManagerLogic, ManagerLogic>();
|
builder.Services.AddTransient<IManagerLogic, ManagerLogic>();
|
||||||
builder.Services.AddTransient<ICookLogic, CookLogic>();
|
builder.Services.AddTransient<ICookLogic, CookLogic>();
|
||||||
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
||||||
builder.Services.AddTransient<IDishLogic, DishLogic>();
|
builder.Services.AddTransient<IDishLogic, DishLogic>();
|
||||||
|
builder.Services.AddTransient<ITablewareLogic, TablewareLogic>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
@ -8,8 +8,6 @@ namespace CanteenVisitorApp
|
|||||||
public static class APIClient
|
public static class APIClient
|
||||||
{
|
{
|
||||||
private static readonly HttpClient _client = new();
|
private static readonly HttpClient _client = new();
|
||||||
public static VisitorViewModel? Manager { get; set; } = null;
|
|
||||||
|
|
||||||
public static void Connect(IConfiguration configuration)
|
public static void Connect(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
@ -17,7 +15,6 @@ namespace CanteenVisitorApp
|
|||||||
_client.DefaultRequestHeaders.Accept.Add(new
|
_client.DefaultRequestHeaders.Accept.Add(new
|
||||||
MediaTypeWithQualityHeaderValue("application/json"));
|
MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T? GetRequest<T>(string requestUrl)
|
public static T? GetRequest<T>(string requestUrl)
|
||||||
{
|
{
|
||||||
var response = _client.GetAsync(requestUrl);
|
var response = _client.GetAsync(requestUrl);
|
||||||
@ -31,7 +28,6 @@ namespace CanteenVisitorApp
|
|||||||
throw new Exception(result);
|
throw new Exception(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PostRequest<T>(string requestUrl, T model)
|
public static void PostRequest<T>(string requestUrl, T model)
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(model);
|
var json = JsonConvert.SerializeObject(model);
|
||||||
|
@ -17,4 +17,10 @@
|
|||||||
<ProjectReference Include="..\CanteenDataModels\CanteenDataModels.csproj" />
|
<ProjectReference Include="..\CanteenDataModels\CanteenDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using CanteenContracts.View;
|
using CanteenContracts.BindingModels;
|
||||||
|
using CanteenContracts.View;
|
||||||
using CanteenVisitorApp.Models;
|
using CanteenVisitorApp.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -27,7 +28,7 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
public IActionResult Lunches()
|
public IActionResult Lunches()
|
||||||
{
|
{
|
||||||
|
|
||||||
//ViewBag.Cooks = APIClient.GetRequest<List<LunchViewModel>>("api/main/getcooklist");
|
ViewBag.Cooks = APIClient.GetRequest<List<LunchViewModel>>("api/main/getcooklist");
|
||||||
ViewBag.Lunches = new List<LunchViewModel>();
|
ViewBag.Lunches = new List<LunchViewModel>();
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
@ -35,7 +36,7 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Tablewares()
|
public IActionResult Tablewares()
|
||||||
{
|
{
|
||||||
ViewBag.Tablewares = new List<TablewareViewModel>();
|
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>("api/main/gettablewarelist");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +61,18 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateTableware(string TablewareName, int TablewareCount)
|
||||||
|
{
|
||||||
|
APIClient.PostRequest("api/main/CreateTableware", new TablewareBindingModel
|
||||||
|
{
|
||||||
|
VisitorId = 1,
|
||||||
|
TablewareName = TablewareName,
|
||||||
|
Count = TablewareCount
|
||||||
|
});
|
||||||
|
Response.Redirect("Tablewares");
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateTableware()
|
public IActionResult CreateTableware()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
|
using CanteenVisitorApp;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
APIClient.Connect(builder.Configuration);
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
|
@ -14,7 +14,13 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название прибора:</div>
|
<div class="col-4">Название прибора:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<input type="text" name="OrderName" id="OrderName" />
|
<input type="text" name="TablewareName" id="TablewareName" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Количество:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="number" name="TablewareCount" id="TablewareCount" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Loading…
Reference in New Issue
Block a user