Изменение сущности "Снятие наличных с карты".

This commit is contained in:
Programmist73 2023-05-14 15:14:30 +04:00
parent 0ade8d57ca
commit dbeaf0e380
10 changed files with 81 additions and 29 deletions

View File

@ -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);
}
}
}

View File

@ -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();
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -6,8 +6,4 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Enums\" />
</ItemGroup>
</Project>

View File

@ -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
}
}

View File

@ -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; }
}
}

View File

@ -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)

View File

@ -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;
}
}
}