public ActionResult CreateEditUser(UserModel model)
        {
            if (model.ID == 0)
            {
                User userEntity = new User()
                {
                    UserName = model.UserName,
                    Email = model.Email,
                    Password = model.Password,
                    AddedDate = DateTime.UtcNow,
                    ModifiedDate = DateTime.UtcNow,
                    IP = Request.UserHostAddress,

                    UserProfile = new UserProfile()
                    {
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        Address = model.Address,
                        AddedDate = DateTime.UtcNow,
                        ModifiedDate = DateTime.UtcNow,
                        IP = Request.UserHostAddress
                    }
                };
                _userService.InsertUser(userEntity);

                if (userEntity.ID > 0)
                {
                    return RedirectToAction("Index");
                }

            }
            else
            {
                User userEntity = _userService.GetUser(model.ID);
                userEntity.UserName = model.UserName;
                userEntity.Email = model.Email;
                userEntity.Password = model.Password;
                userEntity.ModifiedDate = DateTime.UtcNow;
                userEntity.IP = Request.UserHostAddress;
                userEntity.UserProfile.FirstName = model.FirstName;
                userEntity.UserProfile.LastName = model.LastName;
                userEntity.UserProfile.Address = model.Address;
                userEntity.UserProfile.IP = Request.UserHostAddress;

                _userService.UpdateUser(userEntity);

                if (userEntity.ID > 0)
                {
                    return RedirectToAction("Index");
                }
            }
            return View(model);
        }
        protected void Init1()
        {
            RedisClient redisClient = new RedisClient("127.0.0.1", 6379);
            var key_ = redisClient.Get<string>("key_");
            redisClient.Set("go", "狗");
            var user = new User
            {
                UserName = "******",
                Password = "******",
                Email = "*****@*****.**"
            };
            redisClient.Set<User>("UserModel", user);

            //redisClient
            redisClient.Custom("SET", "goto", 1);
            var c = redisClient.Custom(Commands.Get, "goto");
        }
Example #3
0
 public void UpdateUser(User user)
 {
     _userRepository.Update(user);
 }
Example #4
0
 public void InsertUser(User user)
 {
     _userRepository.Insert(user);
 }
Example #5
0
 public void DeleteUser(User user)
 {
     _userProfileRepository.Delete(user.UserProfile);
     _userRepository.Delete(user);
 }