From 846f54e663b8ac0cf68ebfcbeb0f2848a973ffa6 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Fri, 26 Apr 2024 00:03:46 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D1=82=D0=B0=D0=BB=D0=B8=D1=81?= =?UTF-8?q?=D1=8C=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D1=87=D0=B5=D1=82=D1=8B=20=D0=B2=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8F=D1=85=20=D0=B1=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/AttestationLogic.cs | 55 ++++++++++--------- .../IAttestationLogic.cs | 8 +-- .../UniversityDatabase.cs | 2 +- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/University/UniversityBusinessLogic/BusinessLogics/AttestationLogic.cs b/University/UniversityBusinessLogic/BusinessLogics/AttestationLogic.cs index d023013..8d9cc03 100644 --- a/University/UniversityBusinessLogic/BusinessLogics/AttestationLogic.cs +++ b/University/UniversityBusinessLogic/BusinessLogics/AttestationLogic.cs @@ -65,48 +65,55 @@ namespace UniversityBusinessLogic.BusinessLogics _logger.LogWarning("Insert operation failed"); return false; } - return true; } public bool ScoreUpdate(AttestationBindingModel model, AttestationScore newScore) { CheckModel(model); - if (model.Score + 1 != newScore) + + if (!Enum.IsDefined(typeof(AttestationScore), newScore)) { - _logger.LogWarning("Status update to " + newScore.ToString() + " operation failed. Order status incorrect."); + _logger.LogWarning("Score update to " + newScore.ToString() + " operation failed. Attestation status incorrect."); return false; } - model.Score = newScore; - - if (model.Score == AttestationScore.Выдан) - model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); - if (_attestationStorage.Update(model) == null) { - model.Score--; _logger.LogWarning("Update operation failed"); return false; } + model.Score = newScore; return true; } - public bool TakeOrderInWork(OrderBindingModel model) + public bool SetPass(AttestationBindingModel model) { - return StatusUpdate(model, OrderStatus.Выполняется); + return ScoreUpdate(model, AttestationScore.Зачёт); } - public bool DeliveryOrder(OrderBindingModel model) + public bool SetNotPass(AttestationBindingModel model) { - return StatusUpdate(model, OrderStatus.Готов); + return ScoreUpdate(model, AttestationScore.Незачёт); } - public bool FinishOrder(OrderBindingModel model) + public bool SetTwo(AttestationBindingModel model) { - return StatusUpdate(model, OrderStatus.Выдан); + return ScoreUpdate(model, AttestationScore.Неудовлетворительно); + } + public bool SetThree(AttestationBindingModel model) + { + return ScoreUpdate(model, AttestationScore.Удовлетворительно); + } + public bool SetFour(AttestationBindingModel model) + { + return ScoreUpdate(model, AttestationScore.Хорошо); + } + public bool SetFive(AttestationBindingModel model) + { + return ScoreUpdate(model, AttestationScore.Отлично); } - private void CheckModel(OrderBindingModel model, bool withParams = true) + private void CheckModel(AttestationBindingModel model, bool withParams = true) { if (model == null) { @@ -116,21 +123,17 @@ namespace UniversityBusinessLogic.BusinessLogics { return; } - if (model.WorkId < 0) + if (string.IsNullOrEmpty(model.FormOfEvaluation)) { - throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.WorkId)); + throw new ArgumentNullException("Не выбрана форма оценивания", nameof(model.FormOfEvaluation)); } - if (model.Count <= 0) + if (model.StudentId <= 0) { - throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count)); + throw new ArgumentNullException("Некорректный идентификатор студента", nameof(model.StudentId)); } - - if (model.Sum <= 0) - { - throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); - } - _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. WorkId: { WorkId}", model.Id, model.Sum, model.WorkId); + _logger.LogInformation("Attestation. AttestationId:{Id}.FormOfEvaluation:{FormOfEvaluation}. StudentId: { StudentId}", + model.Id, model.FormOfEvaluation, model.StudentId); } } } diff --git a/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs b/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs index be5f3d2..a5a3d31 100644 --- a/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs +++ b/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs @@ -15,10 +15,10 @@ namespace UniversityContracts.BusinessLogicsContracts bool CreateAttestation(AttestationBindingModel model); bool SetPass(AttestationBindingModel model); bool SetNotPass(AttestationBindingModel model); - bool Set(AttestationBindingModel model); - bool Set(AttestationBindingModel model); - bool Set(AttestationBindingModel model); - bool SetNotCredit(AttestationBindingModel model); + bool SetTwo(AttestationBindingModel model); + bool SetThree(AttestationBindingModel model); + bool SetFour(AttestationBindingModel model); + bool SetFive(AttestationBindingModel model); } } diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 21c4a21..c186883 100644 --- a/University/UniversityDatabaseImplement/UniversityDatabase.cs +++ b/University/UniversityDatabaseImplement/UniversityDatabase.cs @@ -12,7 +12,7 @@ namespace UniversityDatabaseImplement if (optionsBuilder.IsConfigured == false) { //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR - optionsBuilder.UseSqlServer(@"Data Source=(localdb)\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); }