crud completely finished
This commit is contained in:
parent
8088518d83
commit
f411d90acb
@ -116,7 +116,7 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
if (model.ManagerId <= 0)
|
if (model.ManagerId <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("id менеджера должен дыть больше 0", nameof(model.ManagerId));
|
throw new ArgumentNullException("id менеджера должен быть больше 0", nameof(model.ManagerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.Position))
|
if (string.IsNullOrEmpty(model.Position))
|
||||||
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -115,11 +116,6 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException("Нет названия блюда", nameof(model.DishName));
|
throw new ArgumentNullException("Нет названия блюда", nameof(model.DishName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.Price <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена блюда должна быть больше 0", nameof(model.Price));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.ManagerId <= 0)
|
if (model.ManagerId <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("id менеджера должен быть больше 0", nameof(model.ManagerId));
|
throw new ArgumentNullException("id менеджера должен быть больше 0", nameof(model.ManagerId));
|
||||||
@ -133,5 +129,25 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
throw new InvalidOperationException("Блюдо с таким названием уже есть");
|
throw new InvalidOperationException("Блюдо с таким названием уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AddCooksToProduct(DishSearchModel model, ProductViewModel product, int count)
|
||||||
|
{
|
||||||
|
var dish = _dishStorage.GetElement(model);
|
||||||
|
dish.DishProducts[product.Id] = (product, count);
|
||||||
|
if (_dishStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = dish.Id,
|
||||||
|
DishName = dish.DishName,
|
||||||
|
ManagerId = dish.ManagerId,
|
||||||
|
DishProducts = dish.DishProducts
|
||||||
|
|
||||||
|
}) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,5 @@ 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; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,6 @@ namespace CanteenContracts.BusinessLogicsContracts
|
|||||||
bool Create(DishBindingModel model);
|
bool Create(DishBindingModel model);
|
||||||
bool Update(DishBindingModel model);
|
bool Update(DishBindingModel model);
|
||||||
bool Delete(DishBindingModel model);
|
bool Delete(DishBindingModel model);
|
||||||
|
bool AddCooksToProduct(DishSearchModel model, ProductViewModel product, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using CanteenDataModels.Models;
|
using CanteenDataModels.Models;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -18,5 +19,11 @@ namespace CanteenContracts.View
|
|||||||
public int ManagerId { get; set; }
|
public int ManagerId { get; set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public Dictionary<int, (IProductModel, int)> DishProducts { get; set; }
|
public Dictionary<int, (IProductModel, int)> DishProducts { get; set; }
|
||||||
|
public DishViewModel() { }
|
||||||
|
[JsonConstructor]
|
||||||
|
public DishViewModel(Dictionary<int, (ProductViewModel, int)> DishProducts)
|
||||||
|
{
|
||||||
|
this.DishProducts = DishProducts.ToDictionary(x => x.Key, x => (x.Value.Item1 as IProductModel, x.Value.Item2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ 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,6 +10,5 @@ namespace CanteenDataModels.Models
|
|||||||
{
|
{
|
||||||
int VisitorId { get; }
|
int VisitorId { get; }
|
||||||
string TablewareName { get; }
|
string TablewareName { get; }
|
||||||
int Count { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<DishViewModel> GetFilteredList(DishSearchModel model)
|
public List<DishViewModel> GetFilteredList(DishSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.DishName))
|
if (string.IsNullOrEmpty(model.DishName) && !model.ManagerId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
@ -99,6 +99,8 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
dish.Update(model);
|
dish.Update(model);
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
if (model.DishProducts != null)
|
||||||
|
dish.UpdateDishProduct(context, model);
|
||||||
context.Database.CommitTransaction();
|
context.Database.CommitTransaction();
|
||||||
|
|
||||||
return dish.GetViewModel;
|
return dish.GetViewModel;
|
||||||
|
@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace CanteenDatabaseImplement.Migrations
|
namespace CanteenDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(CanteenDatabase))]
|
[DbContext(typeof(CanteenDatabase))]
|
||||||
[Migration("20230408175356_InitialMigr")]
|
[Migration("20230517172033_InitMigr")]
|
||||||
partial class InitialMigr
|
partial class InitMigr
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -210,6 +210,9 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int?>("CountTablewares")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
@ -217,7 +220,8 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.Property<double?>("Sum")
|
b.Property<double?>("Sum")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.Property<int>("TablewareId")
|
b.Property<int?>("TablewareId")
|
||||||
|
.IsRequired()
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("VisitorId")
|
b.Property<int>("VisitorId")
|
||||||
@ -322,9 +326,6 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("TablewareName")
|
b.Property<string>("TablewareName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace CanteenDatabaseImplement.Migrations
|
namespace CanteenDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class InitialMigr : Migration
|
public partial class InitMigr : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
@ -137,8 +137,7 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
Id = table.Column<int>(type: "int", nullable: false)
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
VisitorId = table.Column<int>(type: "int", nullable: false),
|
VisitorId = table.Column<int>(type: "int", nullable: false),
|
||||||
TablewareName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
TablewareName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
Count = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -230,6 +229,7 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
VisitorId = table.Column<int>(type: "int", nullable: false),
|
VisitorId = table.Column<int>(type: "int", nullable: false),
|
||||||
TablewareId = table.Column<int>(type: "int", nullable: false),
|
TablewareId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
CountTablewares = table.Column<int>(type: "int", nullable: true),
|
||||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
Sum = table.Column<double>(type: "float", nullable: true)
|
Sum = table.Column<double>(type: "float", nullable: true)
|
||||||
},
|
},
|
@ -207,6 +207,9 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int?>("CountTablewares")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
@ -214,7 +217,8 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.Property<double?>("Sum")
|
b.Property<double?>("Sum")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.Property<int>("TablewareId")
|
b.Property<int?>("TablewareId")
|
||||||
|
.IsRequired()
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("VisitorId")
|
b.Property<int>("VisitorId")
|
||||||
@ -319,9 +323,6 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("TablewareName")
|
b.Property<string>("TablewareName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
@ -12,84 +12,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace CanteenDatabaseImplement.Models
|
namespace CanteenDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
//public class Dish : IDishModel
|
|
||||||
//{
|
|
||||||
// public int Id { get; private set; }
|
|
||||||
// [Required]
|
|
||||||
// public string DishName { get; private set; } = string.Empty;
|
|
||||||
// [Required]
|
|
||||||
// public double Cost { get; private set; }
|
|
||||||
// [Required]
|
|
||||||
// public int ManagerId { get; private set; }
|
|
||||||
// private Dictionary<int, (IProductModel, int)>? _dishProduct = null;
|
|
||||||
// public Dictionary<int, (IProductModel, int)> DishProduct
|
|
||||||
// {
|
|
||||||
// get
|
|
||||||
// {
|
|
||||||
// if (_dishProduct == null)
|
|
||||||
// {
|
|
||||||
// _dishProduct = Product
|
|
||||||
// .ToDictionary(recPC => recPC.ProductId, recPC => (recPC.Product as IProductModel, recPC.CountProductProduct));
|
|
||||||
// }
|
|
||||||
// return _dishProduct;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// [ForeignKey("DishId")]
|
|
||||||
// public virtual List<DishProduct> Product { get; set; } = new();
|
|
||||||
// public static Dish? Create(CanteenDatabase context, DishBindingModel model)
|
|
||||||
// {
|
|
||||||
// return new Dish()
|
|
||||||
// {
|
|
||||||
// Id = model.Id,
|
|
||||||
// DishName = model.DishName,
|
|
||||||
// Cost = model.Cost,
|
|
||||||
// Product = model.DishProduct.Select(x => new DishProduct
|
|
||||||
// {
|
|
||||||
// Product = context.Product.First(y => y.Id == x.Key)
|
|
||||||
// }).ToList()
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Update(DishBindingModel model)
|
|
||||||
// {
|
|
||||||
// DishName = model.DishName;
|
|
||||||
// Cost = model.Cost;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public DishViewModel GetViewModel => new()
|
|
||||||
// {
|
|
||||||
// Id = Id,
|
|
||||||
// DishName = DishName,
|
|
||||||
// Cost = Cost,
|
|
||||||
// DishProduct = DishProduct,
|
|
||||||
// ManagerId = ManagerId
|
|
||||||
// };
|
|
||||||
|
|
||||||
// public Dictionary<int, (IProductModel, int)> DishProduct => throw new NotImplementedException();
|
|
||||||
|
|
||||||
// public void UpdateProduct(CanteenDatabase context, DishBindingModel model)
|
|
||||||
// {
|
|
||||||
// var dishProduct = context.DishProduct.Where(record => record.ProductId == model.Id).ToList();
|
|
||||||
// if (dishProduct != null && dishProduct.CountProduct > 0)
|
|
||||||
// {
|
|
||||||
// context.DishProduct.RemoveRange(dishProduct.Where(record => !model.DishProduct.ContainsKey(record.ProductId)));
|
|
||||||
// context.SaveChanges();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var product = context.Product.First(x => x.Id == Id);
|
|
||||||
// foreach (var pc in model.DishProduct)
|
|
||||||
// {
|
|
||||||
// context.DishProduct.Add(new DishProduct
|
|
||||||
// {
|
|
||||||
// Product = product,
|
|
||||||
// Dish = context.Dishes.First(x => x.Id == pc.Key),
|
|
||||||
// });
|
|
||||||
// context.SaveChanges();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _dishProduct = null;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public class Dish : IDishModel
|
public class Dish : IDishModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@ -10,7 +10,7 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
public class ProductCook
|
public class ProductCook
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
|
@ -19,8 +19,6 @@ 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; }
|
||||||
@ -35,8 +33,7 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
VisitorId = model.VisitorId,
|
VisitorId = model.VisitorId,
|
||||||
TablewareName = model.TablewareName,
|
TablewareName = model.TablewareName
|
||||||
Count = model.Count
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +77,6 @@ namespace CanteenManagerApp.Controllers
|
|||||||
});
|
});
|
||||||
|
|
||||||
Response.Redirect("Enter");
|
Response.Redirect("Enter");
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
@ -88,18 +86,18 @@ namespace CanteenManagerApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Cooks()
|
public IActionResult CookList()
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Cooks = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist? ={APIClient.Manager.Id}");
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateCook()
|
public IActionResult CookCreate()
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
@ -109,7 +107,7 @@ namespace CanteenManagerApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateCook(string FIO, string position)
|
public void CookCreate(string FIO, string position)
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
@ -121,77 +119,96 @@ namespace CanteenManagerApp.Controllers
|
|||||||
throw new Exception("ФИО не должно быть пустым");
|
throw new Exception("ФИО не должно быть пустым");
|
||||||
}
|
}
|
||||||
|
|
||||||
APIClient.PostRequest("api/main/createcook", new CookBindingModel
|
APIClient.PostRequest("api/main/cookcreate", new CookBindingModel
|
||||||
{
|
{
|
||||||
ManagerId = APIClient.Manager.Id,
|
ManagerId = APIClient.Manager.Id,
|
||||||
FIO = FIO,
|
FIO = FIO,
|
||||||
Position = position
|
Position = position
|
||||||
});
|
});
|
||||||
|
|
||||||
Response.Redirect("Cooks");
|
Response.Redirect("CookList");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult DeleteCook(int CookId)
|
public IActionResult CookDelete()
|
||||||
{
|
|
||||||
if (APIClient.Manager == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
APIClient.PostRequest("api/main/deletecook", new CookBindingModel { Id = CookId }); ;
|
|
||||||
return Redirect("~/Home/Cooks");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult UpdateCook()
|
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateCook(string FIO, string postition)
|
public void CookDelete(int id)
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Доступ возможен только авторизованным пользователям");
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/updatecook", new CookBindingModel
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
Id = APIClient.Manager.Id,
|
throw new Exception("Выберите повара");
|
||||||
FIO = FIO,
|
}
|
||||||
Position = postition
|
APIClient.PostRequest("api/main/CookDelete", new CookBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
});
|
});
|
||||||
Response.Redirect("Cooks");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Response.Redirect("CookList");
|
||||||
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Products()
|
public IActionResult CookUpdate()
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Products = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult CreateProduct()
|
|
||||||
{
|
|
||||||
if (APIClient.Manager == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
ViewBag.Cooks = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateProduct(string name, double price)
|
public void CookUpdate(int Id, string FIO, string position)
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/main/CookUpdate", new CookBindingModel
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
FIO = FIO,
|
||||||
|
Position = position,
|
||||||
|
ManagerId = APIClient.Manager.Id
|
||||||
|
});
|
||||||
|
Response.Redirect("CookList");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult ProductList()
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult ProductCreate()
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void ProductCreate(string name, double price)
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
@ -202,29 +219,29 @@ namespace CanteenManagerApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Наименование продукта не должно быть пустым");
|
throw new Exception("Наименование продукта не должно быть пустым");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/createproduct", new ProductBindingModel
|
APIClient.PostRequest("api/main/ProductCreate", new ProductBindingModel
|
||||||
{
|
{
|
||||||
ManagerId = APIClient.Manager.Id,
|
ManagerId = APIClient.Manager.Id,
|
||||||
ProductName = name,
|
ProductName = name,
|
||||||
Price = price
|
Price = price
|
||||||
});
|
});
|
||||||
|
|
||||||
Response.Redirect("Products");
|
Response.Redirect("ProductList");
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult AddCooksToProduct()
|
public IActionResult ProductAddCooks()
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Products = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
||||||
ViewBag.Cooks = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void AddCooksToProduct(int selectedProduct, int selectedCook)
|
public void ProductAddCooks(int selectedProduct, int selectedCook)
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
@ -239,64 +256,85 @@ namespace CanteenManagerApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Должен быть выбран повар");
|
throw new Exception("Должен быть выбран повар");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/addcookstoproduct", Tuple.Create
|
APIClient.PostRequest("api/main/ProductAddCooks", Tuple.Create
|
||||||
(
|
(
|
||||||
new ProductSearchModel { Id = selectedProduct },
|
new ProductSearchModel { Id = selectedProduct },
|
||||||
new CookViewModel { Id = selectedCook }
|
new CookViewModel { Id = selectedCook }
|
||||||
));
|
));
|
||||||
|
|
||||||
Response.Redirect("Products");
|
Response.Redirect("ProductList");
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult DeleteProduct(int productId)
|
public IActionResult ProductDelete()
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/deleteproduct", new ProductBindingModel { Id = productId });
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
||||||
return Redirect("~/Home/Products");
|
return Redirect("~/Home/ProductList");
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult UpdateProduct()
|
|
||||||
{
|
|
||||||
if (APIClient.Manager == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
return View();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateProduct(string productName, double price)
|
public void ProductDelete(int id)
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Доступ возможен только авторизованным пользователям");
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/updateproduct", new ProductBindingModel
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
Id = APIClient.Manager.Id,
|
throw new Exception("Выберите продукт");
|
||||||
ProductName = productName,
|
}
|
||||||
Price = price
|
APIClient.PostRequest("api/main/ProductDelete", new ProductBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
});
|
});
|
||||||
Response.Redirect("Products");
|
|
||||||
|
Response.Redirect("ProductList");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Dishes()
|
public IActionResult ProductUpdate()
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Dishes = 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 ProductUpdate(int Id, string name, double price)
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/main/productupdate", new ProductBindingModel
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ProductName = name,
|
||||||
|
Price = price,
|
||||||
|
ManagerId = APIClient.Manager.Id
|
||||||
|
});
|
||||||
|
Response.Redirect("ProductList");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DishList()
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.DishList = APIClient.GetRequest<List<DishViewModel>>($"api/main/GetDishList?managerId={APIClient.Manager.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateDish()
|
public IActionResult DishCreate()
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
@ -306,63 +344,123 @@ namespace CanteenManagerApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateDish(string dishName, double price)
|
public void DishCreate(string name)
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Доступ возможен только авторизованным пользователям");
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(dishName))
|
if (string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
throw new Exception("Наименование блюда не должно быть пустым");
|
throw new Exception("Наименование блюда не должно быть пустым");
|
||||||
}
|
}
|
||||||
|
|
||||||
APIClient.PostRequest("api/main/createdish", new DishBindingModel
|
APIClient.PostRequest("api/main/dishcreate", new DishBindingModel
|
||||||
{
|
{
|
||||||
ManagerId = APIClient.Manager.Id,
|
ManagerId = APIClient.Manager.Id,
|
||||||
DishName = dishName,
|
DishName = name
|
||||||
Price = price
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Response.Redirect("Dishes");
|
Response.Redirect("DishList");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult DeleteDish(int dishId)
|
public IActionResult DishAddProducts()
|
||||||
{
|
|
||||||
if (APIClient.Manager == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
APIClient.PostRequest("api/main/deletedish", new DishBindingModel { Id = dishId });
|
|
||||||
return Redirect("~/Home/Dishes");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult UpdateDish()
|
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
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();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateDish(string dishName, double price)
|
public void DishAddProducts(int selectedDish, int selectedProduct, int count)
|
||||||
{
|
{
|
||||||
if (APIClient.Manager == null)
|
if (APIClient.Manager == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Доступ возможен только авторизованным пользователям");
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/updatedish", new DishBindingModel
|
|
||||||
|
if (selectedDish <= 0)
|
||||||
{
|
{
|
||||||
Id = APIClient.Manager.Id,
|
throw new Exception("Должно быть выбрано блюдо");
|
||||||
DishName = dishName,
|
}
|
||||||
Price = price
|
if (selectedProduct <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должен быть выбран продукт");
|
||||||
|
}
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Количество продукта должно быть больше 0");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/main/dishaddproducts", Tuple.Create
|
||||||
|
(
|
||||||
|
new DishSearchModel { Id = selectedDish },
|
||||||
|
new ProductViewModel { Id = selectedProduct },
|
||||||
|
count
|
||||||
|
));
|
||||||
|
|
||||||
|
Response.Redirect("DishList");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DishDelete()
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.DishList = APIClient.GetRequest<List<DishViewModel>>($"api/main/getdishlist?managerId={APIClient.Manager.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[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
|
||||||
});
|
});
|
||||||
Response.Redirect("Dishes");
|
|
||||||
|
Response.Redirect("ProductList");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DishUpdate()
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.DishList = APIClient.GetRequest<List<DishViewModel>>($"api/main/getdishlist?managerId={APIClient.Manager.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void DishUpdate(int Id, string name, double price)
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/main/DishUpdate", new DishBindingModel
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
DishName = name,
|
||||||
|
Price = price,
|
||||||
|
ManagerId = APIClient.Manager.Id
|
||||||
|
});
|
||||||
|
Response.Redirect("DishList");
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Graphic()
|
public IActionResult Graphic()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Cook";
|
ViewData["Title"] = "CookList";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Добавление повара</h2>
|
<h2 class="display-4">Добавление повара</h2>
|
@ -13,7 +13,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Выберите повара</div>
|
<div class="col-4">Выберите повара</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select id="cook" name="cook" class="form-control" asp-items="@(new SelectList(@ViewBag.Cooks, "Id"))"></select>
|
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.CookList, "Id", "FIO"))"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
30
Canteen/CanteenManagerApp/Views/Home/CookList.cshtml
Normal file
30
Canteen/CanteenManagerApp/Views/Home/CookList.cshtml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "CookList";
|
||||||
|
}
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h2>Список поваров</h2>
|
||||||
|
<a type="button" class="btn btn-success" href="/Home/CookCreate">Добавить повара</a>
|
||||||
|
<a type="button" class="btn btn-danger" href="/Home/CookDelete">Удалить повара</a>
|
||||||
|
<a type="button" class="btn btn-warning" href="/Home/CookUpdate">Обновить повара</a>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Номер</th>
|
||||||
|
<th>ФИО</th>
|
||||||
|
<th>Должность</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var cook in ViewBag.CookList)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@cook.Id</td>
|
||||||
|
<td>@cook.FIO</td>
|
||||||
|
<td>@cook.Position</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace CanteenManagerApp.Views.Home
|
namespace CanteenManagerApp.Views.Home.Cook
|
||||||
{
|
{
|
||||||
public class CooksModel : PageModel
|
public class CooksModel : PageModel
|
||||||
{
|
{
|
44
Canteen/CanteenManagerApp/Views/Home/CookUpdate.cshtml
Normal file
44
Canteen/CanteenManagerApp/Views/Home/CookUpdate.cshtml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
@using Newtonsoft.Json;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "CookUpdate";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Данные повара</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Повар:</div>
|
||||||
|
<div class="col-8"><select id="Id" name="Id" class="form-control" onchange="populateFields()" asp-items="@(new SelectList(@ViewBag.CookList, "Id", "FIO"))"></select></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">ФИО:</div>
|
||||||
|
<div class="col-8"><input type="text" name="FIO" value="" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Должность:</div>
|
||||||
|
<div class="col-8"><input type="text" name="position" value="" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
const cooks = [];
|
||||||
|
|
||||||
|
function populateFields() {
|
||||||
|
ViewBag.CookList.forEach(value => {
|
||||||
|
cooks.push(value);
|
||||||
|
});
|
||||||
|
var selectedCookId = document.getElementById("Id").value;
|
||||||
|
var selectedCook = cooks.find(function (cook) {
|
||||||
|
return cook.Id === selectedCookId;
|
||||||
|
});
|
||||||
|
//console.log(selectedCook.FIO);
|
||||||
|
if (selectedCook) {
|
||||||
|
document.getElementsByName("FIO")[0].value = selectedCook.FIO;
|
||||||
|
document.getElementsByName("position")[0].value = selectedCook.Position;
|
||||||
|
}
|
||||||
|
console.log(document.getElementsByName("FIO")[0].value);
|
||||||
|
}
|
||||||
|
</script>
|
@ -1,59 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Cooks";
|
|
||||||
}
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<h2>Список поваров</h2>
|
|
||||||
<a type="button" class="btn btn-success" href="/Home/CreateCook">Добавить повара</a>
|
|
||||||
<button type="submit" class="btn btn-danger" form="selectCookForm">Удалить повара</button>
|
|
||||||
<a type="button" class="btn btn-warning" href="/Home/UpdateCook">Обновить повара</a>
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Номер</th>
|
|
||||||
<th>ФИО</th>
|
|
||||||
<th>Должность</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var cook in ViewBag.Cooks)
|
|
||||||
{
|
|
||||||
<tr onclick="selectCook(this)">
|
|
||||||
<td>@cook.Id</td>
|
|
||||||
<td>@cook.FIO</td>
|
|
||||||
<td>@cook.Position</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
<form id="selectCookForm" method="post" action="/Home/DeleteCook">
|
|
||||||
<input type="hidden" id="CookId" name="CookId" value="" />
|
|
||||||
</form>
|
|
||||||
<style>
|
|
||||||
.selected-row {
|
|
||||||
background-color: lightgray;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
function selectCook(row) {
|
|
||||||
var CookId = document.getElementById("CookId");
|
|
||||||
var previousValue = CookId.value;
|
|
||||||
var currentValue = row.cells[0].innerText;
|
|
||||||
|
|
||||||
if (previousValue === currentValue) {
|
|
||||||
CookId.value = "";
|
|
||||||
row.classList.remove("selected-row");
|
|
||||||
} else {
|
|
||||||
CookId.value = currentValue;
|
|
||||||
|
|
||||||
var rows = document.getElementsByTagName("tr");
|
|
||||||
for (var i = 0; i < rows.length; i++) {
|
|
||||||
rows[i].classList.remove("selected-row");
|
|
||||||
}
|
|
||||||
|
|
||||||
row.classList.add("selected-row");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
25
Canteen/CanteenManagerApp/Views/Home/DIshDelete.cshtml
Normal file
25
Canteen/CanteenManagerApp/Views/Home/DIshDelete.cshtml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "DishDelete";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление блюда</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Выберите блюдо</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.DishList, "Id", "DishName"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Удалить" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
48
Canteen/CanteenManagerApp/Views/Home/DishAddProducts.cshtml
Normal file
48
Canteen/CanteenManagerApp/Views/Home/DishAddProducts.cshtml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
@using CanteenContracts.View;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "DishAddProducts";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Привязка продукта к блюду</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Блюдо:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="selectedDish" name="selectedDish">
|
||||||
|
@foreach (var dish in ViewBag.DishList as List<DishViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@dish.Id">@dish.DishName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Продукт:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="selectedProduct">
|
||||||
|
@foreach (var product in ViewBag.ProductList as List<ProductViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@product.Id">@product.ProductName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Количество:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="text" name="count" id="count" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Добавить" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Dish";
|
ViewData["Title"] = "DishCreate";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Добавление блюда</h2>
|
<h2 class="display-4">Добавление блюда</h2>
|
||||||
@ -14,14 +14,7 @@
|
|||||||
<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="FIO" id="FIO" />
|
<input type="text" name="name" id="name" />
|
||||||
@* <select id="bouquet" name="bouquet" class="form-control" asp-items="@(new SelectList(@ViewBag.Bouquets, "Id", "BouquetName"))"></select>*@
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Цена:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<input type="text" name="position" id="position" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
31
Canteen/CanteenManagerApp/Views/Home/DishList.cshtml
Normal file
31
Canteen/CanteenManagerApp/Views/Home/DishList.cshtml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "DishList";
|
||||||
|
}
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h2>Список список продуктов</h2>
|
||||||
|
<a type="button" class="btn btn-success" href="/Home/DishCreate">Добавить блюдо</a>
|
||||||
|
<a type="button" class="btn btn-danger" href="/Home/DishDelete">Удалить блюдо</a>
|
||||||
|
<a type="button" class="btn btn-warning" href="/Home/DishUpdate">Обновить блюдо</a>
|
||||||
|
<a type="button" class="btn btn-warning" href="/Home/DishAddProducts">Привязать продукт</a>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Номер</th>
|
||||||
|
<th>Название</th>
|
||||||
|
<th>Цена</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var cook in ViewBag.DishList)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@cook.Id</td>
|
||||||
|
<td>@cook.DishName</td>
|
||||||
|
<td>@cook.Price</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
38
Canteen/CanteenManagerApp/Views/Home/DishUpdate.cshtml
Normal file
38
Canteen/CanteenManagerApp/Views/Home/DishUpdate.cshtml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "DishUpdate";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Данные блюда</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Блюдо:</div>
|
||||||
|
<div class="col-8"><select id="Id" name="Id" class="form-control" onchange="populateFields()" asp-items="@(new SelectList(@ViewBag.DishList, "Id", "DishName"))"></select></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Название:</div>
|
||||||
|
<div class="col-8"><input type="text" name="name" value="" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Цена:</div>
|
||||||
|
<div class="col-8"><input type="text" name="price" value="" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
function populateFields() {
|
||||||
|
var selectedDishId = document.getElementById("dish").value;
|
||||||
|
var dishes = @Json.Serialize(ViewBag.CookList);
|
||||||
|
var selectedDish = dishes.find(function (dish) {
|
||||||
|
return dish.Id === selectedDishId;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selectedDish) {
|
||||||
|
document.getElementsByName("name")[0].value = selectedDish.DishName;
|
||||||
|
document.getElementsByName("price")[0].value = selectedDish.Price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -1,59 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Products";
|
|
||||||
}
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<h2>Список список продуктов</h2>
|
|
||||||
<a type="button" class="btn btn-success" href="/Home/CreateCook">Добавить продукт</a>
|
|
||||||
<button type="submit" class="btn btn-danger" form="selectCookForm">Удалить продукт</button>
|
|
||||||
<a type="button" class="btn btn-warning" href="/Home/UpdateCook">Обновить продукт</a>
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Номер</th>
|
|
||||||
<th>Название</th>
|
|
||||||
<th>Цена</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var cook in ViewBag.Cooks)
|
|
||||||
{
|
|
||||||
<tr onclick="selectCook(this)">
|
|
||||||
<td>@cook.Id</td>
|
|
||||||
<td>@cook.Name</td>
|
|
||||||
<td>@cook.Price</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
<form id="selectCookForm" method="post" action="/Home/DeleteCook">
|
|
||||||
<input type="hidden" id="ProductId" name="ProductId" value="" />
|
|
||||||
</form>
|
|
||||||
<style>
|
|
||||||
.selected-row {
|
|
||||||
background-color: lightgray;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
function selectCook(row) {
|
|
||||||
var ProductId = document.getElementById("ProductId");
|
|
||||||
var previousValue = ProductId.value;
|
|
||||||
var currentValue = row.cells[0].innerText;
|
|
||||||
|
|
||||||
if (previousValue === currentValue) {
|
|
||||||
ProductId.value = "";
|
|
||||||
row.classList.remove("selected-row");
|
|
||||||
} else {
|
|
||||||
ProductId.value = currentValue;
|
|
||||||
|
|
||||||
var rows = document.getElementsByTagName("tr");
|
|
||||||
for (var i = 0; i < rows.length; i++) {
|
|
||||||
rows[i].classList.remove("selected-row");
|
|
||||||
}
|
|
||||||
|
|
||||||
row.classList.add("selected-row");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,6 +1,6 @@
|
|||||||
@using CanteenContracts.View;
|
@using CanteenContracts.View;
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "AddCooksToProduct";
|
ViewData["Title"] = "ProductAddCooks";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Привязка повара к продукту</h2>
|
<h2 class="display-4">Привязка повара к продукту</h2>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<div class="col-4">Продукты:</div>
|
<div class="col-4">Продукты:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select name="selectedProduct">
|
<select name="selectedProduct">
|
||||||
@foreach (var product in ViewBag.Products as List<ProductViewModel>)
|
@foreach (var product in ViewBag.ProductList as List<ProductViewModel>)
|
||||||
{
|
{
|
||||||
<option value="@product.Id">@product.ProductName</option>
|
<option value="@product.Id">@product.ProductName</option>
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<div class="col-4">Повар:</div>
|
<div class="col-4">Повар:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select name="selectedCook">
|
<select name="selectedCook">
|
||||||
@foreach (var cook in ViewBag.Cooks as List<CookViewModel>)
|
@foreach (var cook in ViewBag.CookList as List<CookViewModel>)
|
||||||
{
|
{
|
||||||
<option value="@cook.Id">@cook.FIO</option>
|
<option value="@cook.Id">@cook.FIO</option>
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
@using CanteenContracts.View;
|
@using CanteenContracts.View;
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Product";
|
ViewData["Title"] = "ProductCreate";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Добавление продукта</h2>
|
<h2 class="display-4">Добавление продукта</h2>
|
||||||
@ -20,18 +20,7 @@
|
|||||||
<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="price" id="price" />
|
<input type="number" name="price" id="price" />
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Цена:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<select name="selectedCooks" multiple>
|
|
||||||
@foreach (var cook in ViewBag.Cooks as List<CookViewModel>)
|
|
||||||
{
|
|
||||||
<option value="@cook.Id">@cook.FIO</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
25
Canteen/CanteenManagerApp/Views/Home/ProductDelete.cshtml
Normal file
25
Canteen/CanteenManagerApp/Views/Home/ProductDelete.cshtml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "ProductDelete";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление продукта</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Выберите продукт</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.ProductList, "Id", "ProductName"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Удалить" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
32
Canteen/CanteenManagerApp/Views/Home/ProductList.cshtml
Normal file
32
Canteen/CanteenManagerApp/Views/Home/ProductList.cshtml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
@using CanteenContracts.View;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "ProductList";
|
||||||
|
}
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h2>Список продуктов</h2>
|
||||||
|
<a type="button" class="btn btn-success" href="/Home/ProductCreate">Добавить продукт</a>
|
||||||
|
<a type="button" class="btn btn-danger" href="/Home/ProductDelete">Удалить продукт</a>
|
||||||
|
<a type="button" class="btn btn-warning" href="/Home/ProductUpdate">Обновить продукт</a>
|
||||||
|
<a type="button" class="btn btn-warning" href="/Home/ProductAddCooks">Привязать повара</a>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Номер</th>
|
||||||
|
<th>Название</th>
|
||||||
|
<th>Цена</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var product in ViewBag.ProductList)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@product.Id</td>
|
||||||
|
<td>@product.ProductName</td>
|
||||||
|
<td>@product.Price</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
38
Canteen/CanteenManagerApp/Views/Home/ProductUpdate.cshtml
Normal file
38
Canteen/CanteenManagerApp/Views/Home/ProductUpdate.cshtml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "ProductUpdate";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Данные продукта</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Повар:</div>
|
||||||
|
<div class="col-8"><select id="Id" name="Id" class="form-control" onchange="populateFields()" asp-items="@(new SelectList(@ViewBag.ProductList, "Id", "ProductName"))"></select></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">ФИО:</div>
|
||||||
|
<div class="col-8"><input type="text" name="name" value="" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Цена:</div>
|
||||||
|
<div class="col-8"><input type="text" name="price" value="" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
function populateFields() {
|
||||||
|
var selectedCookId = document.getElementById("product").value;
|
||||||
|
var cooks = @Json.Serialize(ViewBag.CookList);
|
||||||
|
var selectedCook = cooks.find(function (cook) {
|
||||||
|
return cook.Id === selectedCookId;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selectedCook) {
|
||||||
|
document.getElementsByName("name")[0].value = selectedCook.ProductName;
|
||||||
|
document.getElementsByName("price")[0].value = selectedCook.Price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -1,61 +0,0 @@
|
|||||||
@using CanteenContracts.View;
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Products";
|
|
||||||
}
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<h2>Список продуктов</h2>
|
|
||||||
<a type="button" class="btn btn-success" href="/Home/CreateProduct">Добавить продукт</a>
|
|
||||||
<button type="submit" class="btn btn-danger" form="selectProductForm">Удалить продукт</button>
|
|
||||||
<a type="button" class="btn btn-warning" href="/Home/UpdateProduct">Обновить продукт</a>
|
|
||||||
<a type="button" class="btn btn-warning" href="/Home/AddCooksToProduct">Привязать повара</a>
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Номер</th>
|
|
||||||
<th>Название</th>
|
|
||||||
<th>Цена</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var product in ViewBag.Products)
|
|
||||||
{
|
|
||||||
<tr onclick="selectProduct(this)">
|
|
||||||
<td>@product.Id</td>
|
|
||||||
<td>@product.ProductName</td>
|
|
||||||
<td>@product.Price</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
<form id="selectProductForm" method="post" action="/Home/DeleteProduct">
|
|
||||||
<input type="hidden" id="ProductId" name="ProductId" value="" />
|
|
||||||
</form>
|
|
||||||
<style>
|
|
||||||
.selected-row {
|
|
||||||
background-color: lightgray;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
function selectProduct(row) {
|
|
||||||
var productIdInput = document.getElementById("ProductId");
|
|
||||||
var previousValue = productIdInput.value;
|
|
||||||
var currentValue = row.cells[0].innerText;
|
|
||||||
|
|
||||||
if (previousValue === currentValue) {
|
|
||||||
productIdInput.value = "";
|
|
||||||
row.classList.remove("selected-row");
|
|
||||||
} else {
|
|
||||||
productIdInput.value = currentValue;
|
|
||||||
|
|
||||||
var rows = document.getElementsByTagName("tr");
|
|
||||||
for (var i = 0; i < rows.length; i++) {
|
|
||||||
rows[i].classList.remove("selected-row");
|
|
||||||
}
|
|
||||||
|
|
||||||
row.classList.add("selected-row");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,5 +0,0 @@
|
|||||||
@*
|
|
||||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
||||||
*@
|
|
||||||
@{
|
|
||||||
}
|
|
@ -20,13 +20,13 @@
|
|||||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
<ul class="navbar-nav flex-grow-1">
|
<ul class="navbar-nav flex-grow-1">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Cooks">Повара</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CookList">Повара</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Products">Продукты</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ProductList">Продукты</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Dishes">Блюда</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="DishList">Блюда</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Войти</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Войти</a>
|
||||||
|
@ -29,33 +29,7 @@ namespace CanteenRestApi.Controllers
|
|||||||
_tableware = tableware;
|
_tableware = tableware;
|
||||||
_gl = gl;
|
_gl = gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public List<CookViewModel>? GetCookList(int managerId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _cook.ReadList(new CookSearchModel { ManagerId = managerId});
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error during loading list of bouquets");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public List<ProductViewModel>? GetProductList(int managerId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _product.ReadList(new ProductSearchModel { ManagerId = managerId });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error during loading list of bouquets");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<TablewareViewModel>? GetTablewareList()
|
public List<TablewareViewModel>? GetTablewareList()
|
||||||
{
|
{
|
||||||
@ -69,6 +43,7 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateTableware(TablewareBindingModel model)
|
public void CreateTableware(TablewareBindingModel model)
|
||||||
{
|
{
|
||||||
@ -82,8 +57,23 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<CookViewModel>? GetCookList(int managerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _cook.ReadList(new CookSearchModel { ManagerId = managerId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateCook(CookBindingModel model)
|
public void CookCreate(CookBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -97,7 +87,7 @@ namespace CanteenRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void DeleteCook(CookBindingModel model)
|
public void CookDelete(CookBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -111,7 +101,35 @@ namespace CanteenRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateDish(DishBindingModel model)
|
public void CookUpdate(CookBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_cook.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<DishViewModel>? GetDishList(int managerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _dish.ReadList(new DishSearchModel { ManagerId = managerId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void DishCreate(DishBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -124,7 +142,62 @@ namespace CanteenRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateProduct(ProductBindingModel model)
|
public void DishDelete(DishBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_dish.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void DishUpdate(DishBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_dish.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void DishAddProducts(Tuple<DishSearchModel, ProductViewModel, int> model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_dish.AddCooksToProduct(model.Item1, model.Item2, model.Item3);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<ProductViewModel>? GetProductList(int managerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _product.ReadList(new ProductSearchModel { ManagerId = managerId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void ProductCreate(ProductBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -136,9 +209,36 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void ProductDelete(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_product.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void AddCooksToProduct(Tuple<ProductSearchModel, CookViewModel> model)
|
public void ProductUpdate(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_product.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void ProductAddCooks(Tuple<ProductSearchModel, CookViewModel> model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -150,6 +250,7 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public GraphicViewModel[] GetGraphic()
|
public GraphicViewModel[] GetGraphic()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -67,8 +67,7 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
APIClient.PostRequest("api/main/CreateTableware", new TablewareBindingModel
|
APIClient.PostRequest("api/main/CreateTableware", new TablewareBindingModel
|
||||||
{
|
{
|
||||||
VisitorId = 1,
|
VisitorId = 1,
|
||||||
TablewareName = TablewareName,
|
TablewareName = TablewareName
|
||||||
Count = TablewareCount
|
|
||||||
});
|
});
|
||||||
Response.Redirect("Tablewares");
|
Response.Redirect("Tablewares");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user