Ejemplo n.º 1
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.User.Attach(user);
         db.ObjectStateManager.ChangeObjectState(user, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.RoleId = new SelectList(db.Role, "Id", "Name", user.RoleId);
     return View(user);
 }
Ejemplo n.º 2
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.User.AddObject(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.RoleId = new SelectList(db.Role, "Id", "Name", user.RoleId);
            return View(user);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="roleId">Initial value of the RoleId property.</param>
 /// <param name="isActive">Initial value of the IsActive property.</param>
 /// <param name="city">Initial value of the City property.</param>
 /// <param name="age">Initial value of the Age property.</param>
 public static User CreateUser(global::System.Int32 id, global::System.String name, global::System.String email, global::System.String password, global::System.Int32 roleId, global::System.Boolean isActive, global::System.String city, global::System.Int32 age)
 {
     User user = new User();
     user.Id = id;
     user.Name = name;
     user.Email = email;
     user.Password = password;
     user.RoleId = roleId;
     user.IsActive = isActive;
     user.City = city;
     user.Age = age;
     return user;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the User EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUser(User user)
 {
     base.AddObject("User", user);
 }
Ejemplo n.º 5
0
 public ActionResult ForgotPassword(User model, string returnUrl)
 {
     return RedirectToAction("Index", "Enter");
     //return View(model);
 }
Ejemplo n.º 6
0
        public ActionResult Register(User model)
        {
            if (ModelState.IsValid)
            {
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.Name, model.Password, model.Email, null, null, true, null, out createStatus);
                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.Name, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Enter");
                }
                else
                {
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 7
0
        public ActionResult LogOn(User model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                //if (Membership.ValidateUser(model.Name, model.Password))
                if (true)
                {
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Enter");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }