ClientApp. Completed stress test.
This commit is contained in:
parent
55c66f20e4
commit
df7781a70c
@ -11,6 +11,8 @@ namespace BankYouBankruptСlientApp
|
||||
|
||||
public static ClientViewModel? Client { get; set; } = null;
|
||||
|
||||
public static string ErrorMessage = string.Empty;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
@ -18,6 +20,11 @@ namespace BankYouBankruptСlientApp
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static void SetErrorMessage(string error)
|
||||
{
|
||||
ErrorMessage = error;
|
||||
}
|
||||
|
||||
//Get-запрос
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
|
@ -27,14 +27,13 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
}
|
||||
|
||||
#region Профиль, вход и регистрация
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
@ -50,23 +49,32 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ErrorPage()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Login(string login, string password)
|
||||
[HttpPost]
|
||||
public IActionResult Login(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин и пароль");
|
||||
}
|
||||
APIClient.SetErrorMessage("Введите логин и пароль");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.Client = APIClient.GetRequest<ClientViewModel>($"api/Client/Login?login={login}&password={password}");
|
||||
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
APIClient.SetErrorMessage("Неверный логин или пароль");
|
||||
|
||||
Response.Redirect("Enter");
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
return Redirect("Enter");
|
||||
}
|
||||
|
||||
|
||||
@ -83,8 +91,10 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(name)
|
||||
|| string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(patronymic) || string.IsNullOrEmpty(telephone))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль, ФИО и телефон");
|
||||
}
|
||||
APIClient.SetErrorMessage("Проверьте правильность заполнения полей");
|
||||
|
||||
Response.Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Client/Register", new ClientBindingModel
|
||||
{
|
||||
@ -102,8 +112,10 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Logout() {
|
||||
public IActionResult Logout()
|
||||
{
|
||||
APIClient.Client = null;
|
||||
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
@ -130,8 +142,10 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
|| string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(patronymic)
|
||||
|| string.IsNullOrEmpty(telephone))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль, ФИО и телефон");
|
||||
}
|
||||
APIClient.SetErrorMessage("Проверьте правильность заполнения полей");
|
||||
|
||||
Response.Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("/api/Client/UpdateData", new ClientBindingModel
|
||||
{
|
||||
@ -180,18 +194,28 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult CreateCard(string accountId, string number, string cvc, string period) {
|
||||
public IActionResult CreateCard(string accountId, string number, string cvc, DateTime period) {
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
}
|
||||
APIClient.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(accountId) || string.IsNullOrEmpty(number) || string.IsNullOrEmpty(cvc)
|
||||
|| period.Year == 0001 || period <= DateTime.Now)
|
||||
{
|
||||
APIClient.SetErrorMessage("Проверьте корректность параметров создаваемой карты");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Card/CreateCard", new CardBindingModel {
|
||||
ClientID = APIClient.Client.Id,
|
||||
AccountId = int.Parse(accountId),
|
||||
Number = number,
|
||||
CVC = cvc,
|
||||
Period = DateTime.Parse(period)
|
||||
Period = period
|
||||
});
|
||||
|
||||
return Redirect("~/Home/CardsList");
|
||||
@ -229,8 +253,17 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
}
|
||||
APIClient.SetErrorMessage("Необходимо авторизоваться");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(cardId) || sum <= 0)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо ввести корректную сумму для снятия");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Card/CreateDebitingRequest", new DebitingBindingModel()
|
||||
{
|
||||
@ -278,7 +311,14 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
throw new Exception("Не авторизованы");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Card/CreateCreditingOperation", new CreditingBindingModel()
|
||||
if (string.IsNullOrEmpty(cardId) || sum <= 0)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо ввести корректную сумму для пополнения");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Card/CreateCreditingOperation", new CreditingBindingModel()
|
||||
{
|
||||
CardId = int.Parse(cardId),
|
||||
Sum = sum,
|
||||
@ -312,9 +352,14 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
throw new Exception("Не авторизованы");
|
||||
}
|
||||
|
||||
//ViewBag.DataOfClientReport = APIClient.GetRequest<ReportClientViewModelForHTML>($"api/Report/GetDataOfClientReport");
|
||||
if (dateFrom == dateTo || dateFrom > dateTo || dateFrom.Year == 0001 || dateTo.Year == 0001)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо задать корректные границы периода");
|
||||
|
||||
return View(APIClient.PostRequestReport<ReportClientViewModelForHTML, ReportSupportBindingModel>("api/Report/CreateClientReport", new ReportSupportBindingModel()
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
return View(APIClient.PostRequestReport<ReportClientViewModelForHTML, ReportSupportBindingModel>("api/Report/CreateClientReport", new ReportSupportBindingModel()
|
||||
{
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
@ -322,30 +367,36 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
}));
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Excel отчёты
|
||||
#region Excel отчёты
|
||||
|
||||
//отчёт клиента по переводам
|
||||
[HttpPost]
|
||||
public IActionResult CreateExcelReport(List<CheckboxViewModel> cards)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateExcelReport(List<CheckboxViewModel> cards)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
APIClient.PostRequest("api/Report/CreateExcelClient", new ReportSupportBindingModel()
|
||||
{
|
||||
CardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList(),
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (cards.Count == 0 || cards.Count == cards.Where(x => x.IsChecked == false).ToList().Count)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо выбрать хотя-бы 1 карту для отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Report/CreateExcelClient", new ReportSupportBindingModel()
|
||||
{
|
||||
CardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList(),
|
||||
Email = APIClient.Client.Email
|
||||
});
|
||||
|
||||
return Redirect("ReportSuccess");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return Redirect("ReportSuccess");
|
||||
}
|
||||
|
||||
//отчёт клиента по пополнениям
|
||||
[HttpPost]
|
||||
@ -353,7 +404,16 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (cards.Count == 0 || cards.Count == cards.Where(x => x.IsChecked == false).ToList().Count)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо выбрать хотя-бы 1 карту для отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Report/CreateExcelCrediting", new ReportSupportBindingModel()
|
||||
@ -371,7 +431,16 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (cards.Count == 0 || cards.Count == cards.Where(x => x.IsChecked == false).ToList().Count)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо выбрать хотя-бы 1 карту для отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Report/CreateExcelDebiting", new ReportSupportBindingModel()
|
||||
@ -393,7 +462,16 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (cards.Count == 0 || cards.Count == cards.Where(x => x.IsChecked == false).ToList().Count)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо выбрать хотя-бы 1 карту для отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Report/CreateWordClient", new ReportSupportBindingModel()
|
||||
@ -411,7 +489,16 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (cards.Count == 0 || cards.Count == cards.Where(x => x.IsChecked == false).ToList().Count)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо выбрать хотя-бы 1 карту для отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Report/CreateWordCrediting", new ReportSupportBindingModel()
|
||||
@ -429,7 +516,16 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (cards.Count == 0 || cards.Count == cards.Where(x => x.IsChecked == false).ToList().Count)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо выбрать хотя-бы 1 карту для отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/Report/CreateWordDebiting", new ReportSupportBindingModel()
|
||||
@ -465,12 +561,21 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
[HttpPost]
|
||||
public IActionResult ReportWithCards(List<CheckboxViewModel> cards)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
List<int> cardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList();
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
if (cards.Count == 0 || cards.Count == cards.Where(x => x.IsChecked == false).ToList().Count)
|
||||
{
|
||||
APIClient.SetErrorMessage("Необходимо выбрать хотя-бы 1 карту для отчёта");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
List<int> cardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList();
|
||||
|
||||
List<ReportViewModel> creditings = APIClient.GetRequest<List<CreditingViewModel>>($"api/Client/getUsersCreditings?userId={APIClient.Client.Id}")
|
||||
.Where(x => cardList.Contains(x.CardId)).Select(x => new ReportViewModel() {
|
||||
@ -524,13 +629,14 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
[HttpPost]
|
||||
public IActionResult Diagram(int cardId)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
|
||||
|
||||
return View(new ClientDiagramViewModel() {
|
||||
DiagramName = "Hello World",
|
||||
@ -543,11 +649,14 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult ReportSuccess()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
}
|
||||
return View();
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
APIClient.SetErrorMessage("Не авторизованы");
|
||||
|
||||
return Redirect("ErrorPage");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
@using BankYouBankruptСlientApp
|
||||
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Страница пользователя";
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
@using BankYouBankruptСlientApp
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Отправка отчета";
|
||||
}
|
||||
|
||||
<div class="text-center p-5">
|
||||
<h3 class="display-4">Упс, что-то пошло не так...</h3>
|
||||
<h3 class="display-4">Ошибка: @APIClient.ErrorMessage</h3>
|
||||
</div>
|
@ -1,9 +1,9 @@
|
||||
@using BankYouBankruptСlientApp
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Отправка отчета";
|
||||
}
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (APIClient.Client == null)
|
||||
|
@ -1,4 +1,5 @@
|
||||
@model ErrorViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user