Stage 9-10 : поделал страницы для кассира, но их можно будет проверить полностью после клиента, чуть подправил RestAPI, чуть не помер в homecontroller в кассирском приложении( и тут он понял )
This commit is contained in:
parent
75d7f129bd
commit
47f20b530b
@ -1,5 +1,7 @@
|
||||
using Azure;
|
||||
using BankContracts.ViewModels;
|
||||
using BankContracts.ViewModels.Cashier.ViewModels;
|
||||
using BankContracts.ViewModels.Client.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
@ -11,8 +13,15 @@ namespace BankCashierApp
|
||||
private static readonly HttpClient _cashier = new();
|
||||
|
||||
public static CashierViewModel? Cashier { get; set; } = null;
|
||||
public static CreditingViewModel? Crediting { get; set; } = null;
|
||||
|
||||
public static string ErrorMessage = string.Empty;
|
||||
public static DebitingViewModel? Debiting { get; set; } = null;
|
||||
|
||||
public static AccountViewModel? Account { get; set; } = null;
|
||||
|
||||
public static CardViewModel? Card { get; set; } = null;
|
||||
|
||||
public static string ErrorMessage = string.Empty;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
@ -60,7 +69,7 @@ namespace BankCashierApp
|
||||
}
|
||||
|
||||
// Post-запрос для получения данных
|
||||
public static T? PostRequetReport<T, U>(string requestUrl, U model)
|
||||
public static T? PostRequestReport<T, U>(string requestUrl, U model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
@ -1,4 +1,13 @@
|
||||
using BankCashierApp.Models;
|
||||
using BankContracts.BindingModels.Cashier;
|
||||
using BankContracts.BindingModels.Reports;
|
||||
using BankContracts.ViewModels.Cashier.Diagram;
|
||||
using BankContracts.ViewModels.Cashier.ViewModels;
|
||||
using BankContracts.ViewModels.Client.ViewModels;
|
||||
using BankContracts.ViewModels.Reports.Cashier;
|
||||
using BankContracts.ViewModels.Reports;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
@ -12,47 +21,698 @@ namespace BankCashierApp.Controllers
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
//вытаскивает через API клиента Get-запросом список его собственных заказов
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(APICashier.GetRequest<List<AccountViewModel>>($"/api/Account/GetAllAccounts"));
|
||||
}
|
||||
|
||||
// Обновление данных пользователя
|
||||
|
||||
//изменемение ланных Get-ом
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(APICashier.Cashier);
|
||||
}
|
||||
|
||||
//изменение данных Post-ом
|
||||
[HttpPost]
|
||||
public void Privacy(string login, string password, string name, string surname, string patronymic, string telephone)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(name)
|
||||
|| string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(patronymic)
|
||||
|| string.IsNullOrEmpty(telephone))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль, ФИО и телефон");
|
||||
}
|
||||
|
||||
APICashier.PostRequest("/api/Cashier/UpdateData", new CashierBindingModel
|
||||
{
|
||||
Id = APICashier.Cashier.Id,
|
||||
Name = name,
|
||||
Surname = surname,
|
||||
Patronymic = patronymic,
|
||||
MobilePhone = telephone,
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
|
||||
APICashier.Cashier.Name = name;
|
||||
APICashier.Cashier.Surname = surname;
|
||||
APICashier.Cashier.Patronymic = patronymic;
|
||||
APICashier.Cashier.Email = login;
|
||||
APICashier.Cashier.Password = password;
|
||||
APICashier.Cashier.MobilePhone = telephone;
|
||||
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Login()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Login(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо заполнить оба поля");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APICashier.Cashier = APICashier.GetRequest<CashierViewModel>($"api/Cashier/Login?login={login}&password={password}");
|
||||
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Неверный логин или пароль");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
return Redirect("Enter");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Logout()
|
||||
{
|
||||
APICashier.Cashier = null;
|
||||
|
||||
return Redirect("Enter");
|
||||
}
|
||||
|
||||
|
||||
// Вывод ошибок
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel
|
||||
{
|
||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ErrorPage()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Вход в приложение
|
||||
|
||||
//просто открытие вьюхи
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//отсылаем указанные данные на проверку
|
||||
[HttpPost]
|
||||
public IActionResult Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
APICashier.SetErrorMessage("Введите логин и пароль");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APICashier.Cashier = APICashier.GetRequest<CashierViewModel>($"/api/Cashier/Login?login={login}&password={password}");
|
||||
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Неверный логин или пароль");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
return Redirect("Index");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Регистрация
|
||||
|
||||
//просто открытие вьюхи
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
//Post-запрос по созданию нового пользователя
|
||||
[HttpPost]
|
||||
public void Register(string login, string password, string name, string surname, string patronymic, string telephone)
|
||||
{
|
||||
return View();
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(name)
|
||||
|| string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(patronymic) || string.IsNullOrEmpty(telephone))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль, ФИО и телефон");
|
||||
}
|
||||
|
||||
APICashier.PostRequest("/api/Cashier/Register", new CashierBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Surname = surname,
|
||||
Patronymic = patronymic,
|
||||
Email = login,
|
||||
Password = password,
|
||||
MobilePhone = telephone
|
||||
});
|
||||
|
||||
//переход на вкладку "Enter", чтобы пользователь сразу смог зайти
|
||||
Response.Redirect("Enter");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Открытие нового счёта
|
||||
|
||||
//открытие счёта. Получаем и передаём список изделий во вьюху?
|
||||
[HttpGet]
|
||||
public IActionResult CreateAccount()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
//запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net
|
||||
ViewBag.Clients = APICashier.GetRequest<List<ClientViewModel>>($"/api/Client/GetAllClients").Select(x => new ClientSelectViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
FullName = x.Surname + " " + x.Name + " " + x.Patronymic
|
||||
}).ToList();
|
||||
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateReport()
|
||||
|
||||
//создание заказа Post-запросом
|
||||
[HttpPost]
|
||||
public IActionResult CreateAccount(int clientId, string accountNumber, string password, int balance)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (clientId <= 0 || string.IsNullOrEmpty(accountNumber) || string.IsNullOrEmpty(password) || balance < 0)
|
||||
{
|
||||
APICashier.SetErrorMessage("Проверьте корректность вводимых данных");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APICashier.PostRequest("/api/Account/Register", new AccountBindingModel
|
||||
{
|
||||
CashierId = APICashier.Cashier.Id,
|
||||
ClientId = clientId,
|
||||
AccountNumber = accountNumber,
|
||||
Balance = balance,
|
||||
DateOpen = DateTime.Now
|
||||
});
|
||||
|
||||
return Redirect("Index");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Работа с заявками на зачисление
|
||||
|
||||
//для страницы "Заявки на зачисление"
|
||||
[HttpGet]
|
||||
public IActionResult Crediting()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
Response.Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
return View(APICashier.GetRequest<List<CreditingViewModel>>($"/api/Account/FindOpenCrediting"));
|
||||
}
|
||||
|
||||
//открытие вьюхи одобрения заявки на зачисление
|
||||
[HttpGet]
|
||||
public IActionResult CloseCrediting()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Creditings = APICashier.GetRequest<List<CreditingViewModel>>("/api/Account/FindOpenCrediting");
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
//одобрения заявки на зачисление Post-запросом
|
||||
[HttpPost]
|
||||
public IActionResult CloseCrediting(int creditingId, int accountPayeeId)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (creditingId <= 0 || accountPayeeId <= 0)
|
||||
{
|
||||
APICashier.SetErrorMessage("Проверьте коректность передавваемых значений");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
//получаем необходимые данные для запроса
|
||||
APICashier.Crediting = APICashier.GetRequest<CreditingViewModel>($"/api/Account/FindCrediting?id={creditingId}");
|
||||
|
||||
APICashier.Card = APICashier.GetRequest<CardViewModel>($"/api/Card/FindCard?id={APICashier.Crediting.CardId}");
|
||||
|
||||
APICashier.PostRequest("/api/Account/CloseCrediting", new MoneyTransferBindingModel
|
||||
{
|
||||
CashierId = APICashier.Cashier.Id,
|
||||
CreditingId = creditingId,
|
||||
Sum = APICashier.Crediting.Sum,
|
||||
AccountPayeeId = accountPayeeId
|
||||
});
|
||||
|
||||
//очистка данных
|
||||
APICashier.Crediting = null;
|
||||
APICashier.Card = null;
|
||||
|
||||
return Redirect("Crediting");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Работа с заявками на снятие
|
||||
|
||||
//для страницы "Заявки на снятие"
|
||||
[HttpGet]
|
||||
public IActionResult Debiting()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
Response.Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
|
||||
return View(APICashier.GetRequest<List<DebitingViewModel>>($"/api/Account/FindOpenDebiting"));
|
||||
}
|
||||
|
||||
//открытие вьюхи одобрения заявки на снятие
|
||||
[HttpGet]
|
||||
public IActionResult CloseDebiting()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
Response.Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
|
||||
ViewBag.Debitings = APICashier.GetRequest<List<DebitingViewModel>>("/api/Account/FindOpenDebiting");
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
//одобрения заявки на снятие Post-запросом
|
||||
[HttpPost]
|
||||
public IActionResult CloseDebiting(int debitingId, int accountId)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (debitingId <= 0 || accountId <= 0)
|
||||
{
|
||||
APICashier.SetErrorMessage("Проверьте корректность передаваемых значений");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
//получаем необходимые данные для запроса
|
||||
APICashier.Debiting = APICashier.GetRequest<DebitingViewModel>($"/api/Account/FindDebiting?id={debitingId}");
|
||||
|
||||
APICashier.Card = APICashier.GetRequest<CardViewModel>($"/api/Card/FindCard?id={APICashier.Debiting.CardId}");
|
||||
|
||||
APICashier.PostRequest("/api/Account/CloseDebiting", new CashWithdrawalBindingModel
|
||||
{
|
||||
CashierId = APICashier.Cashier.Id,
|
||||
DebitingId = debitingId,
|
||||
Sum = APICashier.Debiting.Sum,
|
||||
AccountId = accountId
|
||||
});
|
||||
|
||||
APICashier.Debiting = null;
|
||||
APICashier.Card = null;
|
||||
|
||||
return Redirect("Debiting");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//получение номера запрашиваемого счёта для снятия - для работы с начислениями и списаниями
|
||||
[HttpPost]
|
||||
public string GetAccountNumber(int id)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
Response.Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APICashier.Debiting = APICashier.GetRequest<DebitingViewModel>($"/api/Account/FindDebiting?id={id}");
|
||||
|
||||
APICashier.Crediting = APICashier.GetRequest<CreditingViewModel>($"/api/Account/FindCrediting?id={id}");
|
||||
|
||||
if (APICashier.Debiting == null)
|
||||
{
|
||||
APICashier.Card = APICashier.GetRequest<CardViewModel>($"/api/Card/FindCard?id={APICashier.Crediting.CardId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
APICashier.Card = APICashier.GetRequest<CardViewModel>($"/api/Card/FindCard?id={APICashier.Debiting.CardId}");
|
||||
}
|
||||
|
||||
APICashier.Account = APICashier.GetRequest<AccountViewModel>($"/api/Account/GetAccount?accountId={APICashier.Card.AccountId}");
|
||||
|
||||
string AccountNumber = APICashier.Account.AccountNumber;
|
||||
|
||||
APICashier.Debiting = null;
|
||||
APICashier.Card = null;
|
||||
APICashier.Account = null;
|
||||
|
||||
return AccountNumber;
|
||||
}
|
||||
|
||||
// Работа с переводом со счёта на счёт
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult MoneyTransfers()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
|
||||
return View();
|
||||
}
|
||||
public IActionResult Accounts()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
[HttpPost]
|
||||
public IActionResult MoneyTransfers(int accountSenderId, int accountPayeeId, int sumMoneyTransfer)
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (accountPayeeId <= 0 || accountSenderId <= 0 || sumMoneyTransfer <= 0)
|
||||
{
|
||||
APICashier.SetErrorMessage("Проверьте корректность передаваемых значений");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APICashier.PostRequest("/api/Account/CloseCrediting", new MoneyTransferBindingModel
|
||||
{
|
||||
CashierId = APICashier.Cashier.Id,
|
||||
Sum = sumMoneyTransfer,
|
||||
AccountPayeeId = accountPayeeId,
|
||||
AccountSenderId = accountSenderId
|
||||
});
|
||||
|
||||
return Redirect("Index");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Отчёт с выборкой по счетам
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ReportWithAccounts()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
|
||||
return View(new List<ReportCashierAccountsViewModel>());
|
||||
}
|
||||
|
||||
//создание excel отчёта у касира
|
||||
[HttpPost]
|
||||
public IActionResult CreateCashierExcelReport(string accountId)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(accountId))
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо выбрать счёт для создания отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APICashier.PostRequest("api/Report/CreateExcelCashier", new ReportSupportBindingModel()
|
||||
{
|
||||
AccountId = int.Parse(accountId),
|
||||
Email = APICashier.Cashier.Email
|
||||
});
|
||||
|
||||
return Redirect("ReportSuccess");
|
||||
}
|
||||
|
||||
//создание excel отчёта у касира
|
||||
[HttpPost]
|
||||
public IActionResult CreateCashierWordReport(string accountId)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(accountId))
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо выбрать счёт для создания отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APICashier.PostRequest("api/Report/CreateWordCashier", new ReportSupportBindingModel()
|
||||
{
|
||||
AccountId = int.Parse(accountId),
|
||||
Email = APICashier.Cashier.Email
|
||||
});
|
||||
|
||||
return Redirect("ReportSuccess");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult ReportWithAccounts(string accountId)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(accountId))
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо выбрать счёт для создания отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
var cashWithdrawals = APICashier.GetRequest<List<CashWithdrawalViewModel>>("api/Account/FindAllCashWithdrawal").Where(x => x.AccountId == int.Parse(accountId))
|
||||
.Select(x => new ReportCashierAccountsViewModel
|
||||
{
|
||||
Sum = (int)x.Sum,
|
||||
AccountSenderNumber = x.AccountNumber,
|
||||
DateOperation = x.DateWithdrawal,
|
||||
typeOperation = TypeOperationEnum.Снятие
|
||||
});
|
||||
|
||||
var moneyTransfers = APICashier.GetRequest<List<MoneyTransferViewModel>>("/api/Account/FindAllMoneyTransfer").Where(x => (x.AccountPayeeId == int.Parse(accountId) || x.AccountSenderId == int.Parse(accountId)))
|
||||
.Select(x => new ReportCashierAccountsViewModel
|
||||
{
|
||||
CashierSurname = x.CashierSurname,
|
||||
Sum = (int)x.Sum,
|
||||
AccountPayeeNumber = x.AccountPayeeNumber,
|
||||
AccountSenderNumber = x.AccountSenderNumber != null ? x.AccountSenderNumber : "---",
|
||||
DateOperation = x.DateTransfer,
|
||||
typeOperation = x.AccountSenderId.HasValue ? TypeOperationEnum.Перевод : TypeOperationEnum.Пополнение
|
||||
});
|
||||
|
||||
return View(cashWithdrawals.Concat(moneyTransfers).OrderBy(x => x.DateOperation).ToList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Получение отчёта PDF
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateReport()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
//запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net
|
||||
ViewBag.Clients = APICashier.GetRequest<List<ClientViewModel>>($"/api/Client/GetAllClients").Select(x => new ClientSelectViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
FullName = x.Surname + " " + x.Name + " " + x.Patronymic
|
||||
}).ToList();
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult CreateReport(int clientId, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (clientId <= 0 || dateFrom == dateTo || dateFrom > dateTo || dateFrom.Year == 0001 || dateTo.Year == 0001)
|
||||
{
|
||||
APICashier.SetErrorMessage("Пожалуйста, установите корректные границы периода для отчёта и выберите счёт");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
//запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net
|
||||
ViewBag.Clients = APICashier.GetRequest<List<ClientViewModel>>($"/api/Client/GetAllClients").Select(x => new ClientSelectViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
FullName = x.Surname + " " + x.Name + " " + x.Patronymic
|
||||
}).ToList();
|
||||
|
||||
return View(APICashier.PostRequestReport<ReportCashierViewModelForHTML, ReportSupportBindingModel>("api/Report/CreateCashierReport", new ReportSupportBindingModel()
|
||||
{
|
||||
ClientId = clientId,
|
||||
Email = APICashier.Cashier.Email,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Диаграмма
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Diagram()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>($"api/Account/GetAllAccounts");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Diagram(int accountId)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
if (accountId <= 0)
|
||||
{
|
||||
APICashier.SetErrorMessage("Для построения диаграммы необходимо выбрать счёт");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>($"api/Account/GetAllAccounts");
|
||||
|
||||
|
||||
return View(new CashierDiagramViewModel()
|
||||
{
|
||||
DiagramName = "Hello World",
|
||||
Elements = APICashier.GetRequest<List<CashierDiagramElementsViewModel>>($"api/Account/getAccountMonthResult?cardId={accountId}")
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ReportSuccess()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
APICashier.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
Response.Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,11 @@
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Сначала авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateAccount">Открыть счёт</a>
|
||||
</p>
|
||||
@ -35,6 +40,28 @@
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.AccountNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Patronymic)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Balance)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOpen)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
53
Bank/BankCashierApp/Views/Home/CloseCrediting.cshtml
Normal file
53
Bank/BankCashierApp/Views/Home/CloseCrediting.cshtml
Normal file
@ -0,0 +1,53 @@
|
||||
@{
|
||||
ViewData["Title"] = "Одобрение зачислений";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Зачисление</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-2">
|
||||
<div class="col-4">Номер запроса на зачисление:</div>
|
||||
<div class="col-8">
|
||||
<select id="creditigId" name="creditingId" class="form-control" asp-items="@(new SelectList( @ViewBag.Creditings, "Id", "Id"))">
|
||||
<option disabled selected>Выберите запрос</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-4">Запрашиваемый счёт для зачисления:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" id="accountNumber" class="form-control" name="accountNumber" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-4">Номер счёта для зачисления:</div>
|
||||
<div class="col-8">
|
||||
<select id="accountPayeeId" name="accountPayeeId" class="form-control" asp-items="@(new SelectList( @ViewBag.Accounts, "Id", "AccountNumber"))" required>
|
||||
<option disabled selected>Выберите счёт</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<input type="submit" style="width: 100%" value="Начислить" class="btn btn-dark" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- подгрузка номера запрашиваемого клиентом счёта в реальном времени -->
|
||||
<script>
|
||||
$('#creditigId').on('change', function () {
|
||||
check();
|
||||
});
|
||||
|
||||
function check() {
|
||||
var creditigId = $('#creditigId').val();
|
||||
$.ajax({
|
||||
method: "Post",
|
||||
url: "/Home/GetAccountNumber",
|
||||
data: { id: creditigId },
|
||||
success: function (result) {
|
||||
$("#accountNumber").val(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
53
Bank/BankCashierApp/Views/Home/CloseDebiting.cshtml
Normal file
53
Bank/BankCashierApp/Views/Home/CloseDebiting.cshtml
Normal file
@ -0,0 +1,53 @@
|
||||
@{
|
||||
ViewData["Title"] = "Одобрение снятия";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Снятие</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-4">
|
||||
<div class="col-4">Номер запроса на снятие:</div>
|
||||
<div class="col-8">
|
||||
<select id="debitingId" name="debitingId" class="form-control" asp-items="@(new SelectList( @ViewBag.Debitings, "Id", "Id"))">
|
||||
<option disabled selected>Выберите запрос</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
<div class="col-4">Запрашиваемый счёт для перевода:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" class="form-control" id="accountNumber" name="accountNumber" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
<div class="col-4">Номер счёта для снятия:</div>
|
||||
<div class="col-8">
|
||||
<select id="accountId" name="accountId" class="form-control" asp-items="@(new SelectList( @ViewBag.Accounts, "Id", "AccountNumber"))" required>
|
||||
<option disabled selected>Выберите счёт</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
<input type="submit" style="width: 100%" value="Снять" class="btn btn-dark" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- подгрузка номера запрашиваемого клиентом счёта в реальном времени -->
|
||||
<script>
|
||||
$('#debitingId').on('change', function () {
|
||||
check();
|
||||
});
|
||||
|
||||
function check() {
|
||||
var debitingId = $('#debitingId').val();
|
||||
$.ajax({
|
||||
method: "Post",
|
||||
url: "/Home/GetAccountNumber",
|
||||
data: { id: debitingId },
|
||||
success: function (result) {
|
||||
$("#accountNumber").val(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
61
Bank/BankCashierApp/Views/Home/Crediting.cshtml
Normal file
61
Bank/BankCashierApp/Views/Home/Crediting.cshtml
Normal file
@ -0,0 +1,61 @@
|
||||
@using BankContracts.ViewModels.Client.ViewModels
|
||||
|
||||
@model List<CreditingViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Заявки на зачисление";
|
||||
}
|
||||
|
||||
<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="CloseCrediting">Одобрение заявки</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер заявки
|
||||
</th>
|
||||
<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.CardNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateCredit)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
62
Bank/BankCashierApp/Views/Home/Debiting.cshtml
Normal file
62
Bank/BankCashierApp/Views/Home/Debiting.cshtml
Normal file
@ -0,0 +1,62 @@
|
||||
@using BankContracts.ViewModels.Client.ViewModels
|
||||
|
||||
|
||||
@model List<DebitingViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Заявки на снятия";
|
||||
}
|
||||
|
||||
<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="CloseDebiting">Одобрение заявки</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер заявки
|
||||
</th>
|
||||
<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.CardNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateDebit)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
88
Bank/BankCashierApp/Views/Home/Diagram.cshtml
Normal file
88
Bank/BankCashierApp/Views/Home/Diagram.cshtml
Normal file
@ -0,0 +1,88 @@
|
||||
@using BankContracts.ViewModels.Cashier.Diagram
|
||||
|
||||
@model CashierDiagramViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Диаграмма";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Диаграмма суммарных поступлений на счёт по месяцам</h1>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row mb-2">
|
||||
<div class="row">Номер счета:</div>
|
||||
<select id="accountId" name="accountId" class="form-control" asp-items="@(new SelectList( @ViewBag.Accounts, "Id", "AccountNumber"))">
|
||||
<option disabled selected>Выберите счёт</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<input style="width:100%;" type="submit" value="Выбрать" class="btn btn-dark" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@if (Model == null) return;
|
||||
|
||||
<div id="Diagrams" class="text-center">
|
||||
<div id="@Model.DiagramName Diagram">
|
||||
<canvas id="Chart"></canvas>
|
||||
<div id="params">
|
||||
@foreach (var info in Model.Elements)
|
||||
{
|
||||
<input type="hidden" id="@info.Name" value="@info.Value" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
<script>
|
||||
const diagrams = document.getElementById('Diagrams').childNodes;
|
||||
|
||||
let diagram_name = diagrams[1].id;
|
||||
|
||||
console.log(diagram_name);
|
||||
let diagram = document.getElementById(diagram_name).childNodes;
|
||||
console.log(diagram);
|
||||
let labels = [];
|
||||
let data = [];
|
||||
document.getElementById('params').childNodes.forEach(element => {
|
||||
if (element.id != undefined) {
|
||||
labels.push(element.id);
|
||||
}
|
||||
});
|
||||
document.getElementById('params').childNodes.forEach(element => {
|
||||
if (element.id != undefined) {
|
||||
data.push(Number(element.value));
|
||||
}
|
||||
});
|
||||
|
||||
new Chart(diagram.item(1), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Денег в этом месяце',
|
||||
data: data,
|
||||
borderWidth: 1,
|
||||
backgroundColor: 'rgb(33, 37, 41)'
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
suggestedMin: Math.min(data) - Math.min(data) * -0.1,
|
||||
suggestedMax: Math.max(data) + Math.max(data) * 0.1,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
</script>
|
10
Bank/BankCashierApp/Views/Home/ErrorPage.cshtml
Normal file
10
Bank/BankCashierApp/Views/Home/ErrorPage.cshtml
Normal file
@ -0,0 +1,10 @@
|
||||
@using BankCashierApp
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Отправка отчета";
|
||||
}
|
||||
|
||||
<div class="text-center p-5">
|
||||
<h3 class="display-4">Упс, что-то пошло не так...</h3>
|
||||
<h3 class="display-4">Ошибка: @APICashier.ErrorMessage</h3>
|
||||
</div>
|
@ -9,11 +9,17 @@
|
||||
<div class="row mb-2">
|
||||
<div class="col-4">Номер счёта для снятия:</div>
|
||||
<div class="col-8">
|
||||
<select id="accountSenderId" name="accountSenderId" class="form-control" asp-items="@(new SelectList( @ViewBag.Accounts, "Id", "AccountNumber"))">
|
||||
<option disabled selected>Выберите счёт</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-4">Номер счёта для начисления:</div>
|
||||
<div class="col-8">
|
||||
<select id="accountPayeeId" name="accountPayeeId" class="form-control" asp-items="@(new SelectList( @ViewBag.Accounts, "Id", "AccountNumber"))">
|
||||
<option disabled selected>Выберите счёт</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
|
@ -1,19 +1,38 @@
|
||||
@{
|
||||
ViewData["Title"] = "Регистрация";
|
||||
ViewData["Title"] = "Регистрация";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
|
||||
<form class="form-signin text-center" method="post">
|
||||
<h1 class="h3 mb-3 font-weight-normal">Регистрация</h1>
|
||||
<input type="email" id="login" name="login" class="form-control" placeholder="Почта" required>
|
||||
<input type="password" id="password" name="password" class="form-control" placeholder="Пароль" required>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Имя" required>
|
||||
<input type="text" id="surname" name="surname" class="form-control" placeholder="Фамилия" required>
|
||||
<input type="text" id="patronymic" name="patronymic" class="form-control" placeholder="Отчество" required>
|
||||
<input type="text" id="telephone" name="telephone" class="form-control" placeholder="Телефон" required>
|
||||
<input type="email" id="login" name="login" class="form-control short-input mb-2" placeholder="Почта" required>
|
||||
<input type="password" id="password" name="password" class="form-control short-input mb-2" placeholder="Пароль" required>
|
||||
<input type="text" id="name" name="name" class="form-control short-input mb-2" placeholder="Имя" required>
|
||||
<input type="text" id="surname" name="surname" class="form-control short-input mb-2" placeholder="Фамилия" required>
|
||||
<input type="text" id="patronymic" name="patronymic" class="form-control short-input mb-2" placeholder="Отчество" required>
|
||||
<input type="text" id="telephone" name="telephone" class="form-control short-input mb-2" placeholder="Телефон" required>
|
||||
|
||||
<button class="btn btn-lg btn-warning btn-block" type="submit" asp-controller="Home" asp-action="Register">Регистрация</button>
|
||||
<button class="btn btn-lg btn-dark btn-block mt-3" type="submit" asp-controller="Home" asp-action="Register">Зарегистрироваться</button>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.form-signin {
|
||||
max-width: 300px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.short-input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.mb-2 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mt-3 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
|
15
Bank/BankCashierApp/Views/Home/ReportSuccess.cshtml
Normal file
15
Bank/BankCashierApp/Views/Home/ReportSuccess.cshtml
Normal file
@ -0,0 +1,15 @@
|
||||
@{
|
||||
ViewData["Title"] = "Отправка отчета";
|
||||
}
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
<h3 class="display-4">Сначала авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
}
|
||||
<h3 class="display-4">Отчeт был отправлен на почту @APICashier.Cashier.Email</h3>
|
||||
</div>
|
88
Bank/BankCashierApp/Views/Home/ReportWithAccounts.cshtml
Normal file
88
Bank/BankCashierApp/Views/Home/ReportWithAccounts.cshtml
Normal file
@ -0,0 +1,88 @@
|
||||
@using BankContracts.ViewModels.Reports.Cashier
|
||||
|
||||
@model List<ReportCashierAccountsViewModel>?
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Отчет по счетам";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Отчет</h1>
|
||||
</div>
|
||||
|
||||
<div class="container" sf-type="container" sf-label="Bootstrap Container" sf-uid="2">
|
||||
|
||||
<div class="row" sf-type="container" sf-label="Row" sf-uid="3">
|
||||
<div class="mb-4 mb-md-0 aos-init aos-animate col-md-3" sf-type="container" sf-label="Column" sf-anim-delay="1.5" data-aos="fade-down" data-aos-delay="400" sf-uid="4">
|
||||
<div sf-type="container" sf-label="Container" class="py-15 h-100 bg-bg-2" sf-uid="5">
|
||||
<form method="post">
|
||||
<select id="accountId" name="accountId" class="form-control mb-2" asp-items="@(new SelectList(ViewBag.Accounts, "Id", "AccountNumber"))">
|
||||
<option disabled selected>Выберите счёт</option>
|
||||
</select>
|
||||
<div class="mb-2">
|
||||
<button class="btn btn-lg btn-dark btn-block" style="width: 100%;" type="submit" asp-controller="Home" asp-action="ReportWithAccounts">Создать отчёт по аккаунтам</button>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<button class="btn btn-lg btn-dark btn-block" style="width: 100%;" type="submit" asp-controller="Home" asp-action="CreateCashierExcelReport">Создать отчёт по заявкам снятия (EXCEL)</button>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<button class="btn btn-lg btn-dark btn-block" style="width: 100%;" type="submit" asp-controller="Home" asp-action="CreateCashierWordReport">Создать отчёт по заявкам снятия (WORD</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aos-init aos-animate col-md" sf-type="container" sf-label="Column" sf-anim-delay="2" data-aos="fade-down" data-aos-delay="500" sf-uid="8">
|
||||
<div sf-type="container" sf-label="Container" class="py-15 h-100 bg-bg-2" sf-uid="9">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Тип операции
|
||||
</th>
|
||||
<th>
|
||||
Кассир
|
||||
</th>
|
||||
<th>
|
||||
Счет отправителя
|
||||
</th>
|
||||
<th>
|
||||
Счет получателя
|
||||
</th>
|
||||
<th>
|
||||
Сумма операции
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.typeOperation)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CashierSurname)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.AccountSenderNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.AccountPayeeNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOperation)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -58,6 +58,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.ViewModels.Cashier.ViewModels
|
||||
{
|
||||
public class ClientSelectViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -12,6 +12,6 @@ namespace BankDataModels.Enums
|
||||
|
||||
Пополнение = 2,
|
||||
|
||||
Переыод = 3
|
||||
Перевод = 3
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -13,6 +13,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BankBusinessLogic\BankBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||
<ProjectReference Include="..\BankDatabaseImplement\BankDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -1,12 +1,244 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BankContracts.BindingModels.Reports;
|
||||
using BankContracts.BusinessLogicsContracts.Reports;
|
||||
using BankContracts.ViewModels.Reports;
|
||||
using BankDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestAPI.Controllers
|
||||
{
|
||||
public class ReportController : Controller
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ReportController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IReportClientLogic _reportClientLogic;
|
||||
|
||||
private readonly IReportCashierLogic _reportCashierLogic;
|
||||
|
||||
//хранят данные для отображения отчёта на вебе
|
||||
private ReportClientViewModelForHTML _reportClientViewModelForHTML;
|
||||
|
||||
private ReportCashierViewModelForHTML _reportCashierViewModelForHTML;
|
||||
|
||||
public ReportController(ILogger<ReportController> logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_reportClientLogic = reportClientLogic;
|
||||
_reportCashierLogic = reportCashierLogic;
|
||||
}
|
||||
|
||||
|
||||
//метод генерации отчёта за период по картам клиента
|
||||
[HttpPost]
|
||||
public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт_по_картам.pdf",
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
Role = MailsEnum.Клиент,
|
||||
Email = model.Email
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//метод генерации отчёта по всем счетм клиентов
|
||||
[HttpPost]
|
||||
public ReportCashierViewModelForHTML CreateCashierReport(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт_по_счетам.pdf",
|
||||
ClientId = model.ClientId,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
Role = MailsEnum.Кассир,
|
||||
Email = model.Email
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//отчёт клиента Excel по переводу денег
|
||||
[HttpPost]
|
||||
public void CreateExcelClient(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по переводам.xlsx",
|
||||
CardList = model.CardList,
|
||||
Email = model.Email
|
||||
}, OfficeOperationEnum.Между_cчетами);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//отчёт клиента Excel по переводу денег
|
||||
[HttpPost]
|
||||
public void CreateExcelCrediting(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по пополнениям.xlsx",
|
||||
CardList = model.CardList,
|
||||
Email = model.Email
|
||||
}, OfficeOperationEnum.Пополнение_карт);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//отчёт клиента Excel по выдаче денег
|
||||
[HttpPost]
|
||||
public void CreateExcelDebiting(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по снятиям.xlsx",
|
||||
CardList = model.CardList,
|
||||
Email = model.Email
|
||||
}, OfficeOperationEnum.Cнятие_с_карты);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//отчёт клиента Excel по переводу денег
|
||||
[HttpPost]
|
||||
public void CreateExcelCashier(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportCashierLogic.SaveAccountsToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по зявкам на снятие.xlsx",
|
||||
AccountId = model.AccountId,
|
||||
Email = model.Email
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//отчёт клиента Word по переводу денег
|
||||
[HttpPost]
|
||||
public void CreateWordClient(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportClientLogic.SaveToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по переводам.docx",
|
||||
CardList = model.CardList,
|
||||
Email = model.Email
|
||||
}, OfficeOperationEnum.Между_cчетами);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//отчёт клиента Word по переводу денег
|
||||
[HttpPost]
|
||||
public void CreateWordCrediting(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportClientLogic.SaveToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по пополнениям.docx",
|
||||
CardList = model.CardList,
|
||||
Email = model.Email
|
||||
}, OfficeOperationEnum.Пополнение_карт);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//отчёт клиента Word по выдаче денег
|
||||
[HttpPost]
|
||||
public void CreateWordDebiting(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportClientLogic.SaveToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по снятиям.docx",
|
||||
CardList = model.CardList,
|
||||
Email = model.Email
|
||||
}, OfficeOperationEnum.Cнятие_с_карты);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//отчёт клиента Word по переводу денег
|
||||
[HttpPost]
|
||||
public void CreateWordCashier(ReportSupportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportCashierLogic.SaveAccountsToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по зявкам на снятие.docx",
|
||||
AccountId = model.AccountId,
|
||||
Email = model.Email
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,20 @@
|
||||
|
||||
|
||||
using BankBusinessLogic.BusinessLogic.Cashier;
|
||||
using BankBusinessLogic.BusinessLogic.Client;
|
||||
using BankBusinessLogic.BusinessLogic.Reports;
|
||||
using BankBusinessLogic.MailWorker;
|
||||
using BankBusinessLogic.OfficePackage;
|
||||
using BankBusinessLogic.OfficePackage.Implements;
|
||||
using BankContracts.BindingModels.Messages;
|
||||
using BankContracts.BusinessLogicsContracts.Cashier;
|
||||
using BankContracts.BusinessLogicsContracts.Client;
|
||||
using BankContracts.BusinessLogicsContracts.Reports;
|
||||
using BankContracts.StoragesModels.Cashier;
|
||||
using BankContracts.StoragesModels.Client;
|
||||
using BankDatabaseImplement.Implements.CashierImplements;
|
||||
using BankDatabaseImplement.Implements.ClientImplements;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
||||
@ -7,6 +22,33 @@ builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<ICashierStorage, CashierStorage>();
|
||||
builder.Services.AddTransient<IAccountStorage, AccountStorage>();
|
||||
builder.Services.AddTransient<ICardStorage, CardStorage>();
|
||||
builder.Services.AddTransient<ICreditingStorage, CreditingStorage>();
|
||||
builder.Services.AddTransient<IMoneyTransferStorage, MoneyTransferStorage>();
|
||||
builder.Services.AddTransient<IDebitingStorage, DebitingStorage>();
|
||||
builder.Services.AddTransient<ICashWithdrawalStorage, CashWithdrawalStorage>();
|
||||
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<ICashierLogic, CashierLogic>();
|
||||
builder.Services.AddTransient<IAccountLogic, AccountLogic>();
|
||||
builder.Services.AddTransient<ICardLogic, CardLogic>();
|
||||
builder.Services.AddTransient<ICreditingLogic, CreditingLogic>();
|
||||
builder.Services.AddTransient<IMoneyTransferLogic, MoneyTransferLogic>();
|
||||
builder.Services.AddTransient<IDebitingLogic, DebitingLogic>();
|
||||
builder.Services.AddTransient<ICashWithdrawalLogic, CashWithdrawalLogic>();
|
||||
|
||||
builder.Services.AddTransient<IReportClientLogic, ReportClientLogic>();
|
||||
builder.Services.AddSingleton<IReportCashierLogic, ReportCashierLogic>();
|
||||
|
||||
builder.Services.AddSingleton<MailKitWorker>();
|
||||
|
||||
//îáùèå êëàññû ôîðìèðîâàíè îò÷¸òîâ
|
||||
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
@ -15,6 +57,16 @@ builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
var mailSender = app.Services.GetService<MailKitWorker>();
|
||||
|
||||
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()),
|
||||
});
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user