public ActionResult RegUser(RegUserModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Username or Password invalid");
                return(View(model));
            }

            var salt     = Hash.CreateSalt(16);
            var passhash = Hash.GenerateSaltedHash(model.Password, salt);
            // Console.WriteLine("Start");
            var user = new BLL.DTO.UserDTO
            {
                BirthDate       = model.BirthDate,
                PostsId         = new List <int>(),
                IsProfileShared = model.SharedProfile,
                LoginName       = model.LoginName,
                Nickname        = model.Nickname,
                CreateTime      = DateTime.Now,
                Salt            = Convert.ToBase64String(salt),
                PasswordHash    = Convert.ToBase64String(passhash)
            };


            try
            {
                DbManager.CreateOrUpdateUser(user);
            }
            catch (Exception ex)
            {
                ViewBag.Error  = ex.Message;
                model.Password = null;

                return(View(model));
            }
            return(RedirectToAction("Login"));
        }