2023-05-16 19:13:19 +04:00
|
|
|
|
using CanteenContracts.BindingModels;
|
2023-05-17 17:02:26 +04:00
|
|
|
|
using CanteenContracts.SearchModel;
|
2023-05-16 19:13:19 +04:00
|
|
|
|
using CanteenContracts.View;
|
2023-05-17 17:59:48 +04:00
|
|
|
|
using CanteenContracts.ViewModels;
|
2023-05-17 17:02:26 +04:00
|
|
|
|
using CanteenDatabaseImplement.Models;
|
|
|
|
|
using CanteenDataModels.Models;
|
2023-04-09 19:05:54 +04:00
|
|
|
|
using CanteenManagerApp.Models;
|
2023-05-17 17:02:26 +04:00
|
|
|
|
using FluentNHibernate.Conventions;
|
2023-04-09 19:05:54 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2023-05-17 17:02:26 +04:00
|
|
|
|
using System.Data;
|
2023-04-09 19:05:54 +04:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace CanteenManagerApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpGet]
|
2023-04-09 19:05:54 +04:00
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
2023-05-16 19:13:19 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-09 19:05:54 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2023-04-09 19:05:54 +04:00
|
|
|
|
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Enter(string login, string password)
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин и пароль");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
APIClient.Manager = APIClient.GetRequest<ManagerViewModel>($"api/manager/login?login={login}&password={password}");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
throw new Exception("Неверный логин/пароль");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
|
|
|
|
|
Response.Redirect("Index");
|
2023-04-09 19:05:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-17 17:02:26 +04:00
|
|
|
|
public IActionResult Register()
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string login, string password, string fio, string phoneNumber)
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин, пароль и ФИО");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
APIClient.PostRequest("api/manager/register", new ManagerBindingModel
|
|
|
|
|
{
|
|
|
|
|
FIO = fio,
|
|
|
|
|
Login = login,
|
|
|
|
|
Password = password,
|
|
|
|
|
PhoneNumber = phoneNumber
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Response.Redirect("Enter");
|
2023-04-09 19:05:54 +04:00
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult CookList()
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
2023-04-09 19:05:54 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
|
2023-04-09 19:05:54 +04:00
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult CookCreate()
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-04-09 19:05:54 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
|
2023-05-16 19:13:19 +04:00
|
|
|
|
[HttpPost]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public void CookCreate(string FIO, string position)
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(FIO))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("ФИО не должно быть пустым");
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/cookcreate", new CookBindingModel
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
|
|
|
|
ManagerId = APIClient.Manager.Id,
|
|
|
|
|
FIO = FIO,
|
|
|
|
|
Position = position
|
|
|
|
|
});
|
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("CookList");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult CookDelete()
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
|
|
|
|
return View();
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CookDelete(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
|
|
|
|
if (id <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Выберите повара");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/main/CookDelete", new CookBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = id
|
|
|
|
|
});
|
2023-04-09 19:05:54 +04:00
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("CookList");
|
|
|
|
|
}
|
2023-04-09 19:05:54 +04:00
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult CookUpdate()
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public void CookUpdate(int Id, string FIO, string position)
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/CookUpdate", new CookBindingModel
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Id = Id,
|
2023-05-17 17:02:26 +04:00
|
|
|
|
FIO = FIO,
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Position = position,
|
|
|
|
|
ManagerId = APIClient.Manager.Id
|
2023-05-17 17:02:26 +04:00
|
|
|
|
});
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("CookList");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult ProductList()
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
2023-04-09 19:05:54 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult ProductCreate()
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
2023-04-09 19:05:54 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpPost]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public void ProductCreate(string name, double price)
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
2023-04-09 19:05:54 +04:00
|
|
|
|
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Наименование продукта не должно быть пустым");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/ProductCreate", new ProductBindingModel
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
ManagerId = APIClient.Manager.Id,
|
|
|
|
|
ProductName = name,
|
|
|
|
|
Price = price
|
|
|
|
|
});
|
2023-05-16 19:13:19 +04:00
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("ProductList");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
}
|
2023-05-16 19:13:19 +04:00
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult ProductAddCooks()
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
|
|
|
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
|
2023-05-16 19:13:19 +04:00
|
|
|
|
[HttpPost]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public void ProductAddCooks(int selectedProduct, int selectedCook)
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (selectedProduct <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Должен быть выбран продукт");
|
|
|
|
|
}
|
|
|
|
|
if (selectedCook <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Должен быть выбран повар");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/ProductAddCooks", Tuple.Create
|
2023-05-17 17:02:26 +04:00
|
|
|
|
(
|
|
|
|
|
new ProductSearchModel { Id = selectedProduct },
|
|
|
|
|
new CookViewModel { Id = selectedCook }
|
|
|
|
|
));
|
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("ProductList");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult ProductDelete()
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
2023-05-16 19:13:19 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
return Redirect("~/Home/Enter");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
|
|
|
|
return Redirect("~/Home/ProductList");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void ProductDelete(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
|
|
|
|
if (id <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Выберите продукт");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/main/ProductDelete", new ProductBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = id
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Response.Redirect("ProductList");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
}
|
2023-05-16 19:13:19 +04:00
|
|
|
|
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult ProductUpdate()
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public void ProductUpdate(int Id, string name, double price)
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/productupdate", new ProductBindingModel
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Id = Id,
|
|
|
|
|
ProductName = name,
|
|
|
|
|
Price = price,
|
|
|
|
|
ManagerId = APIClient.Manager.Id
|
2023-05-17 17:02:26 +04:00
|
|
|
|
});
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("ProductList");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult DishList()
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.DishList = APIClient.GetRequest<List<DishViewModel>>($"api/main/GetDishList?managerId={APIClient.Manager.Id}");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult DishCreate()
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-16 19:13:19 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public void DishCreate(string name)
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
if (string.IsNullOrEmpty(name))
|
2023-05-16 19:13:19 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
throw new Exception("Наименование блюда не должно быть пустым");
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/dishcreate", new DishBindingModel
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
ManagerId = APIClient.Manager.Id,
|
2023-05-18 01:40:11 +04:00
|
|
|
|
DishName = name
|
2023-05-16 19:13:19 +04:00
|
|
|
|
});
|
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("DishList");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult DishAddProducts()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.DishList = APIClient.GetRequest<List<DishViewModel>>($"api/main/getdishlist?managerId={APIClient.Manager.Id}");
|
|
|
|
|
ViewBag.productList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DishAddProducts(int selectedDish, int selectedProduct, int count)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selectedDish <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Должно быть выбрано блюдо");
|
|
|
|
|
}
|
|
|
|
|
if (selectedProduct <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Должен быть выбран продукт");
|
|
|
|
|
}
|
|
|
|
|
if (count <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Количество продукта должно быть больше 0");
|
|
|
|
|
}
|
2023-05-19 03:39:58 +04:00
|
|
|
|
ProductViewModel product = APIClient.GetRequest<ProductViewModel>($"api/main/getproduct?id={selectedProduct}");
|
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/dishaddproducts", Tuple.Create
|
|
|
|
|
(
|
2023-05-19 03:39:58 +04:00
|
|
|
|
new DishBindingModel { Id = selectedDish },
|
|
|
|
|
new ProductViewModel { Id = selectedProduct, Price = product.Price },
|
2023-05-18 01:40:11 +04:00
|
|
|
|
count
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
Response.Redirect("DishList");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
}
|
2023-05-16 19:13:19 +04:00
|
|
|
|
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult DishDelete()
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.DishList = APIClient.GetRequest<List<DishViewModel>>($"api/main/getdishlist?managerId={APIClient.Manager.Id}");
|
|
|
|
|
return View();
|
2023-05-16 19:13:19 +04:00
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DishDelete(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
|
|
|
|
if (id <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Выберите блюдо");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/main/DishDelete", new DishBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = id
|
|
|
|
|
});
|
2023-05-16 19:13:19 +04:00
|
|
|
|
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("ProductList");
|
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
[HttpGet]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public IActionResult DishUpdate()
|
2023-04-09 19:05:54 +04:00
|
|
|
|
{
|
2023-05-17 17:02:26 +04:00
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
ViewBag.DishList = APIClient.GetRequest<List<DishViewModel>>($"api/main/getdishlist?managerId={APIClient.Manager.Id}");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
return View();
|
2023-04-09 19:05:54 +04:00
|
|
|
|
}
|
2023-05-17 17:02:26 +04:00
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2023-05-18 01:40:11 +04:00
|
|
|
|
public void DishUpdate(int Id, string name, double price)
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
|
|
|
|
}
|
2023-05-18 01:40:11 +04:00
|
|
|
|
APIClient.PostRequest("api/main/DishUpdate", new DishBindingModel
|
2023-05-17 17:02:26 +04:00
|
|
|
|
{
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Id = Id,
|
|
|
|
|
DishName = name,
|
|
|
|
|
Price = price,
|
|
|
|
|
ManagerId = APIClient.Manager.Id
|
2023-05-17 17:02:26 +04:00
|
|
|
|
});
|
2023-05-18 01:40:11 +04:00
|
|
|
|
Response.Redirect("DishList");
|
2023-05-17 17:02:26 +04:00
|
|
|
|
}
|
2023-05-17 17:59:48 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Graphic()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Manager == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Model = APIClient.GetRequest<List<GraphicViewModel>>($"api/main/GetGraphic");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2023-04-09 19:05:54 +04:00
|
|
|
|
}
|
|
|
|
|
}
|