From c3e2a547105225234a63116688715323e8e46df3 Mon Sep 17 00:00:00 2001 From: abazov73 <92822431+abazov73@users.noreply.github.com> Date: Fri, 7 Apr 2023 18:20:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OperatorStorage.cs | 20 ++++++++++++++----- Bank/BankDatabaseImplement/Models/Deal.cs | 2 +- .../OperatorApp/Controllers/HomeController.cs | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Bank/BankDatabaseImplement/Implements/OperatorStorage.cs b/Bank/BankDatabaseImplement/Implements/OperatorStorage.cs index a9fc467..edc1aa5 100644 --- a/Bank/BankDatabaseImplement/Implements/OperatorStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/OperatorStorage.cs @@ -45,14 +45,24 @@ namespace BankDatabaseImplement.Implements } public OperatorViewModel? GetElement(OperatorSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password)) { return null; } - using var context = new BankDatabase(); - return context.Operators - .FirstOrDefault(x => x.Id == model.Id) - ?.GetViewModel; + if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password)) + { + using var context = new BankDatabase(); + return context.Operators + .FirstOrDefault(x => x.Login == model.Login && x.Password == model.Password) + ?.GetViewModel; + } + else + { + using var context = new BankDatabase(); + return context.Operators + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } } public OperatorViewModel? Insert(OperatorBindingModel model) { diff --git a/Bank/BankDatabaseImplement/Models/Deal.cs b/Bank/BankDatabaseImplement/Models/Deal.cs index 4bc6b92..0cb65c0 100644 --- a/Bank/BankDatabaseImplement/Models/Deal.cs +++ b/Bank/BankDatabaseImplement/Models/Deal.cs @@ -22,7 +22,7 @@ namespace BankDatabaseImplement.Models public int OperatorId { get; set; } public virtual Operator Operator { get; set; } = new(); public int? CreditProgramId {get; set; } - public virtual CreditProgram CreditProgram { get; set; } = new(); + public virtual CreditProgram? CreditProgram { get; set; } [ForeignKey("DealId")] public virtual List DealPayments { get; set; } = new(); public static Deal? Create(BankDatabase context, DealBindingModel model) diff --git a/Bank/OperatorApp/Controllers/HomeController.cs b/Bank/OperatorApp/Controllers/HomeController.cs index ede4c06..74ef502 100644 --- a/Bank/OperatorApp/Controllers/HomeController.cs +++ b/Bank/OperatorApp/Controllers/HomeController.cs @@ -127,7 +127,7 @@ namespace OperatorApp.Controllers { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } - APIClient.PostRequest("api/main/createorder", new DealBindingModel + APIClient.PostRequest("api/deal/createdeal", new DealBindingModel { ClientId = clientid, OperatorId = APIClient.Operator.Id,