From 67d4a78a39adaa023c173b8794a4cb680a3a2a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D0=B0=20=D0=A1=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=B2?= Date: Sun, 19 Nov 2023 20:57:55 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FoodOrdersDataBase.cs | 2 +- .../Implements/ClientStorage.cs | 4 +- ...0231119073616_InitialCreature.Designer.cs} | 47 ++++++++++++++++++- ...n.cs => 20231119073616_InitialCreature.cs} | 33 ++++++++++++- .../FoodOrdersDataBaseModelSnapshot.cs | 43 +++++++++++++++++ .../Models/Client.cs | 8 ++-- .../Models/Order.cs | 11 +++-- .../Implements/ClientStorage.cs | 4 +- .../FoodOrderFileImplement/Models/Client.cs | 12 ++--- .../BusinessLogic/ClientLogic.cs | 6 +-- .../Controllers/HomeController.cs | 38 ++++++++++----- FoodOrders/FoodOrdersClientApp/Program.cs | 3 ++ .../Views/Home/Privacy.cshtml | 2 +- .../BindingModels/ClientBindingModel.cs | 2 +- .../ViewModels/ClientViewModel.cs | 2 +- .../Models/IClientModel.cs | 2 +- .../Implements/ClientStorage.cs | 4 +- .../FoodOrdersListImplement/Models/Client.cs | 8 ++-- .../Controllers/MainController.cs | 18 +++---- 19 files changed, 192 insertions(+), 57 deletions(-) rename FoodOrders/FoodOrderDatabaseImplement/Migrations/{20230416163421_InitMigration.Designer.cs => 20231119073616_InitialCreature.Designer.cs} (79%) rename FoodOrders/FoodOrderDatabaseImplement/Migrations/{20230416163421_InitMigration.cs => 20231119073616_InitialCreature.cs} (79%) diff --git a/FoodOrders/FoodOrderDatabaseImplement/FoodOrdersDataBase.cs b/FoodOrders/FoodOrderDatabaseImplement/FoodOrdersDataBase.cs index 9799a89..6f548de 100644 --- a/FoodOrders/FoodOrderDatabaseImplement/FoodOrdersDataBase.cs +++ b/FoodOrders/FoodOrderDatabaseImplement/FoodOrdersDataBase.cs @@ -10,7 +10,7 @@ namespace FoodOrdersDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=FoodOrdersDatabaseFull_2;Username=postgres;Password=12345"); + optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=FoodOrdersDatabaseFull_2;Username=postgres;Password=user"); } base.OnConfiguring(optionsBuilder); } diff --git a/FoodOrders/FoodOrderDatabaseImplement/Implements/ClientStorage.cs b/FoodOrders/FoodOrderDatabaseImplement/Implements/ClientStorage.cs index 195629e..79d5180 100644 --- a/FoodOrders/FoodOrderDatabaseImplement/Implements/ClientStorage.cs +++ b/FoodOrders/FoodOrderDatabaseImplement/Implements/ClientStorage.cs @@ -34,7 +34,7 @@ namespace FoodOrderDatabaseImplement.Implements using var context = new FoodOrdersDataBase(); return context.Clients .Include(x => x.Orders) - .Where(x => x.Email.Contains(model.Email)) + .Where(x => x.Login.Contains(model.Email)) .Select(x => x.GetViewModel) .ToList(); } @@ -51,7 +51,7 @@ namespace FoodOrderDatabaseImplement.Implements else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password)) { return context.Clients - .FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))?.GetViewModel; + .FirstOrDefault(x => (x.Login == model.Email && x.Password == model.Password))?.GetViewModel; } return new(); } diff --git a/FoodOrders/FoodOrderDatabaseImplement/Migrations/20230416163421_InitMigration.Designer.cs b/FoodOrders/FoodOrderDatabaseImplement/Migrations/20231119073616_InitialCreature.Designer.cs similarity index 79% rename from FoodOrders/FoodOrderDatabaseImplement/Migrations/20230416163421_InitMigration.Designer.cs rename to FoodOrders/FoodOrderDatabaseImplement/Migrations/20231119073616_InitialCreature.Designer.cs index d54cdbd..265a14c 100644 --- a/FoodOrders/FoodOrderDatabaseImplement/Migrations/20230416163421_InitMigration.Designer.cs +++ b/FoodOrders/FoodOrderDatabaseImplement/Migrations/20231119073616_InitialCreature.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FoodOrderDatabaseImplement.Migrations { [DbContext(typeof(FoodOrdersDataBase))] - [Migration("20230416163421_InitMigration")] - partial class InitMigration + [Migration("20231119073616_InitialCreature")] + partial class InitialCreature { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -25,6 +25,31 @@ namespace FoodOrderDatabaseImplement.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("FoodOrderDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b => { b.Property("Id") @@ -99,6 +124,9 @@ namespace FoodOrderDatabaseImplement.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("ClientId") + .HasColumnType("integer"); + b.Property("Count") .HasColumnType("integer"); @@ -123,6 +151,8 @@ namespace FoodOrderDatabaseImplement.Migrations b.HasKey("Id"); + b.HasIndex("ClientId"); + b.HasIndex("FoodId"); b.ToTable("Orders"); @@ -149,15 +179,28 @@ namespace FoodOrderDatabaseImplement.Migrations modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b => { + b.HasOne("FoodOrderDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("FoodOrdersDatabaseImplement.Models.Food", "Food") .WithMany("Orders") .HasForeignKey("FoodId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Client"); + b.Navigation("Food"); }); + modelBuilder.Entity("FoodOrderDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b => { b.Navigation("FoodComponents"); diff --git a/FoodOrders/FoodOrderDatabaseImplement/Migrations/20230416163421_InitMigration.cs b/FoodOrders/FoodOrderDatabaseImplement/Migrations/20231119073616_InitialCreature.cs similarity index 79% rename from FoodOrders/FoodOrderDatabaseImplement/Migrations/20230416163421_InitMigration.cs rename to FoodOrders/FoodOrderDatabaseImplement/Migrations/20231119073616_InitialCreature.cs index 83f2af6..a3df06e 100644 --- a/FoodOrders/FoodOrderDatabaseImplement/Migrations/20230416163421_InitMigration.cs +++ b/FoodOrders/FoodOrderDatabaseImplement/Migrations/20231119073616_InitialCreature.cs @@ -7,12 +7,26 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FoodOrderDatabaseImplement.Migrations { /// - public partial class InitMigration : Migration + public partial class InitialCreature : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ClientFIO = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Components", columns: table => new @@ -76,6 +90,7 @@ namespace FoodOrderDatabaseImplement.Migrations .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FoodId = table.Column(type: "integer", nullable: false), FoodName = table.Column(type: "text", nullable: false), + ClientId = table.Column(type: "integer", nullable: false), Count = table.Column(type: "integer", nullable: false), Sum = table.Column(type: "double precision", nullable: false), Status = table.Column(type: "integer", nullable: false), @@ -85,6 +100,12 @@ namespace FoodOrderDatabaseImplement.Migrations constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Orders_Foods_FoodId", column: x => x.FoodId, @@ -103,6 +124,11 @@ namespace FoodOrderDatabaseImplement.Migrations table: "FoodComponents", column: "FoodId"); + migrationBuilder.CreateIndex( + name: "IX_Orders_ClientId", + table: "Orders", + column: "ClientId"); + migrationBuilder.CreateIndex( name: "IX_Orders_FoodId", table: "Orders", @@ -121,6 +147,9 @@ namespace FoodOrderDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Components"); + migrationBuilder.DropTable( + name: "Clients"); + migrationBuilder.DropTable( name: "Foods"); } diff --git a/FoodOrders/FoodOrderDatabaseImplement/Migrations/FoodOrdersDataBaseModelSnapshot.cs b/FoodOrders/FoodOrderDatabaseImplement/Migrations/FoodOrdersDataBaseModelSnapshot.cs index b6b35c8..1b7ef9d 100644 --- a/FoodOrders/FoodOrderDatabaseImplement/Migrations/FoodOrdersDataBaseModelSnapshot.cs +++ b/FoodOrders/FoodOrderDatabaseImplement/Migrations/FoodOrdersDataBaseModelSnapshot.cs @@ -22,6 +22,31 @@ namespace FoodOrderDatabaseImplement.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("FoodOrderDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b => { b.Property("Id") @@ -96,6 +121,9 @@ namespace FoodOrderDatabaseImplement.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("ClientId") + .HasColumnType("integer"); + b.Property("Count") .HasColumnType("integer"); @@ -120,6 +148,8 @@ namespace FoodOrderDatabaseImplement.Migrations b.HasKey("Id"); + b.HasIndex("ClientId"); + b.HasIndex("FoodId"); b.ToTable("Orders"); @@ -146,15 +176,28 @@ namespace FoodOrderDatabaseImplement.Migrations modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b => { + b.HasOne("FoodOrderDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("FoodOrdersDatabaseImplement.Models.Food", "Food") .WithMany("Orders") .HasForeignKey("FoodId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Client"); + b.Navigation("Food"); }); + modelBuilder.Entity("FoodOrderDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b => { b.Navigation("FoodComponents"); diff --git a/FoodOrders/FoodOrderDatabaseImplement/Models/Client.cs b/FoodOrders/FoodOrderDatabaseImplement/Models/Client.cs index 72fc23a..f7cb9e7 100644 --- a/FoodOrders/FoodOrderDatabaseImplement/Models/Client.cs +++ b/FoodOrders/FoodOrderDatabaseImplement/Models/Client.cs @@ -13,7 +13,7 @@ namespace FoodOrderDatabaseImplement.Models [Required] public string ClientFIO { get; set; } = string.Empty; [Required] - public string Email { get; set; } = string.Empty; + public string Login { get; set; } = string.Empty; [Required] public string Password { get; set; } = string.Empty; [ForeignKey("ClientId")] @@ -28,7 +28,7 @@ namespace FoodOrderDatabaseImplement.Models { Id = model.Id, ClientFIO = model.ClientFIO, - Email = model.Email, + Login = model.Login, Password = model.Password }; } @@ -39,14 +39,14 @@ namespace FoodOrderDatabaseImplement.Models return; } ClientFIO = model.ClientFIO; - Email = model.Email; + Login = model.Login; Password = model.Password; } public ClientViewModel GetViewModel => new() { Id = Id, ClientFIO = ClientFIO, - Email = Email, + Login = Login, Password = Password }; } diff --git a/FoodOrders/FoodOrderDatabaseImplement/Models/Order.cs b/FoodOrders/FoodOrderDatabaseImplement/Models/Order.cs index 1ad884f..820f629 100644 --- a/FoodOrders/FoodOrderDatabaseImplement/Models/Order.cs +++ b/FoodOrders/FoodOrderDatabaseImplement/Models/Order.cs @@ -10,12 +10,13 @@ namespace FoodOrdersDatabaseImplement.Models public class Order : IOrderModel { public int Id { get; private set; } - - public int FoodId { get; private set; } - + [Required] + public int FoodId { get; private set; } public string FoodName { get; private set; } = string.Empty; [Required] public int ClientId { get; private set; } + + [Required] public int Count { get; private set; } @@ -30,8 +31,8 @@ namespace FoodOrdersDatabaseImplement.Models public DateTime? DateImplement { get; private set; } - public virtual Food Food { get; set; } - public virtual Client Client { get; set; } + public virtual Food Food { get; private set; } + public virtual Client Client { get; private set; } public static Order? Create(OrderBindingModel? model) { diff --git a/FoodOrders/FoodOrderFileImplement/Implements/ClientStorage.cs b/FoodOrders/FoodOrderFileImplement/Implements/ClientStorage.cs index 0bc3d5d..aa96124 100644 --- a/FoodOrders/FoodOrderFileImplement/Implements/ClientStorage.cs +++ b/FoodOrders/FoodOrderFileImplement/Implements/ClientStorage.cs @@ -29,7 +29,7 @@ namespace FoodOrderFileImplement.Implements if (!string.IsNullOrEmpty(model.Email)) { return source.Clients - .Where(x => x.Email.Contains(model.Email)) + .Where(x => x.Login.Contains(model.Email)) .Select(x => x.GetViewModel) .ToList(); } @@ -45,7 +45,7 @@ namespace FoodOrderFileImplement.Implements else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password)) { return source.Clients - .FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))?.GetViewModel; + .FirstOrDefault(x => (x.Login == model.Email && x.Password == model.Password))?.GetViewModel; } return new(); } diff --git a/FoodOrders/FoodOrderFileImplement/Models/Client.cs b/FoodOrders/FoodOrderFileImplement/Models/Client.cs index 4ad3d1f..b5ac6d7 100644 --- a/FoodOrders/FoodOrderFileImplement/Models/Client.cs +++ b/FoodOrders/FoodOrderFileImplement/Models/Client.cs @@ -14,7 +14,7 @@ namespace FoodOrderFileImplement.Models { public int Id { get; private set; } public string ClientFIO { get; private set; } = string.Empty; - public string Email { get; private set; } = string.Empty; + public string Login { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty; public static Client? Create(ClientBindingModel? model) { @@ -26,7 +26,7 @@ namespace FoodOrderFileImplement.Models { Id = model.Id, ClientFIO = model.ClientFIO, - Email = model.Email, + Login = model.Login, Password = model.Password, }; } @@ -40,7 +40,7 @@ namespace FoodOrderFileImplement.Models { Id = Convert.ToInt32(element.Attribute("Id")!.Value), ClientFIO = element.Element("ClientFIO")!.Value, - Email = element.Element("Email")!.Value, + Login = element.Element("Email")!.Value, Password = element.Element("Password")!.Value }; } @@ -51,20 +51,20 @@ namespace FoodOrderFileImplement.Models return; } ClientFIO = model.ClientFIO; - Email = model.Email; + Login = model.Login; Password = model.Password; } public ClientViewModel GetViewModel => new() { Id = Id, ClientFIO = ClientFIO, - Email = Email, + Login = Login, Password = Password }; public XElement GetXElement => new("Client", new XAttribute("Id", Id), new XElement("ClientFIO", ClientFIO), - new XElement("Email", Email), + new XElement("Email", Login), new XElement("Password", Password)); } } diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogic/ClientLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogic/ClientLogic.cs index a997f24..3d65946 100644 --- a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogic/ClientLogic.cs +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogic/ClientLogic.cs @@ -89,7 +89,7 @@ namespace FoodOrderBusinessLogic.BusinessLogic { throw new ArgumentNullException("Нет имени клиента", nameof(model.ClientFIO)); } - if (string.IsNullOrEmpty(model.Email)) + if (string.IsNullOrEmpty(model.Login)) { throw new ArgumentNullException("Нет логина клиента", nameof(model.ClientFIO)); } @@ -97,10 +97,10 @@ namespace FoodOrderBusinessLogic.BusinessLogic { throw new ArgumentNullException("Нет пароля учетной записи клиента", nameof(model.ClientFIO)); } - _logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Password:{Password}. Id:{Id}", model.ClientFIO, model.Email, model.Password, model.Id); + _logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Password:{Password}. Id:{Id}", model.ClientFIO, model.Login, model.Password, model.Id); var element = _clientStorage.GetElement(new ClientSearchModel { - Email = model.Email + Email = model.Login }); if (element != null && element.Id != model.Id) { diff --git a/FoodOrders/FoodOrdersClientApp/Controllers/HomeController.cs b/FoodOrders/FoodOrdersClientApp/Controllers/HomeController.cs index 61572f0..f6624da 100644 --- a/FoodOrders/FoodOrdersClientApp/Controllers/HomeController.cs +++ b/FoodOrders/FoodOrdersClientApp/Controllers/HomeController.cs @@ -1,18 +1,22 @@ -using FoodOrdersClientApp.Models; + +using FoodOrdersClientApp.Models; +using FoodOrdersClientApp; using FoodOrdersContracts.BindingModels; using FoodOrdersContracts.ViewModels; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; -namespace FoodOrdersClientApp.Controllers +namespace AutoPlantClientApp.Controllers { public class HomeController : Controller { private readonly ILogger _logger; + public HomeController(ILogger logger) { _logger = logger; } + public IActionResult Index() { if (APIClient.Client == null) @@ -21,6 +25,7 @@ namespace FoodOrdersClientApp.Controllers } return View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}")); } + [HttpGet] public IActionResult Privacy() { @@ -30,12 +35,13 @@ namespace FoodOrdersClientApp.Controllers } return View(APIClient.Client); } + [HttpPost] public void Privacy(string login, string password, string fio) { if (APIClient.Client == null) { - throw new Exception("Вход только авторизованным. Пожалуйста, пройдите авторизацию."); + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) { @@ -45,25 +51,28 @@ namespace FoodOrdersClientApp.Controllers { Id = APIClient.Client.Id, ClientFIO = fio, - Email = login, + Login = login, Password = password }); APIClient.Client.ClientFIO = fio; - APIClient.Client.Email = login; + APIClient.Client.Login = login; APIClient.Client.Password = password; Response.Redirect("Index"); } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } + [HttpGet] public IActionResult Enter() { return View(); } + [HttpPost] public void Enter(string login, string password) { @@ -78,11 +87,13 @@ namespace FoodOrdersClientApp.Controllers } Response.Redirect("Index"); } + [HttpGet] public IActionResult Register() { return View(); } + [HttpPost] public void Register(string login, string password, string fio) { @@ -93,43 +104,48 @@ namespace FoodOrdersClientApp.Controllers APIClient.PostRequest("api/client/register", new ClientBindingModel { ClientFIO = fio, - Email = login, + Login = login, Password = password }); Response.Redirect("Enter"); return; } + [HttpGet] public IActionResult Create() { - ViewBag.Foods = APIClient.GetRequest>("api/main/getworklist"); + ViewBag.Food = APIClient.GetRequest>("api/main/get\r\n\t\t\t\tFoodId = food,list"); return View(); } + [HttpPost] public void Create(int food, int count) { if (APIClient.Client == null) { - throw new Exception("Вход только авторизованным. Пожалуйста, пройдите авторизацию."); + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } if (count <= 0) { throw new Exception("Количество и сумма должны быть больше 0"); } + var foods = APIClient.GetRequest>("api/main/getfoodlist"); APIClient.PostRequest("api/main/createorder", new OrderBindingModel { ClientId = APIClient.Client.Id, FoodId = food, + FoodName = (foods.FirstOrDefault(x => x.Id == food)).FoodName, Count = count, Sum = Calc(count, food) }); Response.Redirect("Index"); } + [HttpPost] - public double Calc(int count, int work) + public double Calc(int count, int food) { - var wor = APIClient.GetRequest($"api/main/getwork?workId={work}"); - return count * (wor?.Price ?? 1); + var prod = APIClient.GetRequest($"api/main/getfood?foodId={food}"); + return count * (prod?.Price ?? 1); } } } \ No newline at end of file diff --git a/FoodOrders/FoodOrdersClientApp/Program.cs b/FoodOrders/FoodOrdersClientApp/Program.cs index 0727468..29ec5ab 100644 --- a/FoodOrders/FoodOrdersClientApp/Program.cs +++ b/FoodOrders/FoodOrdersClientApp/Program.cs @@ -1,9 +1,12 @@ +using FoodOrdersClientApp; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); var app = builder.Build(); +APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) diff --git a/FoodOrders/FoodOrdersClientApp/Views/Home/Privacy.cshtml b/FoodOrders/FoodOrdersClientApp/Views/Home/Privacy.cshtml index 003342e..63f2879 100644 --- a/FoodOrders/FoodOrdersClientApp/Views/Home/Privacy.cshtml +++ b/FoodOrders/FoodOrdersClientApp/Views/Home/Privacy.cshtml @@ -9,7 +9,7 @@
Логин:
-
+
Пароль:
diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/ClientBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/ClientBindingModel.cs index b20129b..1891a76 100644 --- a/FoodOrders/FoodOrdersContracts/BindingModels/ClientBindingModel.cs +++ b/FoodOrders/FoodOrdersContracts/BindingModels/ClientBindingModel.cs @@ -12,7 +12,7 @@ namespace FoodOrdersContracts.BindingModels public int Id { get; set; } public string ClientFIO { get; set; } = string.Empty; - public string Email { get; set; } = string.Empty; + public string Login { get; set; } = string.Empty; public string Password { get; set; } = string.Empty; } diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/ClientViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/ClientViewModel.cs index a655f40..e924541 100644 --- a/FoodOrders/FoodOrdersContracts/ViewModels/ClientViewModel.cs +++ b/FoodOrders/FoodOrdersContracts/ViewModels/ClientViewModel.cs @@ -9,7 +9,7 @@ namespace FoodOrdersContracts.ViewModels public string ClientFIO { get; set; } = string.Empty; [DisplayName("логин (эл.почта)")] - public string Email { get; set; } = string.Empty; + public string Login { get; set; } = string.Empty; [DisplayName("Пароль")] public string Password { get; set; } = string.Empty; diff --git a/FoodOrders/FoodOrdersDataModel/Models/IClientModel.cs b/FoodOrders/FoodOrdersDataModel/Models/IClientModel.cs index 2ad245a..38e435e 100644 --- a/FoodOrders/FoodOrdersDataModel/Models/IClientModel.cs +++ b/FoodOrders/FoodOrdersDataModel/Models/IClientModel.cs @@ -9,7 +9,7 @@ namespace FoodOrdersDataModel.Models public interface IClientModel { string ClientFIO { get; } - string Email { get; } + string Login { get; } string Password { get; } } } diff --git a/FoodOrders/FoodOrdersListImplement/Implements/ClientStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/ClientStorage.cs index 268481a..5c7c863 100644 --- a/FoodOrders/FoodOrdersListImplement/Implements/ClientStorage.cs +++ b/FoodOrders/FoodOrdersListImplement/Implements/ClientStorage.cs @@ -31,7 +31,7 @@ namespace FoodOrdersListImplement.Implements } foreach (var client in _source.Clients) { - if (client.Email.Contains(model.Email)) + if (client.Login.Contains(model.Email)) { result.Add(client.GetViewModel); } @@ -54,7 +54,7 @@ namespace FoodOrdersListImplement.Implements { foreach (var client in _source.Clients) { - if (client.Email == model.Email && client.Password == model.Password) + if (client.Login == model.Email && client.Password == model.Password) { return client.GetViewModel; } diff --git a/FoodOrders/FoodOrdersListImplement/Models/Client.cs b/FoodOrders/FoodOrdersListImplement/Models/Client.cs index 3d4fcc8..d3be95e 100644 --- a/FoodOrders/FoodOrdersListImplement/Models/Client.cs +++ b/FoodOrders/FoodOrdersListImplement/Models/Client.cs @@ -8,7 +8,7 @@ namespace FoodOrdersListImplement.Models { public int Id { get; private set; } public string ClientFIO { get; private set; } = string.Empty; - public string Email { get; private set; } = string.Empty; + public string Login { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty; public static Client? Create(ClientBindingModel? model) { @@ -20,7 +20,7 @@ namespace FoodOrdersListImplement.Models { Id = model.Id, ClientFIO = model.ClientFIO, - Email = model.Email, + Login = model.Login, Password = model.Password, }; } @@ -31,14 +31,14 @@ namespace FoodOrdersListImplement.Models return; } ClientFIO = model.ClientFIO; - Email = model.Email; + Login = model.Login; Password = model.Password; } public ClientViewModel GetViewModel => new() { Id = Id, ClientFIO = ClientFIO, - Email = Email, + Login = Login, Password = Password }; } diff --git a/FoodOrders/FoodOrdersRestApi/Controllers/MainController.cs b/FoodOrders/FoodOrdersRestApi/Controllers/MainController.cs index 5f25f5a..cce8a10 100644 --- a/FoodOrders/FoodOrdersRestApi/Controllers/MainController.cs +++ b/FoodOrders/FoodOrdersRestApi/Controllers/MainController.cs @@ -12,36 +12,36 @@ namespace FoodOrdersRestApi.Controllers { private readonly ILogger _logger; private readonly IOrderLogic _order; - private readonly IFoodLogic _work; - public MainController(ILogger logger, IOrderLogic order, IFoodLogic work) + private readonly IFoodLogic _food; + public MainController(ILogger logger, IOrderLogic order, IFoodLogic food) { _logger = logger; _order = order; - _work = work; + _food = food; } [HttpGet] - public List? GetWorkList() + public List? GetFoodList() { try { - return _work.ReadList(null); + return _food.ReadList(null); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка работ"); + _logger.LogError(ex, "Ошибка получения списка продуктов"); throw; } } [HttpGet] - public FoodViewModel? GetWork(int workId) + public FoodViewModel? GetFood(int foodId) { try { - return _work.ReadElement(new FoodSearchModel { Id = workId }); + return _food.ReadElement(new FoodSearchModel { Id = foodId }); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения работы по id={Id}", workId); + _logger.LogError(ex, "Ошибка получения работы по id={Id}", foodId); throw; } }