예제 #1
0
 public IActionResult Login(LoginInputModels loginModel)
 {
     if (ModelState.IsValid)
     {
         AccountService.AccountService authService = new AccountService.AccountService();
         var resultCode = authService.Login(loginModel) as LoginServiceResult;
         if (resultCode.OperationCode == OperationCode.Success)
         {
             logger.LogInformation($"Log {resultCode.Login} {resultCode.UserType.ToString()}");
             Login(resultCode);
             return(RedirectToAction("Index", "Home"));
         }
     }
     return(View(loginModel));
 }
예제 #2
0
 public IActionResult Register(RegisterInputModel registerModel)
 {
     if (ModelState.IsValid)
     {
         registerModel.UserType = ShopEngine.Models.Database.UserType.User;
         AccountService.AccountService authService = new AccountService.AccountService();
         var resultCode = authService.Register(registerModel) as LoginServiceResult;
         if (resultCode.OperationCode == OperationCode.Success)
         {
             logger.LogInformation($"Register {resultCode.Login} {resultCode.UserType.ToString()}");
             Directory.CreateDirectory($"wwwroot\\images\\{registerModel.Login.Replace(".", "_").Replace("@", "_")}");
             Login(resultCode);
             return(RedirectToAction("Index", "Home"));
         }
     }
     return(View(registerModel));
 }
예제 #3
0
        static void Main(string[] args)
        {
            List <Account.Account> accounts = new List <Account.Account>();

            IAccountService accountService = new AccountService.AccountService();

            accountService.CreateAccount(new Account.Account(111, "Nikita", "Pundis", 5, AccountType.Base));
            accountService.CreateAccount(new Account.Account(112, "Andrey", "Vasilev", 40, AccountType.Gold));
            accountService.CreateAccount(new Account.Account(113, "Margarita", "Anisko", 120, AccountType.Premium));

            Print(accountService.GetAllAccounts());

            accountService.AddAmount(111);
            Print(accountService.GetAllAccounts());

            accountService.CloseAccount(112);
            Print(accountService.GetAllAccounts());

            accountService.DivAmount(113);
            Print(accountService.GetAllAccounts());

            Console.ReadKey();
        }
예제 #4
0
 public IActionResult ChangeType(User user)
 {
     AccountService.AccountService accountService = new AccountService.AccountService();
     accountService.ChangeRole(user.ID, user.UserType);
     return(Redirect("UserChangeType"));
 }