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