public bool CheckAddIP(string code) { IPVerificationContext db = new IPVerificationContext(); var verification = from profile in db.IPVerificationEntries where profile.Code == code select profile; if (verification != null) { IPVerificationModel IPVerification = verification.ToArray().First(); CustSecurityContext dbNew = new CustSecurityContext(); IPProfile newProfile = new IPProfile(IPVerification.Username, IPVerification.IP); dbNew.IPProfiles.Add(newProfile); dbNew.SaveChanges(); db.IPVerificationEntries.Remove(IPVerification); db.SaveChanges(); return true; } return false; }
public ActionResult Create(IPProfile ipprofile) { if (ModelState.IsValid) { db.IPProfiles.Add(ipprofile); db.SaveChanges(); return RedirectToAction("Index"); } return View(ipprofile); }
private IPDetails GetDetails(string ip) { if (_context.IPProfiles.Any(p => p.IP == ip)) { return(_context.IPProfiles.Where(p => p.IP == ip).First()); } else { var pDetails = _client.GetDetails(ip); var profile = new IPProfile(pDetails) { IP = ip }; _context.IPProfiles.Add(profile); _context.SaveChanges(); return(profile); } }
public void createIPVerification(IPProfile ipProfile) { //Insert your domain here to be able to send correct email verification //Insert it like this: http://www.yourname.com string hostAdress = ""; IPVerificationContext db = new IPVerificationContext(); string validationString; for (int i = 0; true; i++) { validationString = GenerateCode(); var codes = from profile in db.IPVerificationEntries select profile.Code; string[] codeArray = codes.ToArray(); if (!codeArray.Contains(validationString)) { break; } } IPVerificationModel verification = new IPVerificationModel(ipProfile.Username, ipProfile.IP, validationString); db.IPVerificationEntries.Add(verification); db.SaveChanges(); if (hostAdress != "") { MailController.SendMailInner(ipProfile.Username, "IP verificatie", "Hallo, er is geprobeert om op uw account in te loggen vanaf een IP dat niet eerder hiervoor is gebruikt. Als u dit was kunt u op de link hieronder klikken. Was u dit niet, dan hoeft u niks te doen. " + hostAdress + "/test/" + validationString); } }
public ActionResult Edit(IPProfile ipprofile) { if (ModelState.IsValid) { db.Entry(ipprofile).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(ipprofile); }