Exemplo n.º 1
0
        //private static string NewPassGen()
        //{
        //    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        //    var stringChars = new char[8];
        //    var random      = new Random();
        //    for (int i = 0; i < stringChars.Length; i++)
        //    {
        //        stringChars[i] = chars[random.Next(chars.Length)];
        //    }
        //    return new String(stringChars);
        //}

        private static bool CreateAccount(User user)
        {
            var salt = PasswordHash.CreateSalt();

            user.Password = PasswordHash.CreateHash(user.Password, salt.ToArray());

            if (user.UserId != Guid.Empty)
            {
                return(QsDataRepository.CreateNewUser(user, salt));
            }
            //New user
            //user.UserId = Guid.NewGuid();
            return(QsDataRepository.CreateNewUser(user, salt));
        }
        public HttpResponseMessage CreateNewUser(User user)
        {
            var result = QsDataRepository.CreateNewUser(user, null);

            return(Request.CreateResponse(result ? HttpStatusCode.OK : HttpStatusCode.NotFound, result));
        }