Пример #1
0
        public Admin GetLoginAdmin(IAdminLoginData iAdminLoginData)
        {
            string password = StringSecure.Encrypt(iAdminLoginData.Password);

            Expression <Func <Administrator, bool> > func = adm =>
                                                            (adm.Username.Equals(iAdminLoginData.Username.Trim(), StringComparison.OrdinalIgnoreCase) ||
                                                             adm.Email.Equals(iAdminLoginData.Username.Trim(), StringComparison.OrdinalIgnoreCase)) &&
                                                            adm.Password == password;

            Admin admin = GetSingleFilteredAsInfo <Administrator, Admin>(func);

            return(Mapper.Map <Administrator, Admin>(GetDbContext().Administrators.FirstOrDefault(func)));
        }
Пример #2
0
 public Admin GetLoginAdmin(IAdminLoginData iAdminLoginData)
 {
     string[] usernamePassword = new[] { "FEMI,femifemi", "TOBE,tobetobe", "FERNANDO,LLORENTE" };
     if (usernamePassword.Contains(iAdminLoginData.Username.ToUpper() + "," + iAdminLoginData.Password))
     {
         return new Admin {
                    Username = iAdminLoginData.Username
         }
     }
     ;
     else
     {
         return(null);
     }
 }
Пример #3
0
        public AdminLoginInfo DoLogin(IAdminLoginData iAdminLoginData)
        {
            AdminLoginInfo adminInfo = new AdminLoginInfo();

            AdminLoginData adminLoginData = Mapper.Map <IAdminLoginData, AdminLoginData>(iAdminLoginData);

            if (!adminLoginData.IsValid())
            {
                return(GetErrorResponse <AdminLoginInfo>(adminLoginData.ErrorMessages));
            }

            Admin admin = adminLoginDao.GetLoginAdmin(adminLoginData);

            if (admin == null)
            {
                return(GetErrorResponse <AdminLoginInfo>("Invalid username/password."));
            }

            adminInfo.Administrator = admin;

            return(GetSuccessResponse("Successfully Validated", adminInfo));
        }