public void CreateUser(string username, string password, string email)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         SqlCommand command = new SqlCommand(UserQueries.CreateUser(username, password, email), connection);
         connection.Open();
         try
         {
             command.ExecuteNonQuery();
         }
         catch (SqlException e)
         {
             throw e;
         }
     }
 }
Exemple #2
0
        public IHttpActionResult Get(string email, string firstName, string lastName, string password, int userType)
        {
            int         userID = 0;
            UserQueries query  = new UserQueries();

            try
            {
                if (!email.Contains("stenden.com"))
                {
                    if (!email.Contains("@stenden.com") && userType.Equals(2))
                    {
                        return(BadRequest("Stenden email address required for docent registration."));
                    }
                    return(BadRequest("Stenden email address required for registration."));
                }
                userID = query.CreateUser(firstName, lastName, email, userType);
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }

            if (userID != 0)
            {
                try
                {
                    query.SetPassword(userID, password);
                }
                catch (Exception e)
                {
                    return(InternalServerError(e));
                }
            }
            else
            {
                return(InternalServerError());
            }
            return(Ok("Success"));
        }
Exemple #3
0
        public IHttpActionResult Get()
        {
            HttpContext context = HttpContext.Current;
            int         userID  = 0;
            UserQueries query   = new UserQueries();

            try
            {
                if (!context.Request["email"].Contains("@stenden.com") && context.Request["userType"].Equals(2))
                {
                    return(BadRequest("Stenden email address required for docent registration."));
                }

                userID = query.CreateUser();
                query.AddDocentData(userID);
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
            if (userID != 0)
            {
                try
                {
                    query.SetPassword(userID, context.Request["password"]);
                }
                catch (Exception e)
                {
                    return(InternalServerError(e));
                }
            }
            else
            {
                return(InternalServerError());
            }
            return(Ok("Success"));
        }