Exemple #1
0
 protected void CreateUser_Click(object sender, EventArgs e)
 {
     var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
     var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
     var user = new ApplicationUser() { UserName = Username.Text, Email = Email.Text, PhoneNumber = MobileNo.Text };
     IdentityResult result = manager.Create(user, Password.Text);
     if (result.Succeeded)
     {
         // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
         //string code = manager.GenerateEmailConfirmationToken(user.Id);
         //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
         //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");
         result = manager.SetLockoutEnabled(user.Id, true);
         UserRoleActions role = new UserRoleActions();
         role.AddToNormalUserRole(user);
         signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
         using (MenStore.Logic.ShoppingCartActions usersShoppingCart = new MenStore.Logic.ShoppingCartActions())
         {
             String cartId = usersShoppingCart.GetCartId();
             usersShoppingCart.MigrateCart(cartId, user.Id);
         }
         IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
     }
     else
     {
         ErrorMessage.Text = result.Errors.FirstOrDefault();
     }
 }
Exemple #2
0
        public IQueryable<Product> GetProducts()
        {
            var _db = new ProductContext();
            IQueryable<Product> query = _db.Products;

            UserRoleActions user = new UserRoleActions();
            return query;
        }
Exemple #3
0
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     // Initialize the product database.
     Database.SetInitializer(new ProductDatabaseInitializer());
     // Create the custom role and user.
     UserRoleActions roleActions = new UserRoleActions();
     roleActions.AddUserAndRole();
     Automation auto = new Automation();
 }
        public IQueryable<Product> GetProduct([QueryString("productID")] int? productId)
        {
            var _db = new ProductContext();
            IQueryable<Product> query = _db.Products.Where(p => p.Status == true && p.UnitInStock > 0);
            query = query.Where(p => p.ProductID == productId);
            if (query.Count() > 0)
            {
                UserRoleActions user = new UserRoleActions();
                lblCreatedBy.Text = user.GetUserNameById(query.ToList()[0].CreatedBy);
                lblCreatedDate.Text = ((DateTime)query.ToList()[0].CreatedDate).ToShortDateString();
                if (query.ToList()[0].ModifiedBy != null)
                {
                    lblModifyBy.Text = user.GetUserNameById(query.ToList()[0].ModifiedBy);
                    lblModifyDate.Text = ((DateTime)query.ToList()[0].ModifiedDate).ToShortDateString();
                    proModifyby.Visible = true;
                }
            }
            else
            {
                query = null;
            }

            return query;
        }