Crediting change

This commit is contained in:
shadowik 2023-05-16 16:45:35 +04:00
parent d0ec922743
commit 191d34b8a5
10 changed files with 58 additions and 31 deletions

View File

@ -107,13 +107,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException("Сумма операции должна быть больше 0", nameof(model.Sum)); 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}", _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);
} }
} }
} }

View File

@ -37,13 +37,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {
return _creditingStorage.GetFilteredList(new CreditingSearchModel return _creditingStorage.GetFilteredList(new CreditingSearchModel
{ {
dateFrom = model.DateFrom, DateFrom = model.DateFrom,
dateTo = model.DateTo, DateTo = model.DateTo,
}).Select(x => new ReportClientViewModel }).Select(x => new ReportClientViewModel
{ {
CardId = x.CardId, CardId = x.CardId,
SumOperation = x.Sum, SumOperation = x.Sum,
DateComplite = x.Date DateComplite = x.DateOpen
}).ToList(); }).ToList();
} }
@ -51,8 +51,8 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {
return _debitingStorage.GetFilteredList(new DebitingSearchModel return _debitingStorage.GetFilteredList(new DebitingSearchModel
{ {
DateOpen = model.DateFrom, DateTo = model.DateFrom,
DateClose = model.DateTo, DateFrom = model.DateTo,
}).Select(x => new ReportClientViewModel }).Select(x => new ReportClientViewModel
{ {
CardId = x.CardId, CardId = x.CardId,

View File

@ -1,4 +1,5 @@
using BankYouBankruptDataModels.Models; using BankYouBankruptDataModels.Enums;
using BankYouBankruptDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -15,6 +16,10 @@ namespace BankYouBankruptContracts.BindingModels
public int Sum { get; set; } 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.Открыта;
} }
} }

View File

@ -20,6 +20,6 @@ namespace BankYouBankruptContracts.BindingModels
public DateTime? DateClose { get; set; } public DateTime? DateClose { get; set; }
public StatusEnum Status { get; set; } public StatusEnum Status { get; set; } = StatusEnum.Открыта;
} }
} }

View File

@ -1,4 +1,5 @@
using System; using BankYouBankruptDataModels.Enums;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -14,8 +15,10 @@ namespace BankYouBankruptContracts.SearchModels
public int? Sum { get; set; } 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; }
} }
} }

View File

@ -15,9 +15,9 @@ namespace BankYouBankruptContracts.SearchModels
public int? Sum { get; set; } 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; } public StatusEnum? Status { get; set; }
} }

View File

@ -1,4 +1,5 @@
using BankYouBankruptDataModels.Models; using BankYouBankruptDataModels.Enums;
using BankYouBankruptDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -20,7 +21,13 @@ namespace BankYouBankruptContracts.ViewModels
[DisplayName("Сумма операции")] [DisplayName("Сумма операции")]
public int Sum { get; set; } public int Sum { get; set; }
[DisplayName("Дата операции")] [DisplayName("Дата открытия заявки")]
public DateTime Date { get; set; } = DateTime.Now; public DateTime DateOpen { get; set; } = DateTime.Now;
[DisplayName("Дата закрытия заявки")]
public DateTime? DateClose { get; set; }
[DisplayName("Статус заявки")]
public StatusEnum Status { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using BankYouBankruptDataModels.Enums;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -13,6 +14,10 @@ namespace BankYouBankruptDataModels.Models
int Sum { get; } int Sum { get; }
DateTime Date { get; } DateTime DateOpen { get; }
}
DateTime? DateClose { get; }
StatusEnum Status { get; }
}
} }

View File

@ -1,5 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Enums;
using BankYouBankruptDataModels.Models; using BankYouBankruptDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -24,8 +25,12 @@ namespace BankYouBankruptDatabaseImplement.Models
public int Sum { get; set; } public int Sum { get; set; }
[Required] [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() public CreditingViewModel GetViewModel => new()
{ {
@ -33,7 +38,7 @@ namespace BankYouBankruptDatabaseImplement.Models
CardId = CardId, CardId = CardId,
CardNumber = Card.Number, CardNumber = Card.Number,
Sum = Sum, Sum = Sum,
Date = Date DateOpen = DateOpen
}; };
public static Crediting Create(BankYouBancruptDatabase context, CreditingBindingModel model) public static Crediting Create(BankYouBancruptDatabase context, CreditingBindingModel model)
@ -44,13 +49,14 @@ namespace BankYouBankruptDatabaseImplement.Models
CardId = model.CardId, CardId = model.CardId,
Card = context.Cards.First(x => x.Id == model.CardId), Card = context.Cards.First(x => x.Id == model.CardId),
Sum = model.Sum, Sum = model.Sum,
Date = model.Date DateOpen = model.DateOpen
}; };
} }
public void Update(CreditingBindingModel model) public void Update(CreditingBindingModel model)
{ {
Date = model.Date; DateClose = model.DateClose;
Status = model.Status;
} }
} }
} }

View File

@ -77,10 +77,11 @@ namespace BankYouBankruptRestApi.Controllers
try { try {
_creditingLogic.Create(model); _creditingLogic.Create(model);
_accountLogic.ChangeBalance(new AccountSearchModel
{ //_accountLogic.ChangeBalance(new AccountSearchModel
Id = _cardLogic.ReadElement(new CardSearchModel { Id = model.CardId }).AccountId //{
}, model.Sum); // Id = _cardLogic.ReadElement(new CardSearchModel { Id = model.CardId }).AccountId
//}, model.Sum);
} }
catch (Exception ex) { catch (Exception ex) {
_logger.LogError(ex, "Ошибка создания операции на пополнение"); _logger.LogError(ex, "Ошибка создания операции на пополнение");