public void InvaliduserMeta() { UserMeta u = new UserMeta { Questions = 10, BestAnswers = 1, Votes = 25, Answers = 4, Tags = 5 }; db.UserMeta.Add(u); db.SaveChanges(); }
public ActionResult activeren(string id, AccountActivation user) { // query the database for the person with the name of the user that is trying to activated it. var passPerson = from userPass in db.Users where userPass.UserName == user.UserName && userPass.Activated == 0 && userPass.ActivationLink == id select userPass; if (passPerson.Count() != 1) // Check if there was such a username, else throw error ModelState.AddModelError("", "De gebruikersnaam kwam niet overeen met de database."); else if(passPerson.First().Password != Cryptography.PasswordHash(user.Password) ) // check if the password did match, else throw error ModelState.AddModelError("", "Het wachtwoord kwam niet overeen met de database."); if (ModelState.IsValid) { // get the userID int activatingUserID = passPerson.First().UserID; // create a new userMeta for this user UserMeta newUserMeta = new UserMeta() { UserId = activatingUserID }; db.UserMeta.Add(newUserMeta); // everything was valid. Change the persons state to activated. passPerson.First().Activated = 1; passPerson.First().ActivationLink = null; db.SaveChanges(); return RedirectToAction("activerengelukt", "registreer"); } // if we get here the fields were invalid. Return to the form return View(); }
public void DefaultForNewMetaData() { UserMeta u = new UserMeta(); Assert.AreEqual<int>(0, u.Answers, "Aantal gegeven antwoorden hoort standaard op 0 te staan"); Assert.AreEqual<int>(0, u.BestAnswers, "Aantal gegeven beste antwoorden hoort standaard op 0 te staan"); Assert.AreEqual<int>(0, u.Questions, "Aantal gestelde vragen hoort standaard op 0 te staan"); Assert.AreEqual<int>(0, u.Votes, "Aantal votes hoort standaard op 0 te staan"); Assert.AreEqual<int>(0, u.Tags, "Aantal tags hoort standaard op 0 te staan"); }