Ejemplo n.º 1
0
 public override string[] GetRolesForUser(string username)
 {
     using (EcommerceDBEntities _db = new EcommerceDBEntities())
     {
         var objUser = _db.tblUsers.FirstOrDefault(u => u.Username == username);
         if (objUser == null)
         {
             return(null);
         }
         else
         {
             string[] rtn = objUser.tblUserRoles.Select(u => u.tblRole.roleName).ToArray();
             return(rtn);
         }
     }
 }
Ejemplo n.º 2
0
 public ActionResult Login(LoginViewModel l, string ReturnUrl = "")
 {
     using (EcommerceDBEntities _db = new EcommerceDBEntities())
     {
         var users = _db.tblUsers.Where(u => u.Username == l.Username && u.Password == l.Password).FirstOrDefault();
         if (users != null)
         {
             FormsAuthentication.SetAuthCookie(l.Username, l.Rememberme);
             if (Url.IsLocalUrl(ReturnUrl))
             {
                 return(Redirect(ReturnUrl));
             }
             else
             {
                 return(RedirectToAction("Index", "Home"));
             }
         }
         else
         {
             ModelState.AddModelError("", "InvalidUser!!!");
         }
     }
     return(View());
 }
Ejemplo n.º 3
0
 public BaseService()
 {
     DBModel = DBHelper.CreateDBConnection();
 }
Ejemplo n.º 4
0
 public StockModel()
 {
     DBModel = new EcommerceDBEntities();
 }
Ejemplo n.º 5
0
 public LogModel()
 {
     DBModel = new EcommerceDBEntities();
 }
Ejemplo n.º 6
0
        public static EcommerceDBEntities CreateDBConnection()
        {
            DBConnection = DBConnection ?? new EcommerceDBEntities();

            return(DBConnection);
        }