Добавил апдейт статуса

This commit is contained in:
Artyom_Yashin 2024-05-26 22:56:41 +04:00
parent 135fde1a80
commit d2c8fb0bcd
8 changed files with 45 additions and 26 deletions

View File

@ -81,14 +81,15 @@ namespace BankBusinessLogic.BusinessLogic
}
return true;
}
public bool DeclineRequest(RequestBindingModel model)
{
return ChangeStatus(model, RequestStatus.Выполнена);
}
public bool SatisfyRequest(RequestBindingModel model)
{
return ChangeStatus(model, RequestStatus.Отклонена);
}
//todo методы смены статуса
//public bool DeclineRequest(RequestBindingModel model)
//{
// return ChangeStatus(model, RequestStatus.Отклонена);
//}
//public bool SatisfyRequest(RequestBindingModel model)
//{
// return ChangeStatus(model, RequestStatus.Выполнена);
//}
private void CheckModel(RequestBindingModel model, bool withParams = true)
{
@ -101,12 +102,12 @@ namespace BankBusinessLogic.BusinessLogic
_logger.LogInformation("Request. Sum:{Sum}. Id: { Id} ", model.Sum, model.Id);
}
private bool ChangeStatus(RequestBindingModel model, RequestStatus status)
{
//todo поменять
model.Status = status;
_requestStorage.Update(model);
return true;
}
//private bool ChangeStatus(RequestBindingModel model, RequestStatus status)
//{
// //todo поменять
// model.Status = status;
// _requestStorage.Update(model);
// return true;
//}
}
}

View File

@ -101,7 +101,7 @@ namespace BankBusinessLogic.OfficePackage
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var transfer in transfer.Transfers)
foreach (var transfer1 in transfer.Transfers)
{
InsertCellInWorksheet(new ExcelCellParameters
{

View File

@ -53,11 +53,21 @@ namespace BankBusinessLogic.OfficePackage
List<ReportTransfersViewModel> reports = info.Transfers;
foreach (ReportTransfersViewModel report in reports)
{
List<string> header = new List<string>
{
report.CardNumber,
"",
"",
"",
"",
"",
};
table.Add(header);
foreach(TransferViewModel transfer in report.Transfers)
{
List<string> row = new List<string>
{
report.CardNumber,
"",
transfer.Id.ToString(),
transfer.Sum.ToString(),
transfer.TransferTime.ToString(),

View File

@ -443,7 +443,6 @@ namespace BankClientApp.Controllers
Id = request,
Sum = sum,
CardRequests = a,
Status = RequestStatus.Принята
});
Response.Redirect("Request");
}

View File

@ -16,7 +16,8 @@ namespace BankContracts.BusinessLogicsContracts
bool Create(RequestBindingModel model);
bool Update(RequestBindingModel model);
bool Delete(RequestBindingModel model);
bool DeclineRequest(RequestBindingModel model);
bool SatisfyRequest(RequestBindingModel model);
//todo методы смены статуса
//bool DeclineRequest(RequestBindingModel model);
//bool SatisfyRequest(RequestBindingModel model);
}
}

View File

@ -37,7 +37,7 @@ namespace BankDatabaseImplement.Implements
return context.CardRequests
.Include(x => x.Card).Include(x => x.Request)
.Where(x => x.RequestId==model.RequestId)
.Select(x => x.Card.Id).ToList();
.Select(x => x.Card.Id).Distinct().ToList();
}
public List<ReportTransfersViewModel> GetReportTransfersList(CardSearchModel model)

View File

@ -70,9 +70,8 @@ namespace BankDatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
var Request = context.Requests.FirstOrDefault(rec =>
rec.Id == model.Id);
if (Request == null || Request.Status != RequestStatus.Принята)
var Request = context.Requests.FirstOrDefault(rec => rec.Id == model.Id);
if (Request == null)
{
return null;
}

View File

@ -55,7 +55,16 @@ namespace BankDatabaseImplement.Models
public void Update(RequestBindingModel model)
{
Sum = model.Sum;
Status = model.Status;
}
public bool ChangeStatus(RequestStatus status)
{
if(Status == RequestStatus.Принята)
{
Status = status;
return true;
}
return false;
}
public RequestViewModel GetViewModel => new()
@ -69,7 +78,7 @@ namespace BankDatabaseImplement.Models
public void UpdateCards(BankDatabase context, RequestBindingModel model)
{
var CardRequests = context.CardRequests.Where(rec => rec.RequestId == model.Id).ToList();
var CardRequests = context.CardRequests.Where(rec => rec.RequestId == model.Id).Distinct().ToList();
if (CardRequests != null && CardRequests.Count > 0)
{ // удалили те, которых нет в модели
context.CardRequests.RemoveRange(CardRequests.Where(rec => !model.CardRequests.ContainsKey(rec.CardId)));