public SignUpViewModel RegisterUser(SignUpViewModel userInfo)
        {
            userInfo.Password = CommonUtilities.MD5Hash(userInfo.Password);
            var isRegistered = TwitterCloneDataAccess.RegisterUser(userInfo);

            userInfo.isRegistered = isRegistered;
            return(userInfo);
        }
        public ActionResult RegisterUser(SignUpViewModel regUser)
        {
            if (ModelState.IsValid)
            {
                regUser = _tcBLayer.RegisterUser(regUser);

                if (!regUser.isRegistered)
                {
                    ModelState.AddModelError("UserName", "Something went wrong, Please try later.");
                }
            }
            return(View("signUp", regUser));
        }
        public static SignUpViewModel GetProfile(string userId)
        {
            SignUpViewModel pr = new SignUpViewModel();

            using (var _context = new TwitterCloneDBEntities())
            {
                var items = _context.People.Where(x => x.user_id.Trim() == userId.Trim()).FirstOrDefault();
                if (items != null && items.user_id != null)
                {
                    pr.UserName = items.user_id;
                    pr.Email    = items.email;
                    pr.FullName = items.fullName;
                    pr.Password = items.password;
                }
            }

            return(pr);
        }
        public static bool RegisterUser(SignUpViewModel userInfo)
        {
            bool isRegistered = false;

            try
            {
                using (var _context = new TwitterCloneDBEntities())
                {
                    var items = _context.People.Where(x => x.user_id.ToUpper().Trim() == userInfo.UserName.ToUpper().Trim()).FirstOrDefault();

                    if (items == null)
                    {
                        Person user = new Person();
                        user.user_id  = userInfo.UserName;
                        user.password = userInfo.Password;
                        user.fullName = userInfo.FullName;
                        user.email    = userInfo.Email;
                        user.joined   = DateTime.Now;
                        user.active   = true;

                        _context.People.Add(user);
                    }
                    else
                    {
                        items.password = userInfo.Password;
                        items.fullName = userInfo.FullName;
                    }

                    _context.SaveChanges();
                    isRegistered = true;
                }
            }
            catch (Exception ex)
            {
                isRegistered = false;
            }

            return(isRegistered);
        }