From 191d34b8a56f1c825a0ed530c67205b9dbf3c59e Mon Sep 17 00:00:00 2001 From: shadowik Date: Tue, 16 May 2023 16:45:35 +0400 Subject: [PATCH] Crediting change --- .../BusinessLogics/CreditingLogic.cs | 6 +++--- .../BusinessLogics/ReportClientLogic.cs | 10 +++++----- .../BindingModels/CreditingBindingModel.cs | 9 +++++++-- .../BindingModels/DebitingBindingModel.cs | 4 ++-- .../SearchModels/CreditingSearchModel.cs | 9 ++++++--- .../SearchModels/DebitingSearchModel.cs | 4 ++-- .../ViewModels/CreditingViewModel.cs | 13 ++++++++++--- .../Models/ICreditingModel.cs | 11 ++++++++--- .../Models/Crediting.cs | 14 ++++++++++---- .../Controllers/CardController.cs | 9 +++++---- 10 files changed, 58 insertions(+), 31 deletions(-) diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs index 54ec562..71f1cce 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs @@ -107,13 +107,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { throw new ArgumentNullException("Сумма операции должна быть больше 0", nameof(model.Sum)); } - if (model.Date > DateTime.Now) + if (model.DateOpen > DateTime.Now) { - throw new ArgumentNullException("Дата не может быть меньше текущего времени", nameof(model.Date)); + throw new ArgumentNullException("Дата не может быть меньше текущего времени", nameof(model.DateOpen)); } _logger.LogInformation("Crediting. Sum:{Sum}.CardId:{CardId}.Date:{date}.Id:{Id}", - model.Sum, model.CardId, model.Date.ToString(), model.Id); + model.Sum, model.CardId, model.DateOpen.ToString(), model.Id); } } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs index 6aa0186..cb8c59f 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs @@ -37,13 +37,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { return _creditingStorage.GetFilteredList(new CreditingSearchModel { - dateFrom = model.DateFrom, - dateTo = model.DateTo, + DateFrom = model.DateFrom, + DateTo = model.DateTo, }).Select(x => new ReportClientViewModel { CardId = x.CardId, SumOperation = x.Sum, - DateComplite = x.Date + DateComplite = x.DateOpen }).ToList(); } @@ -51,8 +51,8 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { return _debitingStorage.GetFilteredList(new DebitingSearchModel { - DateOpen = model.DateFrom, - DateClose = model.DateTo, + DateTo = model.DateFrom, + DateFrom = model.DateTo, }).Select(x => new ReportClientViewModel { CardId = x.CardId, diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs index 440830b..cfb3242 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs @@ -1,4 +1,5 @@ -using BankYouBankruptDataModels.Models; +using BankYouBankruptDataModels.Enums; +using BankYouBankruptDataModels.Models; using System; using System.Collections.Generic; using System.Linq; @@ -15,6 +16,10 @@ namespace BankYouBankruptContracts.BindingModels public int Sum { get; set; } - public DateTime Date { get; set; } = DateTime.Now; + public DateTime DateOpen { get; set; } = DateTime.Now; + + public DateTime? DateClose { get; set; } + + public StatusEnum Status { get; set; } = StatusEnum.Открыта; } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs index 9a0bcfa..ec439ef 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs @@ -20,6 +20,6 @@ namespace BankYouBankruptContracts.BindingModels public DateTime? DateClose { get; set; } - public StatusEnum Status { get; set; } - } + public StatusEnum Status { get; set; } = StatusEnum.Открыта; + } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CreditingSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CreditingSearchModel.cs index c6690c4..7c3fea1 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CreditingSearchModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CreditingSearchModel.cs @@ -1,4 +1,5 @@ -using System; +using BankYouBankruptDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,8 +15,10 @@ namespace BankYouBankruptContracts.SearchModels public int? Sum { get; set; } - public DateTime? dateFrom { get; set; } + public DateTime? DateFrom { get; set; } - public DateTime? dateTo { get; set; } + public DateTime? DateTo { get; set; } + + public StatusEnum? Status { get; set; } } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs index 9be07ad..32a6ed7 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs @@ -15,9 +15,9 @@ namespace BankYouBankruptContracts.SearchModels public int? Sum { get; set; } - public DateTime? DateOpen { get; set; } + public DateTime? DateFrom { get; set; } - public DateTime? DateClose { get; set; } + public DateTime? DateTo { get; set; } public StatusEnum? Status { get; set; } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs index 5a31584..2b28318 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs @@ -1,4 +1,5 @@ -using BankYouBankruptDataModels.Models; +using BankYouBankruptDataModels.Enums; +using BankYouBankruptDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -20,7 +21,13 @@ namespace BankYouBankruptContracts.ViewModels [DisplayName("Сумма операции")] public int Sum { get; set; } - [DisplayName("Дата операции")] - public DateTime Date { get; set; } = DateTime.Now; + [DisplayName("Дата открытия заявки")] + public DateTime DateOpen { get; set; } = DateTime.Now; + + [DisplayName("Дата закрытия заявки")] + public DateTime? DateClose { get; set; } + + [DisplayName("Статус заявки")] + public StatusEnum Status { get; set; } } } diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs b/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs index 40d91c1..77da0f1 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs @@ -1,4 +1,5 @@ -using System; +using BankYouBankruptDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,6 +14,10 @@ namespace BankYouBankruptDataModels.Models int Sum { get; } - DateTime Date { get; } - } + DateTime DateOpen { get; } + + DateTime? DateClose { get; } + + StatusEnum Status { get; } + } } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs index 29cff81..91f8707 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs @@ -1,5 +1,6 @@ using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.ViewModels; +using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Models; using System; using System.Collections.Generic; @@ -24,8 +25,12 @@ namespace BankYouBankruptDatabaseImplement.Models public int Sum { get; set; } [Required] - public DateTime Date { get; set; } = DateTime.Now; + public DateTime DateOpen { get; set; } = DateTime.Now; + public DateTime? DateClose { get; set; } + + [Required] + public StatusEnum Status { get; set; } public CreditingViewModel GetViewModel => new() { @@ -33,7 +38,7 @@ namespace BankYouBankruptDatabaseImplement.Models CardId = CardId, CardNumber = Card.Number, Sum = Sum, - Date = Date + DateOpen = DateOpen }; public static Crediting Create(BankYouBancruptDatabase context, CreditingBindingModel model) @@ -44,13 +49,14 @@ namespace BankYouBankruptDatabaseImplement.Models CardId = model.CardId, Card = context.Cards.First(x => x.Id == model.CardId), Sum = model.Sum, - Date = model.Date + DateOpen = model.DateOpen }; } public void Update(CreditingBindingModel model) { - Date = model.Date; + DateClose = model.DateClose; + Status = model.Status; } } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs index 0ead646..2edf664 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs @@ -77,10 +77,11 @@ namespace BankYouBankruptRestApi.Controllers try { _creditingLogic.Create(model); - _accountLogic.ChangeBalance(new AccountSearchModel - { - Id = _cardLogic.ReadElement(new CardSearchModel { Id = model.CardId }).AccountId - }, model.Sum); + + //_accountLogic.ChangeBalance(new AccountSearchModel + //{ + // Id = _cardLogic.ReadElement(new CardSearchModel { Id = model.CardId }).AccountId + //}, model.Sum); } catch (Exception ex) { _logger.LogError(ex, "Ошибка создания операции на пополнение");