public IActionResult Confirm(string key) { ViewBag.Title = "confirm your account"; using (var acontext = new SnContext()) { var account = acontext.Accounts.FirstOrDefault(a => a.key == key); if (account == null) { string msg = "Your account was not registered or could not be found. Please submit " + "for registration again."; Flash(msg, "danger"); } else { if (account.verified == false) { account.verified = true; acontext.Accounts.Update(account); acontext.SaveChanges(); } string msg = "The account " + account.email + "@st-andrews.ac.uk " + "(" + account.uname + ") " + "has been succesfuly registered and confirmed. Please save your password, " + "you are authenticated to access all features of stacsnet"; Flash(msg, "success"); } } return(RedirectToAction("Index", "Home")); }
public IActionResult Comment(string return_url, QAPost post) { using (var context = new SnContext()) { post.date = DateTime.Now; context.QAPosts.Add(post); context.SaveChanges(); Flash("Comment posted", "success"); } return(Redirect(return_url)); }
public QAThread Children() { QAThread thread = new QAThread(); using (var context = new SnContext()) { thread.posts = context.QAPosts.Where(p => p.pid == id).ToList(); thread.header = this; context.SaveChanges(); } return(thread); }
public IActionResult Submit(string return_url, GradeReport report) { if (ModelState.IsValid) { using (var context = new SnContext()) { context.GradeReports.Add(report); context.SaveChanges(); } Flash("submission received", "success"); } else { Flash("submission not received", "danger"); } return(Redirect(return_url)); }
public IActionResult Submit(Account account) { string key = Guid.NewGuid().ToString(); using (var acontext = new SnContext()) { var model = new Account(); var old_account = acontext.Accounts.FirstOrDefault(a => a.email == account.email); if (old_account != null) { if (old_account.verified) { string msg = "The email address " + account.email + " has been registered and confirmed. The username and password you supplied when creating the account" + " are valid to authenticate you on this site."; Flash(msg, "success"); } else { string msg = "The email address " + account.email + "@st-andrews.ac.uk has already submitted for registration. " + "Please check your emails from [email protected] and open the confirmation link supplied."; Flash(msg, "warning"); } } else { Send(account.email, account.uname, key); var hasher = new PasswordHasher <Account>(); account.key = key; account.pwhash = hasher.HashPassword(account, account.pwhash); account.verified = false; acontext.Accounts.Add(account); acontext.SaveChanges(); string msg = "The email address " + account.email + "@st-andrews.ac.uk" + " was succesfully submitted for registration. " + "Please check your emails from [email protected] and open the confirmation link supplied."; Flash(msg, "info"); } return(RedirectToAction("Index", "Home")); } }
public void Save() { db.SaveChanges(); }