diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs
index 866943b..42df87a 100644
--- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs
+++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs
@@ -100,13 +100,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
{
throw new ArgumentNullException("Сумма операции должна быть больше 0", nameof(model.Sum));
}
- if (model.Date < DateTime.Now)
+ if (model.DateClose < model.DateOpen)
{
- throw new ArgumentNullException("Дата не может быть меньше текущего времени", nameof(model.Date));
+ throw new ArgumentNullException("Дата закрытия не может быть меньше даты открытия", nameof(model.DateClose));
}
- _logger.LogInformation("Debiting. Sum:{Sum}.CardId:{CardId}.Date:{date}.Id:{Id}",
- model.Sum, model.CardId, model.Date.ToString(), model.Id);
+ _logger.LogInformation("Debiting. Sum:{Sum}.CardId:{CardId}.DateOpen:{DateOpen}.DateOpen:{DateOpen}.Id:{Id}",
+ model.Sum, model.CardId, model.DateOpen.ToString(), model.DateClose.ToString(), model.Id);
}
}
}
diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs
index 3822907..6aa0186 100644
--- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs
+++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs
@@ -51,13 +51,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
{
return _debitingStorage.GetFilteredList(new DebitingSearchModel
{
- dateFrom = model.DateFrom,
- dateTo = model.DateTo,
+ DateOpen = model.DateFrom,
+ DateClose = model.DateTo,
}).Select(x => new ReportClientViewModel
{
CardId = x.CardId,
SumOperation = x.Sum,
- DateComplite = x.Date
+ DateComplite = x.DateClose
}).ToList();
}
diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs
index 8b2ec1c..84f467d 100644
--- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs
+++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.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; }
+ }
}
diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs
index 80e2719..9be07ad 100644
--- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs
+++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.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? DateOpen { get; set; }
- public DateTime? dateTo { get; set; }
+ public DateTime? DateClose { get; set; }
+
+ public StatusEnum? Status { get; set; }
}
}
diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs
index 22f80e9..352feb0 100644
--- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs
+++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .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/BankYouBankruptDataModels.csproj b/BankYouBankrupt/BankYouBankruptDataModels/BankYouBankruptDataModels.csproj
index b6a7529..132c02c 100644
--- a/BankYouBankrupt/BankYouBankruptDataModels/BankYouBankruptDataModels.csproj
+++ b/BankYouBankrupt/BankYouBankruptDataModels/BankYouBankruptDataModels.csproj
@@ -6,8 +6,4 @@
enable
-
-
-
-
diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Enums/StatusEnum.cs b/BankYouBankrupt/BankYouBankruptDataModels/Enums/StatusEnum.cs
new file mode 100644
index 0000000..285fab6
--- /dev/null
+++ b/BankYouBankrupt/BankYouBankruptDataModels/Enums/StatusEnum.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankYouBankruptDataModels.Enums
+{
+ public enum StatusEnum
+ {
+ Открыта = 0,
+
+ Закрыта = 1
+ }
+}
diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.cs b/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.cs
index 6ad9cfd..ade8c49 100644
--- a/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.cs
+++ b/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.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/Implements/DebitingStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs
index 8c71c56..6a812fd 100644
--- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs
+++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs
@@ -3,6 +3,7 @@ using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDatabaseImplement.Models;
+using BankYouBankruptDataModels.Enums;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
@@ -33,6 +34,15 @@ namespace BankYouBankruptDatabaseImplement.Implements
using var context = new BankYouBancruptDatabase();
+ //для получения всех заявок на стнятие со статусом "Открыта"
+ if(model.Status != StatusEnum.Закрыта)
+ {
+ return context.Debitings
+ .Where(x => x.Status == StatusEnum.Открыта)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+
return context.Debitings
.Where(x => x.CardId == model.CardId)
.Select(x => x.GetViewModel)
diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs
index 4d45307..04bd053 100644
--- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs
+++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs
@@ -1,5 +1,6 @@
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
+using BankYouBankruptDataModels.Enums;
using BankYouBankruptDataModels.Models;
using System;
using System.Collections.Generic;
@@ -16,22 +17,30 @@ namespace BankYouBankruptDatabaseImplement.Models
[Required]
public int CardId { get; set; }
+
public virtual Card Card { get; set; } = new();
[Required]
public int Sum { get; set; }
[Required]
- public DateTime Date { get; set; } = DateTime.Now;
+ public DateTime DateOpen { get; set; } = DateTime.Now;
+ [Required]
+ public DateTime DateClose { get; set; }
- public DebitingViewModel GetViewModel => new()
+ [Required]
+ public StatusEnum Status { get; set; } = StatusEnum.Открыта;
+
+ public DebitingViewModel GetViewModel => new()
{
Id = Id,
CardId = CardId,
CardNumber = Card.Number,
Sum = Sum,
- Date = Date
+ DateOpen = DateOpen,
+ DateClose = DateClose,
+ Status = Status
};
public static Debiting Create(BankYouBancruptDatabase context, DebitingBindingModel model)
@@ -42,13 +51,15 @@ namespace BankYouBankruptDatabaseImplement.Models
CardId = model.CardId,
Card = context.Cards.First(x => x.Id == model.CardId),
Sum = model.Sum,
- Date = model.Date
- };
+ DateOpen = model.DateOpen,
+ DateClose = model.DateClose,
+ Status = model.Status
+ };
}
public void Update(DebitingBindingModel model)
{
- Date = model.Date;
+ DateClose = model.DateClose;
}
}
}