public bool checkLoginDetails(LoginModel loginDetails) { loginDetails.Password = hashPassword(loginDetails.Password); CustomerDal dalobj = new CustomerDal(); if(dalobj.LoginCheck(loginDetails)) return true; return false; }
public bool LoginCheck(LoginModel login) { bool status = false; HttpContext.Current.Session["UserRole"] = "visitor"; //HttpContext.Current.Session["UserID"] = "000"; string conStr = ConfigurationManager.ConnectionStrings["FashionableMeDB"].ConnectionString; SqlConnection conn = new SqlConnection(conStr); try { conn.Open(); SqlCommand cmd = new SqlCommand("select count(UserID) from Customer where UserID=@userid and PassWord=@pass ", conn); cmd.Parameters.AddWithValue("userid",login.UserID); cmd.Parameters.AddWithValue("pass",login.Password); int count = (Int32)cmd.ExecuteScalar(); //return count.ToString(); if (count==1) { HttpContext.Current.Session["UserID"] = login.UserID; if(login.UserID.ToLower() == "adminfme") HttpContext.Current.Session["UserRole"] = "admin"; else HttpContext.Current.Session["UserRole"] = "customer"; status = true; } } catch (Exception exc) { HttpContext.Current.Session["ErrorMessage"] = exc.Message; status = false; } conn.Close(); return status; }