@ -24,6 +24,8 @@ namespace OperatorApp.Controllers
private readonly ICurrencyLogic _currencyLogic ;
private readonly AbstractMailWorker _mailWorker ;
public static OperatorViewModel ? Operator ;
public HomeController ( ILogger < HomeController > logger , IDealLogic dealLogic , IPaymentLogic paymentLogic , ITransferLogic transferLogic , IOperatorLogic operatorLogic , IReportLogic reportLogic , ICurrencyLogic currencyLogic , AbstractMailWorker mailWorker )
{
_logger = logger ;
@ -38,28 +40,28 @@ namespace OperatorApp.Controllers
public IActionResult Index ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
return Redirect ( "~/Home/Enter" ) ;
}
return View ( _dealLogic . ReadList ( new DealSearchModel { OperatorId = APIClient . Operator . Id } ) ) ;
return View ( _dealLogic . ReadList ( new DealSearchModel { OperatorId = HomeController . Operator . Id } ) ) ;
}
[HttpGet]
public IActionResult Privacy ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
}
return View ( APIClient . Operator ) ;
return View ( HomeController . Operator ) ;
}
[HttpPost]
public void Privacy ( string login , string password , string lastname , string firstname , string middleName )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return ;
@ -70,7 +72,7 @@ namespace OperatorApp.Controllers
}
_operatorLogic . Update ( new OperatorBindingModel
{
Id = APIClient . Operator . Id ,
Id = HomeController . Operator . Id ,
LastName = lastname ,
FirstName = firstname ,
MiddleName = middleName ,
@ -78,11 +80,11 @@ namespace OperatorApp.Controllers
Password = password
} ) ;
APIClient . Operator . LastName = lastname ;
APIClient . Operator . FirstName = firstname ;
APIClient . Operator . MiddleName = middleName ;
APIClient . Operator . Login = login ;
APIClient . Operator . Password = password ;
HomeController . Operator . LastName = lastname ;
HomeController . Operator . FirstName = firstname ;
HomeController . Operator . MiddleName = middleName ;
HomeController . Operator . Login = login ;
HomeController . Operator . Password = password ;
Response . Redirect ( "Index" ) ;
}
@ -106,8 +108,8 @@ namespace OperatorApp.Controllers
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('Input login and password!');window.location.replace('/Home/Enter');</script>" ) ;
return ;
}
APIClient . Operator = _operatorLogic . ReadElement ( new OperatorSearchModel { Login = login , Password = password } ) ;
if ( APIClient . Operator = = null )
HomeController . Operator = _operatorLogic . ReadElement ( new OperatorSearchModel { Login = login , Password = password } ) ;
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('Wrong login or password!');window.location.replace('/Home/Enter');</script>" ) ;
return ;
@ -142,7 +144,7 @@ namespace OperatorApp.Controllers
[HttpGet]
public IActionResult CreateDeal ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
@ -153,7 +155,7 @@ namespace OperatorApp.Controllers
[HttpPost]
public void CreateDeal ( int clientid )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return ;
@ -161,34 +163,34 @@ namespace OperatorApp.Controllers
_dealLogic . Create ( new DealBindingModel
{
ClientId = clientid ,
OperatorId = APIClient . Operator . Id ,
OperatorId = HomeController . Operator . Id ,
} ) ;
Response . Redirect ( "Index" ) ;
}
public IActionResult Payments ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
}
return View ( _paymentLogic . ReadList ( new PaymentSearchModel { OperatorId = APIClient . Operator . Id } ) ) ;
return View ( _paymentLogic . ReadList ( new PaymentSearchModel { OperatorId = HomeController . Operator . Id } ) ) ;
}
[HttpGet]
public IActionResult CreatePayment ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
}
ViewBag . Deals = _dealLogic . ReadList ( new DealSearchModel { OperatorId = APIClient . Operator . Id } ) ;
ViewBag . Deals = _dealLogic . ReadList ( new DealSearchModel { OperatorId = HomeController . Operator . Id } ) ;
return View ( ) ;
}
[HttpPost]
public void CreatePayment ( List < int > deals )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return ;
@ -199,13 +201,13 @@ namespace OperatorApp.Controllers
var deal = _dealLogic . ReadElement ( new DealSearchModel { Id = id } ) ;
if ( deal ! = null ) DealPayments . Add ( deal . Id , deal ) ;
}
_paymentLogic . Create ( new PaymentBindingModel { OperatorId = APIClient . Operator . Id , DealPayments = DealPayments , } ) ;
_paymentLogic . Create ( new PaymentBindingModel { OperatorId = HomeController . Operator . Id , DealPayments = DealPayments , } ) ;
Response . Redirect ( "Payments" ) ;
}
[HttpGet]
public IActionResult Payment ( int id )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
@ -215,39 +217,39 @@ namespace OperatorApp.Controllers
[HttpGet]
public IActionResult Transfers ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
}
return View ( _transferLogic . ReadList ( new TransferSearchModel { OperatorId = APIClient . Operator . Id } ) ) ;
return View ( _transferLogic . ReadList ( new TransferSearchModel { OperatorId = HomeController . Operator . Id } ) ) ;
}
[HttpGet]
public IActionResult CreateTransfer ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
}
ViewBag . Payments = _paymentLogic . ReadList ( new PaymentSearchModel { OperatorId = APIClient . Operator . Id } ) ;
ViewBag . Payments = _paymentLogic . ReadList ( new PaymentSearchModel { OperatorId = HomeController . Operator . Id } ) ;
return View ( ) ;
}
[HttpPost]
public void CreateTransfer ( string amount , int payment )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return ;
}
_transferLogic . Create ( new TransferBindingModel { OperatorId = APIClient . Operator . Id , Amount = ( float ) Convert . ToDouble ( amount ) , PaymentId = payment } ) ;
_transferLogic . Create ( new TransferBindingModel { OperatorId = HomeController . Operator . Id , Amount = ( float ) Convert . ToDouble ( amount ) , PaymentId = payment } ) ;
Response . Redirect ( "Transfers" ) ;
}
public void DeleteTransfer ( int id )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
}
@ -258,12 +260,12 @@ namespace OperatorApp.Controllers
[HttpGet]
public IActionResult PaymentsReport ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
}
ViewBag . Payments = _paymentLogic . ReadList ( new PaymentSearchModel { OperatorId = APIClient . Operator . Id } ) ;
ViewBag . Payments = _paymentLogic . ReadList ( new PaymentSearchModel { OperatorId = HomeController . Operator . Id } ) ;
return View ( ) ;
}
@ -302,7 +304,7 @@ namespace OperatorApp.Controllers
[HttpGet]
public IActionResult TransfersReport ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
@ -312,7 +314,7 @@ namespace OperatorApp.Controllers
[HttpPost]
public IActionResult TransfersReport ( DateTime dateFrom , DateTime dateTo , string reptype , string email , string fileName )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
@ -332,7 +334,7 @@ namespace OperatorApp.Controllers
_mailWorker . MailSendAsync ( new MailSendInfoBindingModel
{
Subject = "Отчёт о закупках" ,
Text = "Для оператора " + APIClient. Operator . LastName + APIClient . Operator . FirstName ,
Text = "Для оператора " + HomeController. Operator . LastName + HomeController . Operator . FirstName ,
MailAddress = email ,
FileName = fileName ,
Attachment = report
@ -349,7 +351,7 @@ namespace OperatorApp.Controllers
[HttpGet]
public IActionResult AddCurrenciesToPayment ( )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
return Redirect ( "/Home/Enter" ) ;
@ -361,7 +363,7 @@ namespace OperatorApp.Controllers
[HttpPost]
public void AddCurrenciesToPayment ( int payment , List < int > currencies )
{
if ( APIClient . Operator = = null )
if ( HomeController . Operator = = null )
{
Response . WriteAsync ( $"<script language=\" javascript \ ">alert('You need to login!');window.location.replace('/Home/Enter');</script>" ) ;
Redirect ( "/Home/Enter" ) ;