Пример #1
0
        public ActionResult Edit(int? id)
        {
            var userToEdit = new User();
              if (id.HasValue)
              {
            userToEdit = (from i in Core.DataContext.Users where i.ID == id.Value select i).SingleOrDefault();

              }
              return View(userToEdit);
        }
Пример #2
0
        public static User CreateNewUser(User newUser)
        {
            var exists = false;
              User createdUser = new User();
              createdUser = newUser;

              //var query = (from u in Core.DataContext.Users where u.ID == userID select u).FirstOrDefault();
              //if (query != null)
              //{
              //  exists = true;
              //}

              return createdUser;
        }
Пример #3
0
 public static User CreateUserAndAccount(RegisterModel registerDates)
 {
     var newRegisteredUser = new User();
       newRegisteredUser.Email = registerDates.Email;
       newRegisteredUser.UserName = registerDates.Email;
       newRegisteredUser.UniqueKey = Guid.NewGuid().ToString();
       newRegisteredUser.FirstName = registerDates.FirstName;
       newRegisteredUser.LastName = registerDates.LastName;
       newRegisteredUser.Password = registerDates.Password;
       newRegisteredUser.RoleID = (int)Core.Roles.User;
       newRegisteredUser.AddedDate = DateTime.Now;
       Core.DataContext.Users.Add(newRegisteredUser);
       Core.DataContext.SaveChanges();
       return newRegisteredUser;
 }
Пример #4
0
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
              {
            if (user.ID > 0)
            {
              User userToUpdate = UsersManager.GetUserByEmail(user.Email);
              if (userToUpdate != null)
              {
            TryUpdateModel(userToUpdate);
              }

            }
            else
            {
              Core.DataContext.Users.Add(UsersManager.CreateNewUser(user));
            }
            Core.DataContext.SaveChanges();

            return RedirectToAction("List");
              }

              return View();
        }
Пример #5
0
        public ActionResult Register(RegisterModel model)
        {
            var newUSer = new User();
              if (ModelState.IsValid)
              {
            if (!UsersManager.CheckExistingUserByEmail(model.Email))
            {
              newUSer = UsersManager.CreateUserAndAccount(model);
              FormsAuthentication.SetAuthCookie(model.Email, false);
              ZazaIdentity.Current.CurrentUser = newUSer;
            }
            return RedirectToAction("Index", "Home");

              }

              return View(model);
        }