public async Task <ActionResult> Login(LogIn model) { if (Request.IsAuthenticated) { return(RedirectToAction("Index", "Items")); } if (!ModelState.IsValid) { return(View("Login", model)); } try { var UserStore = new UserStore <IdentityUser>(); var UserManager = new UserManager <IdentityUser>(UserStore); var User = await UserManager.FindAsync(model.UserName, model.Password); if (User != null) { using (var db = new data_Base()) { var dbUser = db.AspNetUsers.Single(u => u.Id == User.Id); if (dbUser.IsDisable == false) { var AuthenticationManager = System.Web.HttpContext.Current.GetOwinContext().Authentication; var UserIdentity = await UserManager.CreateIdentityAsync(User, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, UserIdentity); return(RedirectToAction("Index", "Items")); } else if (dbUser.IsDisable == true) { ViewBag.Account = "Your Account Is Locked"; return(View(model)); } } } ViewBag.UserError = "UserName And Password DoesNot Match"; return(View(model)); } catch (Exception e) { ViewBag.RegisterError = "Error While Loggin Your Account "; return(View("Register", model)); } }
public OrdersController() { db = new data_Base(); }
public IngredientsController() { db = new data_Base(); }
public ItemsController() { db = new data_Base(); }
public CategoriesController() { db = new data_Base(); }
public StripeController() { gateway = new StripeGateway("sk_test_gmsesQcld5Dm19hk4qtN0yjJ"); db = new data_Base(); }
public CartsController() { db = new data_Base(); }
public AccountsController() { db = new data_Base(); }