public void TestGetLatestAchievement()
        {
            /* Definition of variables Ø*/
            int AchIdExpected = 1;
            string AchNameExpected = "Collector";
            string AchDescriptionExpected = "this is an achievement";
            int AchValueExpected = 10;
            string AchDateExpected = "13-03-2011 00:00:00";
             //int AchXpToAchieveExpected = -1;
             //int AchLvlToAchieveExpected = -1;

            /* Get the achievement */
            AchievementController achCtr = new AchievementController();
            Achievement expectedAch = new Achievement();
            expectedAch = achCtr.GetLatestAchievement(AchIdExpected);

            /* Comparison */
            int AchIdActual = expectedAch.AchievementId;
            string AchNameActual = expectedAch.Name;
            string AchDescriptionActual = expectedAch.Description;
            int AchValueActual = expectedAch.Value;
            string AchDateActual = expectedAch.DateAchieved.ToString();
                //int AchXpToAchieveActual = expectedAch.x

            Assert.AreEqual(AchIdExpected, AchIdActual);
            Assert.AreEqual(AchNameExpected, AchNameActual);
            Assert.AreEqual(AchDescriptionExpected, AchDescriptionActual);
            Assert.AreEqual(AchValueExpected, AchValueActual);
            Assert.AreEqual(AchDateExpected, AchDateActual);
        }
        public static Achievement GetAchievement(string userName, string password)
        {
            Achievement returnAchievement = new Achievement();

            string jsonString = "{\"UserName\":" + "\"" + userName + "\", " + "\"Password\":" + "\"" + password + "\"" + "}";
            Debug.WriteLine(jsonString);

            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create("http://localhost:3369/LevelService.svc/achievements/get");
            webReq.Method = "POST";                                     //Set metodetypen. Default er POST, men vi skriver det ALTID alligevel.
            webReq.ContentType = "application/json; charset=utf-8";     //Sæt contenttypen, i.e Sæt til JSON
            webReq.ContentLength = jsonString.Length;                     //Længden på strengen
            Debug.WriteLine(webReq.ContentLength.ToString() + jsonString.Length.ToString());

            using (StreamWriter sw = new StreamWriter(webReq.GetRequestStream()))   //Opret en streamwriter med vores request som parameter (aner ikke hvad requeststream er, slå det selv op)
            {
                sw.Write(jsonString);
            }

            try
            {
                HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();           //Opret et objekt der kan modtage svar på vores request
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))    //Opret et objekt der kan læse svaret
                {
                    string text = sr.ReadToEnd();                           //Læs svaret igennem og gem det i en streng. Det er JSON streng svaret kommer i.

                    returnAchievement = JSONhelper.JsonDeserialize<Achievement>(text);    //kør json-strengen igennem deserialiseringen, med PersonModel som type objekt
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            return returnAchievement;
        }
        public Achievement GetLatestAchievement(int userId)
        {
            //By userID, find latest achievement and send to client
            Achievement latestAch = new Achievement();

            using (var db = new DataAccessContext())
            {
                var query = "select * from achievements as a where achievementid ="+
                            "(select achievement_achievementid from userachievements "+
                            "where  user_userid = 57 and achievement_achievementid = a.achievementid)";

                var data = db.Database.SqlQuery<Achievement>(query).First();
                latestAch = data;
            }
            return latestAch;
        }
        public void TestAssignAchievement()
        {
            List<Achievement> aList = new List<Achievement>();
            Achievement a1 = new Achievement
            {
                AchievementId = 520
            };

            Achievement a2 = new Achievement
            {
                AchievementId = 521
            };
            aList.Add(a1);
            aList.Add(a2);

            User u = new User
            {
                UserId = 65
            };

            UserController userCtr = new UserController();
            userCtr.AssignAchievement(aList, u);
        }