Beispiel #1
0
        public IHttpActionResult Delete([FromUri] string username)
        {
            IEnumerable <string> key;

            Request.Headers.TryGetValues("ApiKey", out key);
            Models.UserDatabaseAccess dbUser = new Models.UserDatabaseAccess();
            if (username == dbUser.getUserIfExists(key.First()).UserName)
            {
                try
                {
                    log(message: "User/Delete - Pass", apiKey: key.First());
                }
                catch (Exception e)
                {
                    if (username == dbUser.getUserIfExists(key.First()).UserName)
                    {
                        return(Ok(false.ToString()));
                    }
                    else
                    {
                        return(Ok(dbUser.deleteUser(key.First()).ToString()));
                    }
                }
                return(Ok(dbUser.deleteUser(key.First()).ToString()));
            }
            log(message: "User/Delete - Fail", apiKey: key.First());
            return(Ok(false.ToString()));
        }
Beispiel #2
0
        public IHttpActionResult GetHello()
        {
            IEnumerable <string> key;

            Request.Headers.TryGetValues("ApiKey", out key);
            Models.UserDatabaseAccess dbUser = new Models.UserDatabaseAccess();
            string response = "Hello " + dbUser.getUserIfExists(key.First()).UserName;

            log(message: "Protected/Hello - Pass", apiKey: key.First());
            return(Ok(response));
        }