public HttpResponseMessage Get([FromUri] string Username)
 {
     if (ud.CheckUserName(Username) == true)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.OK, "True - User Does Exist! Did you mean to do a POST to create a new user?"));
     }
     else
     {
         return(Request.CreateErrorResponse(HttpStatusCode.OK, "False - User Does Not Exist! Did you mean to do a POST to create a new user?"));
     }
 }
Exemplo n.º 2
0
        public HttpResponseMessage Post([FromBody] JObject username)
        {
            string user = username.GetValue("username").ToString();
            string role = username.GetValue("role").ToString();

            if (role == "User" || role == "Admin")
            {
                var dbaccess = new UserDatabaseAccess();
                if (!dbaccess.CheckUserName(user))
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "NOT DONE: Username does not exist"));
                }
                else if (dbaccess.ChangeRole(user, role))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "DONE"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "NOT DONE: An error occured"));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "NOT DONE: Role does not exist"));
            }
        }
Exemplo n.º 3
0
        public HttpResponseMessage Get([FromUri] string username)
        {
            var dbaccess = new UserDatabaseAccess();

            if (dbaccess.CheckUserName(username))
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "True - User Does Exist! Did you mean to do a POST to create a new user?"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "False - User Does Not Exist! Did you mean to do a POST to create a new user?"));
            }
        }
Exemplo n.º 4
0
        public HttpResponseMessage Post([FromBody] string username)
        {
            if (string.IsNullOrEmpty(username))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Oops. Make sure your body contains a string with your username and your Content - Type is Content - Type:application / json"));
            }
            var dbaccess = new UserDatabaseAccess();

            if (dbaccess.CheckUserName(username))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "Oops. This username is already in use. Please try again with a new username."));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dbaccess.NewUser(username)));
            }
        }