コード例 #1
0
ファイル: AdminController.cs プロジェクト: ibavli/Rent-A-Car
 public ActionResult Login(string Username, string Password)
 {
     if (Username.Length < 15 && Password.Length < 15)
     {
         Admin admin = _adminDal.GetAdmin(Username);
         if (admin != null)
         {
             if (admin.Password == CryptoPass(Username, Password, admin.Salt))
             {
                 if (admin.IsAccountActive == true)
                 {
                     MySessionModel mySessionModel = new MySessionModel();
                     mySessionModel.Id          = admin.AdminId;
                     mySessionModel.UserName    = admin.UserName;
                     mySessionModel.NameSurname = admin.Name + " " + admin.Surname;
                     mySessionModel.CarCount    = _carDal.GetCarCount();
                     mySessionModel.BranchCount = _branchDal.GetBranchCount();
                     Session["login"]           = mySessionModel;
                     return(RedirectToAction("Homepage", "AdminPanel"));
                 }
                 else
                 {
                     TempData["blocked"] = "Hesabınız aktif değildir. Lütfen epostanızdan kontrol ediniz.";
                     return(View());
                 }
             }
             else
             {
                 if (admin.IsAccountActive == true)
                 {
                     if (admin.PasswordEnteredIncorrectly == 4)
                     {
                         _adminDal.BlockedAdmin(admin);
                     }
                     else
                     {
                         _adminDal.SaveWrongPassword(admin);
                         TempData["wrongpassword"] = "******";
                     }
                 }
             }
         }
     }
     return(View());
 }