сомнительно, но окэй
This commit is contained in:
parent
8d73f33020
commit
38ac2f89ac
@ -7,7 +7,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
|
||||
<PackageReference Include="MailKit" Version="4.6.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -125,11 +125,11 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
"Отсутствует номер телефона клиента",
|
||||
nameof(model.Phone));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PasswordHash))
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует пароль клиента",
|
||||
nameof(model.PasswordHash));
|
||||
nameof(model.Password));
|
||||
}
|
||||
if (model.WorkerId <= 0)
|
||||
{
|
||||
@ -139,10 +139,10 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
}
|
||||
_logger.LogInformation("Client. Snils: {Snils}. ClientFullname: " +
|
||||
"{ClientSurname} {ClientName} {ClientPatronymic}. Phone: " +
|
||||
"{Phone}. Email: {Email}. PasswordHash: {PasswordHash}.",
|
||||
"{Phone}. Email: {Email}. Password: {Password}.",
|
||||
model.Snils, model.ClientSurname, model.ClientName,
|
||||
model.ClientPatronymic, model.Phone, model.Email,
|
||||
model.PasswordHash);
|
||||
model.Password);
|
||||
var elementByEmail = _clientStorage.GetElement(
|
||||
new ClientSearchModel
|
||||
{
|
||||
|
176
Bank/BankBusinessLogic/BusinessLogics/ReportLogicWorker.cs
Normal file
176
Bank/BankBusinessLogic/BusinessLogics/ReportLogicWorker.cs
Normal file
@ -0,0 +1,176 @@
|
||||
using BankBusinessLogic.OfficePackage;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogicWorker : IReportLogicWorker
|
||||
{
|
||||
private readonly IDepositStorage _depositStorage;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
public ReportLogicWorker(IDepositStorage depositStorage, IClientStorage clientStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord,
|
||||
AbstractSaveToPdf saveToPdf)
|
||||
{
|
||||
_depositStorage = depositStorage;
|
||||
_clientStorage = clientStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
|
||||
public List<ListProgramsViewModel> GetDepositPrograms(List<int> deposits)
|
||||
{
|
||||
|
||||
List<ListProgramsViewModel> ans = new();
|
||||
List<Tuple<DepositViewModel, List<Tuple<CurrencyViewModel, List<ProgramViewModel>>>>> response =
|
||||
_depositStorage.GetReportInfo(new ListProgramsSearchModel { depositsIds = deposits });
|
||||
|
||||
foreach (var deposit in response)
|
||||
{
|
||||
Dictionary<int, (ProgramViewModel, int)> counter = new();
|
||||
foreach (var currency in deposit.Item2)
|
||||
{
|
||||
foreach (var service in currency.Item2)
|
||||
{
|
||||
if (!counter.ContainsKey(service.Id))
|
||||
counter.Add(service.Id, (service, 1));
|
||||
else
|
||||
{
|
||||
counter[service.Id] = (counter[service.Id].Item1, counter[service.Id].Item2 + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<ProgramViewModel> res = new();
|
||||
foreach (var cnt in counter)
|
||||
{
|
||||
if (cnt.Value.Item2 != deposit.Item2.Count)
|
||||
continue;
|
||||
res.Add(cnt.Value.Item1);
|
||||
}
|
||||
ans.Add(new ListProgramsViewModel
|
||||
{
|
||||
DepositId = deposit.Item1.Id,
|
||||
Programs = res
|
||||
});
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
public void SaveProgramsToExcelFile(ListProgramsBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список кредитных программ по выбранным вкладам",
|
||||
DepositsPrograms = GetDepositPrograms(model.Deposits)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveProgramsToWordFile(ListProgramsBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список кредитных программ по выбранным вкладам",
|
||||
DepositsPrograms = GetDepositPrograms(model.Deposits)
|
||||
});
|
||||
}
|
||||
|
||||
public List<CurrenciesRefillsViewModel> GetClientCurrenciesAndRefills(CurrenciesRefillsBindingModel model)
|
||||
{
|
||||
List<CurrenciesRefillsViewModel> ans = new();
|
||||
List<Tuple<ClientViewModel, List<Tuple<DepositViewModel, List<RefillViewModel>>>>> responseRefills =
|
||||
_clientStorage.GetRefillsInfo(new CurrenciesRefillsSearchModel { DateFrom = model.DateFrom!, DateTo = model.DateTo!, WorkerId = model.WorkerId! });
|
||||
List<Tuple<ClientViewModel, List<Tuple<DepositViewModel, List<CurrencyViewModel>>>>> responseCurrencies =
|
||||
_clientStorage.GetCurrenciesInfo(new CurrenciesRefillsSearchModel { WorkerId = model.WorkerId! });
|
||||
Dictionary<int, CurrenciesRefillsViewModel> dict = new();
|
||||
|
||||
foreach (var client in responseRefills)
|
||||
{
|
||||
if (client.Item1.WorkerId == model.WorkerId && client.Item2.Any(deposit => deposit.Item1.OpeningDate.ToDateTime(TimeOnly.MinValue) >= model.DateFrom && deposit.Item1.OpeningDate.ToDateTime(TimeOnly.MinValue) <= model.DateTo))
|
||||
{
|
||||
if (!dict.ContainsKey(client.Item1.WorkerId))
|
||||
{
|
||||
dict.Add(client.Item1.WorkerId, new CurrenciesRefillsViewModel
|
||||
{
|
||||
ClientSurname = client.Item1.ClientSurname,
|
||||
ClientName = client.Item1.ClientName,
|
||||
ClientPatronymic = client.Item1.ClientPatronymic,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var deposit in client.Item2)
|
||||
{
|
||||
foreach (var refill in deposit.Item2)
|
||||
{
|
||||
if (refill.RefillDate.ToDateTime(TimeOnly.MinValue) >= model.DateFrom && refill.RefillDate.ToDateTime(TimeOnly.MinValue) <= model.DateTo)
|
||||
{
|
||||
dict[client.Item1.WorkerId].Refills.Add(refill);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var client in responseCurrencies)
|
||||
{
|
||||
if (client.Item1.WorkerId == model.WorkerId && client.Item2.Any(deposit => deposit.Item1.OpeningDate.ToDateTime(TimeOnly.MinValue) >= model.DateFrom && deposit.Item1.OpeningDate.ToDateTime(TimeOnly.MinValue) <= model.DateTo))
|
||||
{
|
||||
if (!dict.ContainsKey(client.Item1.WorkerId))
|
||||
{
|
||||
dict.Add(client.Item1.WorkerId, new CurrenciesRefillsViewModel
|
||||
{
|
||||
ClientSurname = client.Item1.ClientSurname,
|
||||
ClientName = client.Item1.ClientName,
|
||||
ClientPatronymic = client.Item1.ClientPatronymic,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
}
|
||||
|
||||
HashSet<int> used = new();
|
||||
foreach (var deposit in client.Item2)
|
||||
{
|
||||
foreach (var currency in deposit.Item2)
|
||||
{
|
||||
if (used.Contains(currency.Id))
|
||||
continue;
|
||||
|
||||
dict[client.Item1.WorkerId].Currencies.Add(currency);
|
||||
used.Add(currency.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var kvp in dict)
|
||||
{
|
||||
ans.Add(kvp.Value);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
public void SaveClientsToPdfFile(CurrenciesRefillsBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список клиентов",
|
||||
DateFrom = model.DateFrom!,
|
||||
DateTo = model.DateTo!,
|
||||
Clients = GetClientCurrenciesAndRefills(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -124,18 +124,18 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
"Отсутствует почта работника",
|
||||
nameof(model.Email));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PasswordHash))
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует пароль работника",
|
||||
nameof(model.PasswordHash));
|
||||
nameof(model.Password));
|
||||
}
|
||||
_logger.LogInformation("Worker. Id: {Id}. WorkerFullname: " +
|
||||
"{WorkerSurname} {WorkerName} {WorkerPatronymic}. Phone: " +
|
||||
"{Phone}. Email: {Email}. PasswordHash: {PasswordHash}.",
|
||||
"{Phone}. Email: {Email}. Password: {Password}.",
|
||||
model.Id, model.WorkerSurname, model.WorkerName,
|
||||
model.WorkerPatronymic, model.Phone, model.Email,
|
||||
model.PasswordHash);
|
||||
model.Password);
|
||||
var elementByEmail = _workerStorage.GetElement(
|
||||
new WorkerSearchModel
|
||||
{
|
||||
|
82
Bank/BankBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
82
Bank/BankBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
namespace BankBusinessLogic.MailWorker
|
||||
{
|
||||
public abstract class AbstractMailWorker
|
||||
{
|
||||
protected string _mailLogin = string.Empty;
|
||||
protected string _mailPassword = string.Empty;
|
||||
protected string _smtpClientHost = string.Empty;
|
||||
protected int _smtpClientPort;
|
||||
protected string _popHost = string.Empty;
|
||||
protected int _popPort;
|
||||
private readonly IMessageInfoLogic _messageInfoLogic;
|
||||
private readonly ILogger _logger;
|
||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger,
|
||||
IMessageInfoLogic messageInfoLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_messageInfoLogic = messageInfoLogic;
|
||||
}
|
||||
public void MailConfig(MailConfigBindingModel config)
|
||||
{
|
||||
_mailLogin = config.MailLogin;
|
||||
_mailPassword = config.MailPassword;
|
||||
_smtpClientHost = config.SmtpClientHost;
|
||||
_smtpClientPort = config.SmtpClientPort;
|
||||
_popHost = config.PopHost;
|
||||
_popPort = config.PopPort;
|
||||
_logger.LogDebug("Config: {login}, {password}, " +
|
||||
"{clientHost}, { clientPOrt}, { popHost}, { popPort}",
|
||||
_mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort,
|
||||
_popHost, _popPort);
|
||||
}
|
||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) ||
|
||||
string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(info.MailAddress) ||
|
||||
string.IsNullOrEmpty(info.Subject) ||
|
||||
string.IsNullOrEmpty(info.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress,
|
||||
info.Subject);
|
||||
await SendMailAsync(info);
|
||||
}
|
||||
public async void MailCheck()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) ||
|
||||
string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_messageInfoLogic == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var list = await ReceiveMailAsync();
|
||||
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
||||
foreach (var mail in list)
|
||||
{
|
||||
_messageInfoLogic.Create(mail);
|
||||
}
|
||||
}
|
||||
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
||||
protected abstract Task<List<MessageInfoBindingModel>>
|
||||
ReceiveMailAsync();
|
||||
}
|
||||
}
|
81
Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
81
Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using MailKit.Net.Pop3;
|
||||
using MailKit.Security;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
namespace BankBusinessLogic.MailWorker
|
||||
{
|
||||
public class MailKitWorker : AbstractMailWorker
|
||||
{
|
||||
public MailKitWorker(ILogger<MailKitWorker> logger,
|
||||
IMessageInfoLogic messageInfoLogic) :
|
||||
base(logger, messageInfoLogic) { }
|
||||
protected override async Task SendMailAsync(
|
||||
MailSendInfoBindingModel info)
|
||||
{
|
||||
using var objMailMessage = new MailMessage();
|
||||
using var objSmtpClient = new SmtpClient(_smtpClientHost,
|
||||
_smtpClientPort);
|
||||
try
|
||||
{
|
||||
objMailMessage.From = new MailAddress(_mailLogin);
|
||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||
objMailMessage.Subject = info.Subject;
|
||||
objMailMessage.Body = info.Text;
|
||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||
objSmtpClient.UseDefaultCredentials = false;
|
||||
objSmtpClient.EnableSsl = true;
|
||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin,
|
||||
_mailPassword);
|
||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
protected override async Task<List<MessageInfoBindingModel>>
|
||||
ReceiveMailAsync()
|
||||
{
|
||||
var list = new List<MessageInfoBindingModel>();
|
||||
using var client = new Pop3Client();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Connect(_popHost, _popPort,
|
||||
SecureSocketOptions.SslOnConnect);
|
||||
client.Authenticate(_mailLogin, _mailPassword);
|
||||
for (int i = 0; i < client.Count; i++)
|
||||
{
|
||||
var message = client.GetMessage(i);
|
||||
foreach (var mail in message.From.Mailboxes)
|
||||
{
|
||||
list.Add(new MessageInfoBindingModel
|
||||
{
|
||||
DateDelivery = message.Date.DateTime,
|
||||
MessageId = message.MessageId,
|
||||
SenderName = mail.Address,
|
||||
Subject = message.Subject,
|
||||
Body = message.TextBody
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{ }
|
||||
finally
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
67
Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
Normal file
67
Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcel
|
||||
{
|
||||
public void CreateReport(ExcelInfo info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
|
||||
MergeCells(new ExcelMergeParameters
|
||||
{
|
||||
CellFromName = "A1",
|
||||
CellToName = "C1"
|
||||
});
|
||||
|
||||
uint rowIndex = 2;
|
||||
|
||||
foreach (var rec in info.DepositsPrograms)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = rec.DepositId.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
|
||||
foreach (var service in rec.Programs)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = service.ProgramName,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
protected abstract void CreateExcel(ExcelInfo info);
|
||||
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
|
||||
protected abstract void SaveExcel(ExcelInfo info);
|
||||
}
|
||||
}
|
65
Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
65
Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
namespace BankBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdf
|
||||
{
|
||||
public void CreateDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "4cm", "4cm", "4cm", "4cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Дата", "Клиент", "Пополнения", "Валюты" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var client in info.Clients)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { client.ClientSurname, client.ClientName, client.ClientPatronymic, "", "" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var refill in client.Refills)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { refill.RefillDate.ToString(), "", refill.DepositId.ToString(), "" },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
}
|
||||
foreach (var currency in client.Currencies)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "", "", "", currency.CurrencyName },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
}
|
||||
}
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
55
Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs
Normal file
55
Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
namespace BankBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToWord
|
||||
{
|
||||
public void CreateDoc(WordInfo info)
|
||||
{
|
||||
CreateWord(info);
|
||||
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var rec in info.DepositsPrograms)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (rec.DepositId.ToString(), new WordTextProperties { Size = "24", Bold=true})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var program in rec.Programs)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (program.ProgramName, new WordTextProperties { Size = "20", Bold=false})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
protected abstract void CreateWord(WordInfo info);
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
protected abstract void SaveWord(WordInfo info);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
Title,
|
||||
Text,
|
||||
TextWithBroder
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum WordJustificationType
|
||||
{
|
||||
Center,
|
||||
Both
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelCellParameters
|
||||
{
|
||||
public string ColumnName { get; set; } = string.Empty;
|
||||
public uint RowIndex { get; set; }
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using BankContracts.ViewModels;
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ListProgramsViewModel> DepositsPrograms
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelMergeParameters
|
||||
{
|
||||
public string CellFromName { get; set; } = string.Empty;
|
||||
public string CellToName { get; set; } = string.Empty;
|
||||
public string Merge => $"{CellFromName}:{CellToName}";
|
||||
}
|
||||
}
|
12
Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
Normal file
12
Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using BankContracts.ViewModels;
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public DateTime DateFrom { get; set; }
|
||||
public DateTime DateTo { get; set; }
|
||||
public List<CurrenciesRefillsViewModel> Clients { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfParagraph
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using BankContracts.ViewModels;
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ListProgramsViewModel> DepositsPrograms { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordParagraph
|
||||
{
|
||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||
public WordTextProperties? TextProperties { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTextProperties
|
||||
{
|
||||
public string Size { get; set; } = string.Empty;
|
||||
public bool Bold { get; set; }
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
327
Bank/BankBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
Normal file
327
Bank/BankBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
Normal file
@ -0,0 +1,327 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
namespace BankBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToExcel : AbstractSaveToExcel
|
||||
{
|
||||
private SpreadsheetDocument? _spreadsheetDocument;
|
||||
private SharedStringTablePart? _shareStringPart;
|
||||
private Worksheet? _worksheet;
|
||||
|
||||
private static void CreateStyles(WorkbookPart workbookpart)
|
||||
{
|
||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||
sp.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||
|
||||
var fontUsual = new Font();
|
||||
fontUsual.Append(new FontSize() { Val = 12D });
|
||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
var fontTitle = new Font();
|
||||
fontTitle.Append(new Bold());
|
||||
fontTitle.Append(new FontSize() { Val = 14D });
|
||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
fonts.Append(fontUsual);
|
||||
fonts.Append(fontTitle);
|
||||
|
||||
var fills = new Fills() { Count = 2U };
|
||||
|
||||
var fill1 = new Fill();
|
||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
|
||||
var fill2 = new Fill();
|
||||
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||
|
||||
fills.Append(fill1);
|
||||
fills.Append(fill2);
|
||||
|
||||
var borders = new Borders() { Count = 2U };
|
||||
|
||||
var borderNoBorder = new Border();
|
||||
borderNoBorder.Append(new LeftBorder());
|
||||
borderNoBorder.Append(new RightBorder());
|
||||
borderNoBorder.Append(new TopBorder());
|
||||
borderNoBorder.Append(new BottomBorder());
|
||||
borderNoBorder.Append(new DiagonalBorder());
|
||||
|
||||
var borderThin = new Border();
|
||||
|
||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
borderThin.Append(leftBorder);
|
||||
borderThin.Append(rightBorder);
|
||||
borderThin.Append(topBorder);
|
||||
borderThin.Append(bottomBorder);
|
||||
borderThin.Append(new DiagonalBorder());
|
||||
|
||||
borders.Append(borderNoBorder);
|
||||
borders.Append(borderThin);
|
||||
|
||||
var cellStyleFormats = new CellStyleFormats()
|
||||
{
|
||||
Count = 1U
|
||||
};
|
||||
var cellFormatStyle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U
|
||||
};
|
||||
|
||||
cellStyleFormats.Append(cellFormatStyle);
|
||||
|
||||
var cellFormats = new CellFormats()
|
||||
{
|
||||
Count = 3U
|
||||
};
|
||||
var cellFormatFont = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true
|
||||
};
|
||||
var cellFormatFontAndBorder = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 1U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true,
|
||||
ApplyBorder = true
|
||||
};
|
||||
var cellFormatTitle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 1U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true,
|
||||
Horizontal = HorizontalAlignmentValues.Center
|
||||
},
|
||||
ApplyFont = true
|
||||
};
|
||||
cellFormats.Append(cellFormatFont);
|
||||
cellFormats.Append(cellFormatFontAndBorder);
|
||||
cellFormats.Append(cellFormatTitle);
|
||||
var cellStyles = new CellStyles() { Count = 1U };
|
||||
cellStyles.Append(new CellStyle()
|
||||
{
|
||||
Name = "Normal",
|
||||
FormatId = 0U,
|
||||
BuiltinId = 0U
|
||||
});
|
||||
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
||||
{
|
||||
Count = 0U
|
||||
};
|
||||
|
||||
var tableStyles = new TableStyles()
|
||||
{
|
||||
Count = 0U,
|
||||
DefaultTableStyle = "TableStyleMedium2",
|
||||
DefaultPivotStyle = "PivotStyleLight16"
|
||||
};
|
||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||
var stylesheetExtension1 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
||||
};
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles()
|
||||
{
|
||||
DefaultSlicerStyle = "SlicerStyleLight1"
|
||||
});
|
||||
var stylesheetExtension2 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
||||
};
|
||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
stylesheetExtension2.Append(new TimelineStyles()
|
||||
{
|
||||
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
||||
});
|
||||
|
||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||
|
||||
sp.Stylesheet.Append(fonts);
|
||||
sp.Stylesheet.Append(fills);
|
||||
sp.Stylesheet.Append(borders);
|
||||
sp.Stylesheet.Append(cellStyleFormats);
|
||||
sp.Stylesheet.Append(cellFormats);
|
||||
sp.Stylesheet.Append(cellStyles);
|
||||
sp.Stylesheet.Append(differentialFormats);
|
||||
sp.Stylesheet.Append(tableStyles);
|
||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||
}
|
||||
|
||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||
{
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void CreateExcel(ExcelInfo info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook();
|
||||
CreateStyles(workbookpart);
|
||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any() ? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First() : _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
|
||||
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
_worksheet = worksheetPart.Worksheet;
|
||||
}
|
||||
|
||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null || _shareStringPart == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||
|
||||
if (sheetData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Row row;
|
||||
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||
{
|
||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||
sheetData.Append(row);
|
||||
}
|
||||
|
||||
Cell cell;
|
||||
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
||||
{
|
||||
refCell = rowCell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var newCell = new Cell()
|
||||
{
|
||||
CellReference = excelParams.CellReference
|
||||
};
|
||||
row.InsertBefore(newCell, refCell);
|
||||
cell = newCell;
|
||||
}
|
||||
|
||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||
_shareStringPart.SharedStringTable.Save();
|
||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||
}
|
||||
|
||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells mergeCells;
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
var mergeCell = new MergeCell()
|
||||
{
|
||||
Reference = new StringValue(excelParams.Merge)
|
||||
};
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
|
||||
protected override void SaveExcel(ExcelInfo info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||
_spreadsheetDocument.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
100
Bank/BankBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
100
Bank/BankBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
namespace BankBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdf : AbstractSaveToPdf
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
private static ParagraphAlignment
|
||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment =
|
||||
GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
111
Bank/BankBusinessLogic/OfficePackage/Implements/SaveToWord.cs
Normal file
111
Bank/BankBusinessLogic/OfficePackage/Implements/SaveToWord.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
namespace BankBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWord : AbstractSaveToWord
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
private Body? _docBody;
|
||||
private static JustificationValues
|
||||
GetJustificationValues(WordJustificationType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center,
|
||||
_ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var properties = new SectionProperties();
|
||||
var pageSize = new PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
properties.AppendChild(pageSize);
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static ParagraphProperties?
|
||||
CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var properties = new ParagraphProperties();
|
||||
properties.AppendChild(new Justification()
|
||||
{
|
||||
Val =
|
||||
GetJustificationValues(paragraphProperties.JustificationType)
|
||||
});
|
||||
properties.AppendChild(new SpacingBetweenLines
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
properties.AppendChild(new Indentation());
|
||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
||||
{
|
||||
Val =
|
||||
paragraphProperties.Size
|
||||
});
|
||||
}
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
return properties;
|
||||
}
|
||||
protected override void CreateWord(WordInfo info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName,
|
||||
WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
protected override void CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (_docBody == null || paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
var docRun = new Run();
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
if (run.Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
docRun.AppendChild(properties);
|
||||
docRun.AppendChild(new Text
|
||||
{
|
||||
Text = run.Item1,
|
||||
Space =
|
||||
SpaceProcessingModeValues.Preserve
|
||||
});
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
_docBody.AppendChild(docParagraph);
|
||||
}
|
||||
protected override void SaveWord(WordInfo info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ namespace BankContracts.BindingModels
|
||||
public string ClientPatronymic { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string? Email { get; set; } = string.Empty;
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int WorkerId { get; set; }
|
||||
public Dictionary<int, IProgramModel>
|
||||
ClientPrograms { get; set; } = new();
|
||||
|
@ -0,0 +1,12 @@
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class CurrenciesRefillsBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<int> Clients { get; set; } = new();
|
||||
public DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
public DateTime DateTo { get; set; } = DateTime.Now;
|
||||
public int? WorkerId { get; set; }
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
}
|
@ -11,5 +11,7 @@ namespace BankContracts.BindingModels
|
||||
DateOnly.FromDateTime(DateTime.Now);
|
||||
public Dictionary<int, ICurrencyModel>
|
||||
DepositCurrencies { get; set; } = new();
|
||||
public Dictionary<string, IClientModel>
|
||||
ClientDeposit { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ListProgramsBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<int> Deposits { get; set; } = new();
|
||||
}
|
||||
}
|
12
Bank/BankContracts/BindingModels/MailConfigBindingModel.cs
Normal file
12
Bank/BankContracts/BindingModels/MailConfigBindingModel.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class MailConfigBindingModel
|
||||
{
|
||||
public string MailLogin { get; set; } = string.Empty;
|
||||
public string MailPassword { get; set; } = string.Empty;
|
||||
public string SmtpClientHost { get; set; } = string.Empty;
|
||||
public int SmtpClientPort { get; set; }
|
||||
public string PopHost { get; set; } = string.Empty;
|
||||
public int PopPort { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class MailSendInfoBindingModel
|
||||
{
|
||||
public string MailAddress { get; set; } = string.Empty;
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Text { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
13
Bank/BankContracts/BindingModels/MessageInfoBindingModel.cs
Normal file
13
Bank/BankContracts/BindingModels/MessageInfoBindingModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using BankDataModels.Models;
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class MessageInfoBindingModel : IMessageInfoModel
|
||||
{
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
public int? WorkerId { get; set; }
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Body { get; set; } = string.Empty;
|
||||
public DateTime DateDelivery { get; set; }
|
||||
}
|
||||
}
|
@ -10,6 +10,6 @@ namespace BankContracts.BindingModels
|
||||
public string WorkerPatronymic { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankContracts.SearchModels;
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IMessageInfoLogic
|
||||
{
|
||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||
bool Create(MessageInfoBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogicWorker
|
||||
{
|
||||
List<ListProgramsViewModel> GetDepositPrograms(List<int> deposits);
|
||||
void SaveProgramsToWordFile(ListProgramsBindingModel model);
|
||||
void SaveProgramsToExcelFile(ListProgramsBindingModel model);
|
||||
List<CurrenciesRefillsViewModel> GetClientCurrenciesAndRefills(CurrenciesRefillsBindingModel clients);
|
||||
void SaveClientsToPdfFile(CurrenciesRefillsBindingModel model);
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
public string? ClientPatronymic { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? PasswordHash { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public int? WorkerId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class CurrenciesRefillsSearchModel
|
||||
{
|
||||
public List<int>? ClientsSnilses { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? WorkerId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class ListProgramsSearchModel
|
||||
{
|
||||
public List<int>? depositsIds { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace ConfectioneryContracts.SearchModels
|
||||
{
|
||||
public class MessageInfoSearchModel
|
||||
{
|
||||
public int? WorkerId { get; set; }
|
||||
public string? MessageId { get; set; }
|
||||
}
|
||||
}
|
@ -8,5 +8,6 @@
|
||||
public string? WorkerPatronymic { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,9 @@ namespace BankContracts.StoragesContracts
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
public List<Tuple<ClientViewModel, List<Tuple<DepositViewModel, List<RefillViewModel>>>>> GetRefillsInfo(CurrenciesRefillsSearchModel model);
|
||||
public List<Tuple<ClientViewModel, List<Tuple<DepositViewModel, List<CurrencyViewModel>>>>> GetCurrenciesInfo(CurrenciesRefillsSearchModel model);
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
|
@ -8,7 +8,8 @@ namespace BankContracts.StoragesContracts
|
||||
{
|
||||
List<DepositViewModel> GetFullList();
|
||||
List<DepositViewModel> GetFilteredList(DepositSearchModel model);
|
||||
DepositViewModel? GetElement(DepositSearchModel model);
|
||||
List<Tuple<DepositViewModel, List<Tuple<CurrencyViewModel, List<ProgramViewModel>>>>> GetReportInfo(ListProgramsSearchModel model);
|
||||
DepositViewModel? GetElement(DepositSearchModel model);
|
||||
DepositViewModel? Insert(DepositBindingModel model);
|
||||
DepositViewModel? Update(DepositBindingModel model);
|
||||
DepositViewModel? Delete(DepositBindingModel model);
|
||||
|
@ -20,7 +20,7 @@ namespace BankContracts.ViewModels
|
||||
[DisplayName("Идентификатор работника")]
|
||||
public int WorkerId { get; set; }
|
||||
[DisplayName("Хэш пароля")]
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public Dictionary<int, IProgramModel>
|
||||
ClientPrograms { get; set; } = new();
|
||||
public Dictionary<int, IDepositModel>
|
||||
|
13
Bank/BankContracts/ViewModels/CurrenciesRefillsViewModel.cs
Normal file
13
Bank/BankContracts/ViewModels/CurrenciesRefillsViewModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class CurrenciesRefillsViewModel
|
||||
{
|
||||
public string ClientSurname { get; set; } = string.Empty;
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
public string ClientPatronymic { get; set; } = string.Empty;
|
||||
public List<CurrencyViewModel> Currencies { get; set; } = new();
|
||||
public List<RefillViewModel> Refills { get; set; } = new();
|
||||
public DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
public DateTime DateTo { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
@ -16,5 +16,7 @@ namespace BankContracts.ViewModels
|
||||
DateOnly.FromDateTime(DateTime.Now);
|
||||
public Dictionary<int, ICurrencyModel>
|
||||
DepositCurrencies { get; set; } = new();
|
||||
public Dictionary<int, IClientModel>
|
||||
ClientDeposits { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
8
Bank/BankContracts/ViewModels/ListProgramsViewModel.cs
Normal file
8
Bank/BankContracts/ViewModels/ListProgramsViewModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ListProgramsViewModel
|
||||
{
|
||||
public int DepositId { get; set; }
|
||||
public List<ProgramViewModel> Programs { get; set; } = new();
|
||||
}
|
||||
}
|
17
Bank/BankContracts/ViewModels/MessageInfoViewModel.cs
Normal file
17
Bank/BankContracts/ViewModels/MessageInfoViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.ComponentModel;
|
||||
namespace ConfectioneryContracts.ViewModels
|
||||
{
|
||||
public class MessageInfoViewModel
|
||||
{
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
public int? WorkerId { get; set; }
|
||||
[DisplayName("Отправитель")]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
[DisplayName("Дата письма")]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
[DisplayName("Заголовок")]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
[DisplayName("Текст")]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -18,6 +18,6 @@ namespace BankContracts.ViewModels
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Хэш пароля")]
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
string ClientPatronymic { get; }
|
||||
string Phone { get; }
|
||||
string? Email { get; }
|
||||
string PasswordHash { get; }
|
||||
string Password { get; }
|
||||
int WorkerId { get; }
|
||||
}
|
||||
}
|
||||
|
12
Bank/BankDataModels/Models/IMessageInfoModel.cs
Normal file
12
Bank/BankDataModels/Models/IMessageInfoModel.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace BankDataModels.Models
|
||||
{
|
||||
public interface IMessageInfoModel
|
||||
{
|
||||
string MessageId { get; }
|
||||
int? WorkerId { get; }
|
||||
string SenderName { get; }
|
||||
DateTime DateDelivery { get; }
|
||||
string Subject { get; }
|
||||
string Body { get; }
|
||||
}
|
||||
}
|
@ -7,6 +7,6 @@
|
||||
string WorkerPatronymic { get; }
|
||||
string Phone { get; }
|
||||
string Email { get; }
|
||||
string PasswordHash { get; }
|
||||
string Password { get; }
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@ -250,7 +250,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
|
@ -50,7 +50,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
WorkerPatronymic = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Phone = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -114,7 +114,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
ClientPatronymic = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Phone = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
WorkerId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
|
@ -43,7 +43,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@ -247,7 +247,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace BankDatabaseImplement.Models
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int WorkerId { get; set; }
|
||||
public virtual Worker Worker { get; set; } = null!;
|
||||
@ -68,7 +68,7 @@ namespace BankDatabaseImplement.Models
|
||||
ClientPatronymic = model.ClientPatronymic,
|
||||
Phone = model.Phone,
|
||||
Email = model.Email ?? string.Empty,
|
||||
PasswordHash = model.PasswordHash,
|
||||
Password = model.Password,
|
||||
WorkerId = model.WorkerId,
|
||||
};
|
||||
}
|
||||
@ -82,7 +82,7 @@ namespace BankDatabaseImplement.Models
|
||||
ClientPatronymic = model.ClientPatronymic;
|
||||
Phone = model.Phone;
|
||||
Email = model.Email ?? string.Empty;
|
||||
PasswordHash = model.PasswordHash;
|
||||
Password = model.Password;
|
||||
WorkerId = model.WorkerId;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
@ -93,7 +93,7 @@ namespace BankDatabaseImplement.Models
|
||||
ClientPatronymic = ClientPatronymic,
|
||||
Phone = Phone,
|
||||
Email = Email ?? string.Empty,
|
||||
PasswordHash = PasswordHash,
|
||||
Password = Password,
|
||||
WorkerId = WorkerId,
|
||||
};
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace BankDatabaseImplement.Models
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public List<Deposit> Deposits { get; set; } = null!;
|
||||
public List<Refill> Refills { get; set; } = null!;
|
||||
public static Worker? Create(WorkerBindingModel model)
|
||||
@ -35,7 +35,7 @@ namespace BankDatabaseImplement.Models
|
||||
WorkerPatronymic = model.WorkerPatronymic,
|
||||
Phone = model.Phone,
|
||||
Email = model.Email ?? string.Empty,
|
||||
PasswordHash = model.PasswordHash,
|
||||
Password = model.Password,
|
||||
};
|
||||
}
|
||||
public void Update(WorkerBindingModel model)
|
||||
@ -48,7 +48,7 @@ namespace BankDatabaseImplement.Models
|
||||
WorkerPatronymic = model.WorkerPatronymic;
|
||||
Phone = model.Phone;
|
||||
Email = model.Email ?? string.Empty;
|
||||
PasswordHash = model.PasswordHash;
|
||||
Password = model.Password;
|
||||
}
|
||||
public WorkerViewModel GetViewModel => new()
|
||||
{
|
||||
@ -58,7 +58,7 @@ namespace BankDatabaseImplement.Models
|
||||
WorkerPatronymic = WorkerPatronymic,
|
||||
Phone = Phone,
|
||||
Email = Email ?? string.Empty,
|
||||
PasswordHash = PasswordHash,
|
||||
Password = Password,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
using BankContracts.BindingModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
{
|
||||
@ -12,19 +13,44 @@ namespace BankRestApi.Controllers
|
||||
public class ClientController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientLogic _logic;
|
||||
public ClientController(ILogger<ClientController> logger,
|
||||
IClientLogic logic)
|
||||
private readonly IClientLogic client;
|
||||
public ClientController(ILogger<ClientController> logger, IClientLogic visit)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
client = visit;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ClientViewModel>? GetClientList()
|
||||
public Tuple<ClientViewModel, List<Tuple<string, int>>>? GetClient(string ClientSnils)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
var elem = client.ReadElement(new ClientSearchModel { Snils = ClientSnils });
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.ClientPrograms.Select(x => Tuple.Create(x.Value.ProgramName, x.Value.Id)).ToList());
|
||||
res.Item1.ClientPrograms = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения клиента по id={Id}", ClientSnils);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ClientViewModel> GetClients(int? workerId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ClientViewModel> res;
|
||||
if (!workerId.HasValue)
|
||||
res = client.ReadList(null);
|
||||
else
|
||||
res = client.ReadList(new ClientSearchModel { WorkerId = workerId });
|
||||
foreach (var client in res)
|
||||
client.ClientPrograms = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -32,56 +58,40 @@ namespace BankRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public ClientViewModel? GetClient(string ClientSnils)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Snils = ClientSnils
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения клиента по Snils={Snils}",
|
||||
ClientSnils);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateClient(ClientBindingModel model)
|
||||
public bool CreateClient(ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
return client.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания клиента");
|
||||
_logger.LogError(ex, "Не удалось создать клиента");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public void UpdateClient(ClientBindingModel model)
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateClient(bool isConnection, ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
return client.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления клиента");
|
||||
_logger.LogError(ex, "Не удалось обновить клиента");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteClient(ClientBindingModel model)
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteClient(ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
return client.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,94 +0,0 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class CurrencyController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICurrencyLogic _logic;
|
||||
public CurrencyController(ILogger<CurrencyController> logger,
|
||||
ICurrencyLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CurrencyViewModel>? GetCurrencyList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка валют");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public CurrencyViewModel? GetCurrency(int CurrencyId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new CurrencySearchModel
|
||||
{
|
||||
Id = CurrencyId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения валюты по Id={Id}",
|
||||
CurrencyId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateCurrency(CurrencyBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания валюты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public void UpdateCurrency(CurrencyBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления валюты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteCurrency(CurrencyBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления валюты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
using BankContracts.BindingModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
{
|
||||
@ -12,20 +13,45 @@ namespace BankRestApi.Controllers
|
||||
public class DepositController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDepositLogic _logic;
|
||||
public DepositController(ILogger<DepositController> logger,
|
||||
IDepositLogic logic)
|
||||
private readonly IDepositLogic _deposit;
|
||||
public DepositController(ILogger<DepositController> logger, IDepositLogic deposit)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_deposit = deposit;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<DepositViewModel>? GetDepositList()
|
||||
public Tuple<DepositViewModel, List<Tuple<string, string>>>? GetDeposit(int depositId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
var elem = _deposit.ReadElement(new DepositSearchModel { Id = depositId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.ClientDeposits.Select(x => Tuple.Create(x.Value.ClientSurname, x.Value.Snils)).ToList());
|
||||
res.Item1.ClientDeposits = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения вклада по id={Id}", depositId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<DepositViewModel>? GetDepositList(int? workerId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<DepositViewModel> res;
|
||||
if (!workerId.HasValue)
|
||||
res = _deposit.ReadList(null);
|
||||
else
|
||||
res = _deposit.ReadList(new DepositSearchModel { WorkerId = workerId });
|
||||
foreach (var deposit in res)
|
||||
deposit.ClientDeposits = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -33,56 +59,42 @@ namespace BankRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public DepositViewModel? GetDeposit(int DepositId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new DepositSearchModel
|
||||
{
|
||||
Id = DepositId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения вклада по Id={Id}",
|
||||
DepositId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateDeposit(DepositBindingModel model)
|
||||
public bool CreateDeposit(DepositBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
return _deposit.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания вклада");
|
||||
_logger.LogError(ex, "Не удалось создать вклад");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public void UpdateDeposit(DepositBindingModel model)
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateDeposit(bool isConnection, DepositBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
if (!isConnection)
|
||||
model.ClientDeposit = null!;
|
||||
return _deposit.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления вклада");
|
||||
_logger.LogError(ex, "Не удалось обновить вклад");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteDeposit(DepositBindingModel model)
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteDeposit(DepositBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
return _deposit.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -91,4 +103,4 @@ namespace BankRestApi.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,95 +0,0 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ProgramController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProgramLogic _logic;
|
||||
public ProgramController(ILogger<ProgramController> logger,
|
||||
IProgramLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ProgramViewModel>? GetProgramList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения списка кредитных программ");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public ProgramViewModel? GetProgram(int ProgramId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ProgramSearchModel
|
||||
{
|
||||
Id = ProgramId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения кредитной программы по Id={Id}",
|
||||
ProgramId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateProgram(ProgramBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания кредитной программы");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public void UpdateProgram(ProgramBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления кредитной программы");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteProgram(ProgramBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления кредитной программы");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
using BankContracts.BindingModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
{
|
||||
@ -12,83 +13,87 @@ namespace BankRestApi.Controllers
|
||||
public class RefillController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRefillLogic _logic;
|
||||
public RefillController(ILogger<RefillController> logger,
|
||||
IRefillLogic logic)
|
||||
private readonly IRefillLogic _refill;
|
||||
|
||||
public RefillController(ILogger<RefillController> logger, IRefillLogic refill)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_refill = refill;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<RefillViewModel>? GetRefillList()
|
||||
public RefillViewModel GetRefill(int refillId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
var elem = _refill.ReadElement(new RefillSearchModel { Id = refillId });
|
||||
return elem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка пополнений");
|
||||
_logger.LogError(ex, "Ошибка получения поплнения по id={Id}", refillId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public RefillViewModel? GetRefill(int RefillId)
|
||||
public List<RefillViewModel>? GetRefills(int? workerld)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new RefillSearchModel
|
||||
if (!workerld.HasValue)
|
||||
return _refill.ReadList(null);
|
||||
return _refill.ReadList(new RefillSearchModel
|
||||
{
|
||||
Id = RefillId
|
||||
WorkerId = workerld
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения пополнения по Id={Id}",
|
||||
RefillId);
|
||||
_logger.LogError(ex, "Ошибка получения списка пополнений пользователя id ={ Id}", workerld);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateRefill(RefillBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
_refill.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания пополнения");
|
||||
_logger.LogError(ex, "Ошибка создания прививки");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public void UpdateRefill(RefillBindingModel model)
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateRefill(RefillBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
return _refill.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления пополнения");
|
||||
_logger.LogError(ex, "Не удалось обновить привику");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteRefill(RefillBindingModel model)
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteRefill(RefillBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
return _refill.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления пополнения");
|
||||
_logger.LogError(ex, "Ошибка удаления привики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class TermController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITermLogic _logic;
|
||||
public TermController(ILogger<TermController> logger,
|
||||
ITermLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<TermViewModel>? GetTermList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка сроков");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public TermViewModel? GetTerm(int TermId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new TermSearchModel
|
||||
{
|
||||
Id = TermId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения срока по Id={Id}",
|
||||
TermId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateTerm(TermBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания срока");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public void UpdateTerm(TermBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления срока");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteTerm(TermBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления срока");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
@ -12,47 +11,35 @@ namespace BankRestApi.Controllers
|
||||
public class WorkerController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IWorkerLogic _logic;
|
||||
public WorkerController(ILogger<WorkerController> logger,
|
||||
IWorkerLogic logic)
|
||||
|
||||
public WorkerController(IWorkerLogic logic, ILogger<WorkerController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<WorkerViewModel>? GetWorkerList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка работников");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public WorkerViewModel? GetWorker(int WorkerId)
|
||||
public WorkerViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new WorkerSearchModel
|
||||
{
|
||||
Id = WorkerId
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex, "Ошибка получения работника по Id={Id}",
|
||||
WorkerId);
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateWorker(WorkerBindingModel model)
|
||||
public void Register(WorkerBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -60,12 +47,13 @@ namespace BankRestApi.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания работника");
|
||||
_logger.LogError(ex, "Ошибка регистрации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public void UpdateWorker(WorkerBindingModel model)
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateData(WorkerBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -73,22 +61,9 @@ namespace BankRestApi.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления работника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteWorker(WorkerBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления работника");
|
||||
_logger.LogError(ex, "Ошибка обновления данных");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using BankBusinessLogic.BusinessLogics;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.BindingModels;
|
||||
using BankDatabaseImplement.Implements;
|
||||
using BankBusinessLogic.MailWorker;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using NLog.Extensions.Logging;
|
||||
|
||||
@ -39,11 +41,26 @@ builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo {
|
||||
Title = "VetClinicRestApi",
|
||||
Title = "BankRestApi",
|
||||
Version = "v1" });
|
||||
});
|
||||
var app = builder.Build();
|
||||
|
||||
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = builder.Configuration?.GetSection("MailLogin")?
|
||||
.Value?.ToString() ?? string.Empty,
|
||||
MailPassword = builder.Configuration?.GetSection("MailPassword")?
|
||||
.Value?.ToString() ?? string.Empty,
|
||||
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?
|
||||
.Value?.ToString() ?? string.Empty,
|
||||
SmtpClientPort = Convert.ToInt32(builder.Configuration?
|
||||
.GetSection("SmtpClientPort")?.Value?.ToString()),
|
||||
PopHost = builder.Configuration?.GetSection("PopHost")?
|
||||
.Value?.ToString() ?? string.Empty,
|
||||
PopPort = Convert.ToInt32(builder.Configuration?
|
||||
.GetSection("PopPort")?.Value?.ToString())
|
||||
});
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:27552",
|
||||
"sslPort": 44383
|
||||
"applicationUrl": "http://localhost:57742",
|
||||
"sslPort": 44328
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
@ -14,7 +14,7 @@
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7177;http://localhost:5116",
|
||||
"applicationUrl": "https://localhost:7268;http://localhost:5041",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
@ -5,5 +5,12 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
"AllowedHosts": "*",
|
||||
"SmtpClientHost": "smtp.gmail.com",
|
||||
"SmtpClientPort": "587",
|
||||
"PopHost": "pop.gmail.com",
|
||||
"PopPort": "995",
|
||||
|
||||
"MailLogin": "confectionerypibd23@gmail.com",
|
||||
"MailPassword": "mgsy zvpt cmva kyur"
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using BankContracts.ViewModels;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace BankWorkerApp
|
||||
{
|
||||
public static class APIClient
|
||||
{
|
||||
private static readonly HttpClient _worker = new();
|
||||
public static WorkerViewModel? Worker { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_worker.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_worker.DefaultRequestHeaders.Accept.Clear();
|
||||
_worker.DefaultRequestHeaders.Accept.Add(new
|
||||
MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
}
|
||||
}
|
51
Bank/BankWorkerApp/APIWorker.cs
Normal file
51
Bank/BankWorkerApp/APIWorker.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using BankContracts.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace BankWorkerApp
|
||||
{
|
||||
public static class APIWorker
|
||||
{
|
||||
private static readonly HttpClient _worker = new();
|
||||
|
||||
public static WorkerViewModel? Worker { get; set; } = null;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_worker.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_worker.DefaultRequestHeaders.Accept.Clear();
|
||||
_worker.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _worker.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = _worker.PostAsync(requestUrl, data);
|
||||
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,7 +1,14 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BankWorkerApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankWorkerApp.Models;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using BankDataModels.Models;
|
||||
using BankContracts.SearchModels;
|
||||
using Azure;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
namespace BankWorkerApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
@ -11,33 +18,754 @@ namespace BankWorkerApp.Controllers
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ProgramListReport()
|
||||
{
|
||||
ViewBag.Deposits = APIWorker.GetRequest<List<DepositViewModel>>($"api/deposit/getdepositlist?workerid={APIWorker.Worker.Id}");
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
{
|
||||
ViewBag.Report = new List<CurrenciesRefillsBindingModel>();
|
||||
return View();
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIClient.Worker == null)
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
return View(APIWorker.GetRequest<List<ClientViewModel>>($"api/client/getclients?workerId={APIWorker.Worker.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexDeposits()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIWorker.GetRequest<List<DepositViewModel>>($"api/deposit/getdepositlist?workerId={APIWorker.Worker.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexRefills()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIWorker.GetRequest<List<RefillViewModel>>($"api/refill/getrefills?workerId={APIWorker.Worker.Id}"));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (APIClient.Worker == null)
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
return View(APIWorker.Worker);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Privacy(string login, string password, string workerSurname, string workerName, string workerPatronymic, string phone)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(workerSurname) ||
|
||||
string.IsNullOrEmpty(workerName) || string.IsNullOrEmpty(workerPatronymic) ||
|
||||
string.IsNullOrEmpty(phone))
|
||||
{
|
||||
throw new Exception("Не все данные введены");
|
||||
}
|
||||
APIWorker.PostRequest("api/worker/updatedata",
|
||||
new WorkerBindingModel
|
||||
{
|
||||
Id = APIWorker.Worker.Id,
|
||||
WorkerSurname = workerSurname,
|
||||
WorkerName = workerName,
|
||||
WorkerPatronymic = workerPatronymic,
|
||||
Email = login,
|
||||
Phone = phone,
|
||||
Password = password
|
||||
});
|
||||
APIWorker.Worker.WorkerSurname = workerSurname;
|
||||
APIWorker.Worker.WorkerName = workerName;
|
||||
APIWorker.Worker.WorkerPatronymic = workerPatronymic;
|
||||
APIWorker.Worker.Email = login;
|
||||
APIWorker.Worker.Phone = phone;
|
||||
APIWorker.Worker.Password = password;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None,
|
||||
NoStore = true)]
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите email и пароль");
|
||||
}
|
||||
APIWorker.Worker =
|
||||
APIWorker.GetRequest<WorkerViewModel>($"api/worker/login?login={login}&password={password}");
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string login, string password, string workerSurname, string workerName, string workerPatronymic, string phone)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(workerSurname) ||
|
||||
string.IsNullOrEmpty(workerName) || string.IsNullOrEmpty(workerPatronymic) ||
|
||||
string.IsNullOrEmpty(phone))
|
||||
{
|
||||
throw new Exception("Не все данные введены");
|
||||
}
|
||||
APIWorker.PostRequest("api/worker/register", new
|
||||
WorkerBindingModel
|
||||
{
|
||||
WorkerSurname = workerSurname,
|
||||
WorkerName = workerName,
|
||||
WorkerPatronymic = workerPatronymic,
|
||||
Email = login,
|
||||
Phone = phone,
|
||||
Password = password
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
|
||||
public IActionResult Create()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Programs = APIWorker.GetRequest<List<ProgramViewModel>>($"api/program/getprograms");
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateDeposit()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateRefill()
|
||||
{
|
||||
ViewBag.Deposits = APIWorker.GetRequest<List<DepositViewModel>>($"api/deposit/getdepositlist?workerid={APIWorker.Worker.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(string name, List<int> programs, string login, string password, string clientSurname, string clientName, string clientPatronymic, string phone)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
Dictionary<int, IProgramModel> a = new Dictionary<int, IProgramModel>();
|
||||
foreach (int program in programs)
|
||||
{
|
||||
a.Add(program, new ProgramSearchModel { Id = program } as IProgramModel);
|
||||
}
|
||||
APIWorker.PostRequest("api/client/createclient", new ClientBindingModel
|
||||
{
|
||||
ClientSurname = clientSurname,
|
||||
ClientName = clientName,
|
||||
ClientPatronymic = clientPatronymic,
|
||||
Email = login,
|
||||
Phone = phone,
|
||||
Password = password,
|
||||
WorkerId = APIWorker.Worker.Id,
|
||||
ClientPrograms = a
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateDeposit(string depositname, double sum, List<int> currencies, List<int> clients)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(depositname))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
Dictionary<int, ICurrencyModel> a = new Dictionary<int, ICurrencyModel>();
|
||||
Dictionary<int, IClientModel> b = new Dictionary<int, IClientModel>();
|
||||
APIWorker.PostRequest("api/deposit/createdeposit", new DepositBindingModel
|
||||
{
|
||||
Sum = sum,
|
||||
WorkerId = APIWorker.Worker.Id,
|
||||
});
|
||||
Response.Redirect("IndexDeposits");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateRefill(int depositId, string sum, DateOnly refillDate)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(sum))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
StringBuilder st = new StringBuilder(sum);
|
||||
for (int i = 0; i < sum.Length; i++)
|
||||
{
|
||||
if (sum[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
sum = st.ToString();
|
||||
double _sum;
|
||||
try
|
||||
{
|
||||
_sum = Convert.ToDouble(sum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
if (_sum <= 0)
|
||||
{
|
||||
throw new Exception("Сумма должна быть выше 0");
|
||||
}
|
||||
if (refillDate == null)
|
||||
{
|
||||
throw new Exception("Выберите дату");
|
||||
}
|
||||
APIWorker.PostRequest("api/refill/createrefill", new RefillBindingModel
|
||||
{
|
||||
DepositId = depositId,
|
||||
Sum = Math.Round(_sum, 2),
|
||||
RefillDate = refillDate
|
||||
});
|
||||
Response.Redirect("IndexRefills");
|
||||
}
|
||||
|
||||
public IActionResult Delete()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Clients = APIWorker.GetRequest<List<ClientViewModel>>("api/client/getclients");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(string client)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIWorker.PostRequest("api/client/deleteclient", new ClientBindingModel
|
||||
{
|
||||
Snils = client
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult DeleteDeposit()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Deposits = APIWorker.GetRequest<List<DepositViewModel>>($"api/deposit/getdepositlist?workerid={APIWorker.Worker.Id}");
|
||||
return View();
|
||||
}
|
||||
public IActionResult DeleteRefill()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Refills = APIWorker.GetRequest<List<RefillViewModel>>($"api/refill/getrefills?workerid={APIWorker.Worker.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteDeposit(int deposit)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIWorker.PostRequest("api/deposit/deletedeposit", new DepositBindingModel
|
||||
{
|
||||
Id = deposit
|
||||
});
|
||||
Response.Redirect("IndexDeposits");
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteRefill(int refill)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIWorker.PostRequest("api/refill/deleterefill", new RefillBindingModel
|
||||
{
|
||||
Id = refill
|
||||
});
|
||||
Response.Redirect("IndexRefills");
|
||||
}
|
||||
|
||||
public IActionResult Update()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Clients = APIWorker.GetRequest<List<ClientViewModel>>($"api/client/getclients?workerid={APIWorker.Worker.Id}");
|
||||
ViewBag.Programs = APIWorker.GetRequest<List<ProgramViewModel>>($"api/program/getprograms");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(string snils, string surname, string name, string patronymic, string phone, string email, string password, int workerId)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(snils) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(patronymic) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
|
||||
APIWorker.PostRequest("api/client/updateclient", new ClientBindingModel
|
||||
{
|
||||
Snils = snils,
|
||||
ClientSurname = surname,
|
||||
ClientName = name,
|
||||
ClientPatronymic = patronymic,
|
||||
Phone = phone,
|
||||
Email = email,
|
||||
Password = password,
|
||||
WorkerId = workerId
|
||||
});
|
||||
Response.Redirect("IndexClients");
|
||||
}
|
||||
|
||||
public IActionResult UpdateDeposit()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Deposits = APIWorker.GetRequest<List<DepositViewModel>>($"api/deposit/getdepositlist?workerid={APIWorker.Worker.Id}");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateDeposit(int depositId, double sum, DateOnly openingDate)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (sum <= 0)
|
||||
{
|
||||
throw new Exception("Сумма должна быть выше 0");
|
||||
}
|
||||
|
||||
if (openingDate == null)
|
||||
{
|
||||
throw new Exception("Выберите дату открытия");
|
||||
}
|
||||
|
||||
APIWorker.PostRequest("api/deposit/updatedeposit", new DepositBindingModel
|
||||
{
|
||||
Id = depositId,
|
||||
Sum = sum,
|
||||
OpeningDate = openingDate
|
||||
});
|
||||
Response.Redirect("IndexDeposits");
|
||||
}
|
||||
|
||||
public IActionResult ClientDeposits()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Deposits = APIWorker.GetRequest<List<DepositViewModel>>($"api/deposit/getdepositlist?workerid={APIWorker.Worker.Id}");
|
||||
ViewBag.Clients = APIWorker.GetRequest<List<ClientViewModel>>($"api/client/getclients");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void ClientDeposits(int depositId, int workerId, double sum, DateTime openingDate, List<int> currencies, List<string> clients)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (sum <= 0)
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
|
||||
Dictionary<int, ICurrencyModel> depositCurrencies = new Dictionary<int, ICurrencyModel>();
|
||||
foreach (int currency in currencies)
|
||||
{
|
||||
depositCurrencies.Add(currency, new CurrencySearchModel { Id = currency } as ICurrencyModel);
|
||||
}
|
||||
|
||||
Dictionary<string, IClientModel> clientDeposit = new Dictionary<string, IClientModel>();
|
||||
foreach (string client in clients)
|
||||
{
|
||||
clientDeposit.Add(client, new ClientSearchModel { Snils = client } as IClientModel);
|
||||
}
|
||||
|
||||
APIWorker.PostRequest("api/deposit/updatedeposit?isconnection=true", new DepositBindingModel
|
||||
{
|
||||
Id = depositId,
|
||||
WorkerId = workerId,
|
||||
Sum = Math.Round(sum, 2),
|
||||
OpeningDate = DateOnly.FromDateTime(openingDate),
|
||||
DepositCurrencies = depositCurrencies,
|
||||
ClientDeposit = clientDeposit
|
||||
});
|
||||
Response.Redirect("IndexDeposits");
|
||||
}
|
||||
|
||||
|
||||
public IActionResult ProgramClients()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Clients = APIWorker.GetRequest<List<ClientViewModel>>($"api/client/getclients?workerid={APIWorker.Worker.Id}");
|
||||
ViewBag.Programs = APIWorker.GetRequest<List<ProgramViewModel>>($"api/program/getprograms");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void ProgramClients(int client, string snils, string clientSurname, string clientName, string clientPatronymic,
|
||||
string phone, string? email, string password, int workerId, DateTime date, List<int> programs)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(clientName) || string.IsNullOrEmpty(clientSurname) || string.IsNullOrEmpty(snils) || date == new DateTime())
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
|
||||
Dictionary<int, IProgramModel> clientPrograms = new Dictionary<int, IProgramModel>();
|
||||
foreach (int program in programs)
|
||||
{
|
||||
clientPrograms.Add(program, new ProgramSearchModel { Id = program } as IProgramModel);
|
||||
}
|
||||
|
||||
APIWorker.PostRequest("api/client/updateclient?isconnection=true", new ClientBindingModel
|
||||
{
|
||||
Snils = snils,
|
||||
ClientSurname = clientSurname,
|
||||
ClientName = clientName,
|
||||
ClientPatronymic = clientPatronymic,
|
||||
Phone = phone,
|
||||
Email = email,
|
||||
Password = password,
|
||||
WorkerId = workerId,
|
||||
ClientPrograms = clientPrograms,
|
||||
ClientDeposits = new Dictionary<int, IDepositModel>(),
|
||||
});
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult Refills()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
var res = APIWorker.GetRequest<List<RefillViewModel>>($"api/refill/getrefills?workerid={APIWorker.Worker.Id}");
|
||||
return View(res);
|
||||
|
||||
}
|
||||
public IActionResult UpdateRefill()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Refills = APIWorker.GetRequest<List<RefillViewModel>>($"api/refill/getrefills?workerid={APIWorker.Worker.Id}");
|
||||
ViewBag.Deposits = APIWorker.GetRequest<List<DepositViewModel>>($"api/deposit/getdepositlist?workerid={APIWorker.Worker.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateRefill(int refillId, int depositId, double sum, DateOnly refillDate)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (sum <= 0)
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
|
||||
APIWorker.PostRequest("api/refill/updaterefill", new RefillBindingModel
|
||||
{
|
||||
Id = refillId,
|
||||
DepositId = depositId,
|
||||
Sum = Math.Round(sum, 2),
|
||||
RefillDate = refillDate
|
||||
});
|
||||
Response.Redirect("IndexRefills");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id
|
||||
?? HttpContext.TraceIdentifier });
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<ClientViewModel, List<Tuple<string, int>>>? GetClient(int clientId)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIWorker.GetRequest<Tuple<ClientViewModel, List<Tuple<string, int>>>>($"api/client/getclient?clientid={clientId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<DepositViewModel, List<Tuple<string, int>>>? GetDeposit(int depositId)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIWorker.GetRequest<Tuple<DepositViewModel, List<Tuple<string, int>>>>($"api/deposit/getdeposit?depositid={depositId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<ProgramViewModel, List<string>>? GetProgram(int programId)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIWorker.GetRequest<Tuple<ProgramViewModel, List<string>>>($"api/program/getprogram?programid={programId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public RefillViewModel GetRefill(int refillId)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
var result = APIWorker.GetRequest<RefillViewModel>($"api/refill/getrefill?refillid={refillId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ProgramListReport(List<int> deposits, string type)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (deposits.Count <= 0)
|
||||
{
|
||||
throw new Exception("Количество должно быть больше 0");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(type))
|
||||
{
|
||||
throw new Exception("Неверный тип отчета");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (type == "docx")
|
||||
{
|
||||
APIWorker.PostRequest("api/reportworker/createprogramlistwordfile", new ListProgramsBindingModel
|
||||
{
|
||||
Deposits = deposits,
|
||||
FileName = "C:\\ReportsCourseWork\\wordfile.docx"
|
||||
});
|
||||
Response.Redirect("GetWordFile");
|
||||
}
|
||||
else
|
||||
{
|
||||
APIWorker.PostRequest("api/reportworker/createprogramlistexcelfile", new ListProgramsBindingModel
|
||||
{
|
||||
Deposits = deposits,
|
||||
FileName = "C:\\ReportsCourseWork\\excelfile.xlsx"
|
||||
});
|
||||
Response.Redirect("GetExcelFile");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetWordFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\ReportsCourseWork\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
}
|
||||
|
||||
public IActionResult GetExcelFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\ReportsCourseWork\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
}
|
||||
[HttpGet]
|
||||
public string GetClientsReport(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
List<CurrenciesRefillsViewModel> result;
|
||||
try
|
||||
{
|
||||
string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture);
|
||||
string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture);
|
||||
result = APIWorker.GetRequest<List<CurrenciesRefillsViewModel>>
|
||||
($"api/reportadmin/getclientsrefillsreport?datefrom={dateFromS}&dateto={dateToS}&adminid={APIWorker.Worker.Id}")!;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
string table = "";
|
||||
table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
|
||||
table += "<div class=\"table-responsive\">";
|
||||
table += "<table class=\"table table-striped table-bordered table-hover\">";
|
||||
table += "<thead class=\"table-dark\">";
|
||||
table += "<tr>";
|
||||
table += "<th scope=\"col\">Дата</th>";
|
||||
table += "<th scope=\"col\">Фамилия клиента</th>";
|
||||
table += "<th scope=\"col\">Имя клиента</th>";
|
||||
table += "<th scope=\"col\">Отчество клиента</th>";
|
||||
table += "<th scope=\"col\">Валюта</th>";
|
||||
table += "<th scope=\"col\">Пополнение</th>";
|
||||
table += "</tr>";
|
||||
table += "</thead>";
|
||||
foreach (var client in result)
|
||||
{
|
||||
table += "<tbody>";
|
||||
|
||||
table += "<tr>";
|
||||
table += $"<td>{client.DateFrom} - {client.DateTo}</td>";
|
||||
table += $"<td>{client.ClientSurname}</td>";
|
||||
table += $"<td>{client.ClientName}</td>";
|
||||
table += $"<td>{client.ClientPatronymic}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
|
||||
foreach (var currency in client.Currencies)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{currency.CurrencyName}</td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
|
||||
foreach (var refill in client.Refills)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{refill.Sum}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
|
||||
table += "</tbody>";
|
||||
}
|
||||
|
||||
table += "</table>";
|
||||
table += "</div>";
|
||||
|
||||
return table;
|
||||
}
|
||||
[HttpPost]
|
||||
public void Report(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIWorker.PostRequest("api/reportworker/sendcurrenciesrefillsreporttoemail", new CurrenciesRefillsBindingModel
|
||||
{
|
||||
FileName = "C:\\ReportsCourseWork\\pdffile.pdf",
|
||||
WorkerId = APIWorker.Worker.Id,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
Email = APIWorker.Worker.Email
|
||||
|
||||
});
|
||||
Response.Redirect("Report");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace BankWorkerApp
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
APIClient.Connect(builder.Configuration);
|
||||
APIWorker.Connect(builder.Configuration);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
|
62
Bank/BankWorkerApp/Views/Home/ClientDeposit.cshtml
Normal file
62
Bank/BankWorkerApp/Views/Home/ClientDeposit.cshtml
Normal file
@ -0,0 +1,62 @@
|
||||
@using BankContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ClientDeposits";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Связывание клиента и депозита</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Клиент:</div>
|
||||
<div class="col-8">
|
||||
<select id="client" name="client" class="form-control" asp-items="@(new SelectList(@ViewBag.Clients, "Snils", "ClientName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Депозиты:</div>
|
||||
<div class="col-8">
|
||||
<select name="deposits" class="form-control" multiple size="5" id="deposits">
|
||||
@foreach (var deposit in ViewBag.Deposits)
|
||||
{
|
||||
<option value="@deposit.Id" data-name="@deposit.Id">@deposit.NameDeposit</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var client = $('#client').val();
|
||||
$("#deposits option:selected").removeAttr("selected");
|
||||
if (client) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetClient",
|
||||
data: { clientSnils: client },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.clientName);
|
||||
$('#family').val(result.item1.family);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$(option[data - name= ${ n.item2 }]).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
check();
|
||||
$('#client').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
64
Bank/BankWorkerApp/Views/Home/Create.cshtml
Normal file
64
Bank/BankWorkerApp/Views/Home/Create.cshtml
Normal file
@ -0,0 +1,64 @@
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание клиента</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">СНИЛС:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" id="snils" name="snils" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" clientSurname="clientSurname" />
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<input type="text" clientName="clientName" />
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<input type="text" clientPatronymic="clientPatronymic" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Телефон:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" id="phone" name="phone" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Email:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" id="phone" name="phone" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" id="password" name="password" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Кредитные программы:</div>
|
||||
<div class="col-8">
|
||||
<select name="programs" class="form-control" multiple size="6" id="programs">
|
||||
@foreach (var program in ViewBag.Services)
|
||||
{
|
||||
<option value="@program.Id">@program.ProgramName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
28
Bank/BankWorkerApp/Views/Home/CreateDeposit.cshtml
Normal file
28
Bank/BankWorkerApp/Views/Home/CreateDeposit.cshtml
Normal file
@ -0,0 +1,28 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateDeposit";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание депозита</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="sum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" name="openingdate" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
34
Bank/BankWorkerApp/Views/Home/CreateRefill.cshtml
Normal file
34
Bank/BankWorkerApp/Views/Home/CreateRefill.cshtml
Normal file
@ -0,0 +1,34 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateRefill";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание пополнения</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Депозит:</div>
|
||||
<div class="col-8">
|
||||
<select id="deposit" name="deposit" class="form-control" asp-items="@(new SelectList(@ViewBag.Deposits, "Id", "DepositName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="sum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата пополнения:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="refilldate" name="refilldate" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
18
Bank/BankWorkerApp/Views/Home/Delete.cshtml
Normal file
18
Bank/BankWorkerApp/Views/Home/Delete.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление клиента</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Клиенты:</div>
|
||||
<div class="col-8">
|
||||
<select id="client" name="client" class="form-control" asp-items="@(new SelectList(@ViewBag.Clients, "Snils", "ClientName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
18
Bank/BankWorkerApp/Views/Home/DeleteDeposit.cshtml
Normal file
18
Bank/BankWorkerApp/Views/Home/DeleteDeposit.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteDeposit";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление депозита</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Депозит:</div>
|
||||
<div class="col-8">
|
||||
<select id="deposit" name="deposit" class="form-control" asp-items="@(new SelectList(@ViewBag.Deposits, "Id", "Sum"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
37
Bank/BankWorkerApp/Views/Home/DeleteRefill.cshtml
Normal file
37
Bank/BankWorkerApp/Views/Home/DeleteRefill.cshtml
Normal file
@ -0,0 +1,37 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteRefill";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление пополнения</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Пополнение:</div>
|
||||
<div class="col-8">
|
||||
<select id="refill" name="refill" class="form-control" asp-items="@(new SelectList(@ViewBag.Refills, "Id", "Sum"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$('#refill').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
if (refill) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetRefill",
|
||||
data: { refill: refill },
|
||||
success: function (result) {
|
||||
$("#refill").val(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
27
Bank/BankWorkerApp/Views/Home/Enter.cshtml
Normal file
27
Bank/BankWorkerApp/Views/Home/Enter.cshtml
Normal file
@ -0,0 +1,27 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход в приложение</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="login" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Вход" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -1,7 +1,77 @@
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
@using BankContracts.ViewModels
|
||||
|
||||
@model List<ClientViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Главная";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
|
||||
</div>
|
||||
<h1 class="display-4">Клиенты</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="Update">Редактировать клиента</a>
|
||||
<a asp-action="Delete">Удалить клиента</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="Create">Создать клиента</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
СНИЛС
|
||||
</th>
|
||||
<th>
|
||||
Фамилия
|
||||
</th>
|
||||
<th>
|
||||
Имя
|
||||
</th>
|
||||
<th>
|
||||
Отчество
|
||||
</th>
|
||||
<th>
|
||||
Телефон
|
||||
</th>
|
||||
<th>
|
||||
Email
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Snils)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ClientSurname)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ClientName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ClientPatronymic)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Phone)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Email)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
60
Bank/BankWorkerApp/Views/Home/IndexDeposits.cshtml
Normal file
60
Bank/BankWorkerApp/Views/Home/IndexDeposits.cshtml
Normal file
@ -0,0 +1,60 @@
|
||||
@using BankContracts.ViewModels
|
||||
|
||||
@model List<DepositViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "IndexDeposits";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Депозиты</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="UpdateDeposit">Редактировать депозит</a>
|
||||
<a asp-action="LinkDepositCurrencies">Связать депозит и валюты</a>
|
||||
<a asp-action="DeleteDeposit">Удалить депозит</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="CreateDeposit">Создать депозит</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Дата открытия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.OpeningDate)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
59
Bank/BankWorkerApp/Views/Home/IndexRefills.cshtml
Normal file
59
Bank/BankWorkerApp/Views/Home/IndexRefills.cshtml
Normal file
@ -0,0 +1,59 @@
|
||||
@using BankContracts.ViewModels
|
||||
|
||||
@model List<RefillViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "IndexRefills";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Пополнения</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="UpdateRefill">Изменить пополнение</a>
|
||||
<a asp-action="DeleteRefill">Удалить пополнение</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="CreateRefill">Создать пополнение</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Дата пополнения
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.RefillDate)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
41
Bank/BankWorkerApp/Views/Home/Privacy.cshtml
Normal file
41
Bank/BankWorkerApp/Views/Home/Privacy.cshtml
Normal file
@ -0,0 +1,41 @@
|
||||
@using BankContracts.ViewModels
|
||||
|
||||
@model WorkerViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Фамилия:</div>
|
||||
<div class="col-8"><input type="text" name="surname" value="@Model.WorkerSurname" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Имя:</div>
|
||||
<div class="col-8"><input type="text" name="name" value="@Model.WorkerName" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Отчество:</div>
|
||||
<div class="col-8"><input type="text" name="patronymic" value="@Model.WorkerPatronymic" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Телефон:</div>
|
||||
<div class="col-8"><input type="text" name="phone" value="@Model.Phone" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Email:</div>
|
||||
<div class="col-8"><input type="text" name="email" value="@Model.Email" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" value="@Model.Password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
51
Bank/BankWorkerApp/Views/Home/Register.cshtml
Normal file
51
Bank/BankWorkerApp/Views/Home/Register.cshtml
Normal file
@ -0,0 +1,51 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Фамилия:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="surname" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Имя:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Отчество:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="patronymic" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Телефон:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="phone" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Email:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="email" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Регистрация" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
65
Bank/BankWorkerApp/Views/Home/Report.cshtml
Normal file
65
Bank/BankWorkerApp/Views/Home/Report.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@{
|
||||
ViewData["Title"] = "Report";
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="text-custom-color-1">Отчет по клиентам за период</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateFrom" class="form-label text-custom-color-1">Начало периода:</label>
|
||||
<input type="datetime-local" id="dateFrom" name="dateFrom" class="form-control" placeholder="Выберите дату начала периода">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateTo" class="form-label text-custom-color-1">Окончание периода:</label>
|
||||
<input type="datetime-local" id="dateTo" name="dateTo" class="form-control" placeholder="Выберите дату окончания периода">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Отправить на почту</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="button" id="demonstrate" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Сформировать</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="report"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function check() {
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetProgramReport",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#demonstrate').on('click', (e) => check());
|
||||
</script>
|
||||
}
|
38
Bank/BankWorkerApp/Views/Home/ServiceListReport.cshtml
Normal file
38
Bank/BankWorkerApp/Views/Home/ServiceListReport.cshtml
Normal file
@ -0,0 +1,38 @@
|
||||
@using BankContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ProgramListReport";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создать списки кредитных программ по вкладам</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Вклад:</div>
|
||||
<div class="col-8">
|
||||
<select name="animals" class="form-control" multiple size="5" id="deposits">
|
||||
@foreach (var deposit in ViewBag.deposit)
|
||||
{
|
||||
<option value="@deposit.Id">@deposit.Id</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-format">
|
||||
<label class="form-label">Выберите формат файла:</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="docx" id="docx">
|
||||
<label class="form-check-label" for="docx">Word-файл</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx" checked>
|
||||
<label class="form-check-label" for="xlsx">Excel-файл</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="submit" class="btn btn-block btn-outline-dark w-100">Создать</button>
|
||||
</div>
|
||||
</form>
|
86
Bank/BankWorkerApp/Views/Home/Update.cshtml
Normal file
86
Bank/BankWorkerApp/Views/Home/Update.cshtml
Normal file
@ -0,0 +1,86 @@
|
||||
@using BankContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Update";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование клиента</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Клиент:</div>
|
||||
<div class="col-8">
|
||||
<select id="client" name="client" class="form-control" asp-items="@(new SelectList(@ViewBag.Clients, "Snils", "ClientName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Фамилия:</div>
|
||||
<div class="col-8"><input type="text" name="surname" id="surname" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Имя:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Отчество:</div>
|
||||
<div class="col-8"><input type="text" name="patronymic" id="patronymic" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Телефон:</div>
|
||||
<div class="col-8"><input type="text" name="phone" id="phone" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Email:</div>
|
||||
<div class="col-8"><input type="text" name="email" id="email" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" id="password" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Работник:</div>
|
||||
<div class="col-8">
|
||||
<select name="worker" class="form-control" id="worker">
|
||||
@foreach (var worker in ViewBag.Workers)
|
||||
{
|
||||
<option value="@worker.Id" data-name="@worker.Id">@worker.WorkerName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var client = $('#client').val();
|
||||
$("#worker option:selected").removeAttr("selected");
|
||||
if (client) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetClient",
|
||||
data: { clientSnils: client },
|
||||
success: function (result) {
|
||||
$('#surname').val(result.clientSurname);
|
||||
$('#name').val(result.clientName);
|
||||
$('#patronymic').val(result.clientPatronymic);
|
||||
$('#phone').val(result.phone);
|
||||
$('#email').val(result.email);
|
||||
$('#password').val(result.password);
|
||||
$(`#worker option[value=${result.workerId}]`).attr("selected", "selected");
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#client').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
53
Bank/BankWorkerApp/Views/Home/UpdateDeposit.cshtml
Normal file
53
Bank/BankWorkerApp/Views/Home/UpdateDeposit.cshtml
Normal file
@ -0,0 +1,53 @@
|
||||
@using BankContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateDeposit";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование депозита</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Депозит:</div>
|
||||
<div class="col-8">
|
||||
<select id="deposit" name="deposit" class="form-control" asp-items="@(new SelectList(@ViewBag.Deposits, "Id", "Sum"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><input type="text" name="sum" id="sum" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8"><input type="date" id="openingDate" name="openingDate" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var deposit = $('#deposit').val();
|
||||
if (deposit) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetDeposit",
|
||||
data: { depositId: deposit },
|
||||
success: function (result) {
|
||||
$('#sum').val(result.sum);
|
||||
$('#openingDate').val(result.openingDate);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#deposit').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
69
Bank/BankWorkerApp/Views/Home/UpdateRefill.cshtml
Normal file
69
Bank/BankWorkerApp/Views/Home/UpdateRefill.cshtml
Normal file
@ -0,0 +1,69 @@
|
||||
@{
|
||||
ViewData["Title"] = "UpdateRefill";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование пополнения</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Пополнение:</div>
|
||||
<div class="col-8">
|
||||
<select id="refill" name="refill" class="form-control" asp-items="@(new SelectList(@ViewBag.Refills, "Id", "Sum"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Депозит:</div>
|
||||
<div class="col-8">
|
||||
<select name="deposit" class="form-control" id="deposit">
|
||||
@foreach (var deposit in ViewBag.Deposits)
|
||||
{
|
||||
<option value="@deposit.Id" id="@deposit.Id">@deposit.DepositName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" id="sum" name="sum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата пополнения:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="refillDate" name="refillDate" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
||||
<script>
|
||||
function check() {
|
||||
var refill = $('#refill').val();
|
||||
$("#deposit option:selected").removeAttr("selected");
|
||||
if (refill) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetRefill",
|
||||
data: { refillId: refill },
|
||||
success: function (result) {
|
||||
console.log(result);
|
||||
$('#sum').val(result.sum);
|
||||
$('#refillDate').val(result.refillDate);
|
||||
$(#deposit option[value = ${ result.depositId }]).attr("selected", "selected");
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#refill').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
|
@ -1,49 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - BankWorkerApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/BankWorkerApp.styles.css" asp-append-version="true" />
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - BankWorkerApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">BankWorkerApp</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<main role="main" class="pb-3">
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - BankWorkerApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Вы банкрот</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="IndexDeposits">Вклады</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="IndexRefills">Поплнения</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Клиенты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ProgramListReport">Выгрузка списка</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Report">Отчет</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<main role="main" class="pb-3">
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@RenderSection("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@ -1,24 +1,22 @@
|
||||
html {
|
||||
font-size: 14px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
html {
|
||||
font-size: 16px;
|
||||
}
|
||||
html {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
|
||||
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
|
||||
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
|
||||
}
|
||||
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
background-color: #FFA500;
|
||||
min-height: 100vh;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ $.validator.addMethod( "bic", function( value, element ) {
|
||||
* P. Local authorities
|
||||
* Q. Autonomous bodies, state or not, and the like, and congregations and religious institutions
|
||||
* R. Congregations and religious institutions (since 2008 ORDER EHA/451/2008)
|
||||
* S. Organs of State Administration and regions
|
||||
* S. Organs of State Workeristration and regions
|
||||
* V. Agrarian Transformation
|
||||
* W. Permanent establishments of non-resident in Spain
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user