コード例 #1
0
        public bool CreateUser(User user)
        {
            //var CurUser = this.userRepository.GetUserByName(user.Name);
            if (GetUserIdByName(user.Login) != -1)
            {
                return false;
            }

            var newUser = new User()
            {
                LastName = user.LastName,
                SecondName = user.SecondName,
                Login = user.Login,
                Hash = _cryptoProvider.EncryptString(user.Hash),
                RoleId = 2,
                Street = user.Street,
                House = user.House,
                Flat = user.Flat,
                Party = null,
                PhoneNumber = user.PhoneNumber
            };

            _userRepository.CreateUser(newUser);
            return true;
        }
コード例 #2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    LastName = model.LastName,
                    FirstName = model.FirstName,
                    SecondName = model.SecondName,
                    Login = model.Login,
                    Hash = cryptoProvider.EncryptString(model.Password),
                    RoleId = 2,
                    Street = model.UserStreet,
                    House = model.UserHouse,
                    Flat = Convert.ToInt32(model.UserFlat),
                    Party = null,
                    PhoneNumber = model.UserPhoneNumber
                };
                if (this.userProcessor.CreateUser(user))
                {
                    this.userProcessor.LogOn(model.Login, model.Password);
                    var CurUser = this.userProcessor.GetUserByName(model.Login);
                    return this.RedirectToAction("Index", "Request");
                }
            }

            ModelState.AddModelError(string.Empty, "Невірні реєстраціїні дані");
            return this.View(model);
        }
コード例 #3
0
 public void UpdateUser(User user)
 {
     this.dataBaseContext.Entry(user).State = EntityState.Modified;
     this.dataBaseContext.SaveChanges();
 }
コード例 #4
0
 public void CreateUser(User user)
 {
     this.dataBaseContext.Entry(user).State = EntityState.Added;
     this.dataBaseContext.SaveChanges();
 }