//GET: Admin/Password public ActionResult ChangePassword() { try { ChangePassword cp = new ChangePassword(); string cookieName = FormsAuthentication.FormsCookieName; HttpCookie authCookie = HttpContext.Request.Cookies[cookieName]; FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); string emailAddress = ticket.Name; cp.user.Email = emailAddress; if (CheckForRootAdmin(emailAddress)) { ViewBag.isAdmin = true; return(View(cp)); } else { ViewBag.isAdmin = false; return(View(cp)); } } catch (Exception e) { DataLink.LogError(e); throw; } }
//GET: Admin/PasswordOverride public ActionResult PasswordOverride(int?id) { try { AdminChangePassword change = new AdminChangePassword(); if (id != null) { Users user = ViewModels.GetUser(id); change.user.Email = user.Email; } string emailAddress = GetEmailFromToken(FormsAuthentication.FormsCookieName); if (CheckForRootAdmin(emailAddress)) { ViewBag.isAdmin = true; return(View(change)); } else { ViewBag.isAdmin = false; return(View(change)); } } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult PasswordOverride(AdminChangePassword change, int id) { try { //Check inputs are not null if (ModelState.IsValid) { if (change.confirmPassword != null && change.newPassword != null) { //Check that new is equal to confirm if (change.confirmPassword.Equals(change.newPassword)) { //Check password complexity if (CheckComplexity(change.newPassword)) { change.user = ViewModels.GetUser(id); change.user.Password = Encrypter.ComputeHash(change.newPassword, null); ViewModels.UpdateUser(change.user, EntityState.Modified); return(RedirectToAction("Delete")); } else { change.ComplexityError = true; change.confirmError = change.blankFieldError = false; change.newPassword = change.confirmPassword = null; return(View(change)); } } else { change.confirmError = true; change.ComplexityError = change.blankFieldError = false; change.newPassword = change.confirmPassword = null; return(View(change)); } } else { change.blankFieldError = true; change.ComplexityError = change.confirmError = false; change.newPassword = change.confirmPassword = null; return(View(change)); } } change.confirmError = true; change.ComplexityError = change.blankFieldError = false; change.newPassword = null; change.confirmPassword = null; return(View(change)); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Create(CreateNewUser newUser) { try { if (ModelState.IsValid) { if (CheckValidateEmail(newUser.user.Email)) { if (!ViewModels.CheckForUser(newUser.user.Email)) { if (CheckComplexity(newUser.user.Password)) { newUser.user.Password = Encrypter.ComputeHash(newUser.user.Password, null); Users myUser = new Users(); myUser.Email = newUser.user.Email; myUser.Password = newUser.user.Password; ViewModels.CreateUser(myUser); } else { newUser.passwordError = true; newUser.emailError = false; newUser.blankFieldError = false; newUser.user.Email = null; newUser.user.Password = null; return(View(newUser)); } } else { newUser.emailError = true; newUser.passwordError = false; newUser.blankFieldError = false; newUser.user.Email = null; newUser.user.Password = null; return(View(newUser)); } } else { newUser.emailError = true; newUser.passwordError = false; newUser.blankFieldError = false; newUser.user.Email = null; newUser.user.Password = null; return(View(newUser)); } } return(RedirectToAction("Delete")); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Login(Login login) { try { if (ModelState.IsValid) { //A user has been returned. Pull out the email that is specified. Has the user's password and compare it to the hash in the database. if (login.user.Email != null && login.user.Password != null) { if (ViewModels.CheckForUser(login.user.Email)) { //Get the information for the user they are trying to login as Users u = ViewModels.GetUser(login.user.Email); //Check to the entered password against the saved password if (Encrypter.VerifyHash(login.user.Password, u.Password)) { if (FormsAuthentication.FormsCookieName != null) { FormsAuthentication.SignOut(); } //TODO: Figure out how to set the validation for a user FormsAuthentication.SetAuthCookie(login.user.Email, false); return(RedirectToAction("ReportHome")); } else { //It failed so return the view with the user input login.Error = true; login.user.Password = null; return(View(login)); } } else { login.Error = true; login.user.Email = null; login.user.Password = null; return(View(login)); } } } login.Error = true; login.user.Email = null; login.user.Password = null; return(View(login)); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Index() { try { return(View()); } catch (Exception e) { DataLink.LogError(e); throw; } }
// GET: Battery/CalcBat public ActionResult Index() { try { Battery battery = new Battery(); return(View(battery)); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Login() { try { Login login = new Login(); return(View(login)); } catch (Exception e) { DataLink.LogError(e); throw; } }
// NO LONGER USED // //GET: Admin/Account //public ActionResult Account() //{ // try // { // List<Users> userList = ViewModels.GetAllUsers(); // return View(userList); // } // catch (Exception e) // { // DataLink.LogError(e); // throw; // } //} //GET: Admin/Logoff public ActionResult LogOff() { try { FormsAuthentication.SignOut(); return(RedirectToAction("Login")); } catch (Exception e) { DataLink.LogError(e); throw; } }
// GET: UserInputsDC/CalcDC public ActionResult Index() { try { Models.PowerDC PowerDC = new Models.PowerDC(); return(View(PowerDC)); } catch (Exception e) { DataLink.LogError(e); throw; } }
// GET: Capacitor/CalcCap public ActionResult Index() { try { Capacitors capacitor = new Capacitors(); return(View(capacitor)); } catch (Exception e) { DataLink.LogError(e); throw; } }
//public ActionResult index() //{ // return View(); //} // GET: SubRF/CalcSubRF public ActionResult Index() { try { SubRF powerSubRF = new SubRF(); return(View(powerSubRF)); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Contact() { try { ViewBag.Message = "Your contact page."; return(View()); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult About() { try { ViewBag.Message = "Your application description page."; return(View()); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult DeleteConfirmed(int id) { try { UserInputs60Hz userInputs60Hz = db.userInputs60Hz.Find(id); db.userInputs60Hz.Remove(userInputs60Hz); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Index(SubRF subRF) { try { if (ModelState.IsValid) { //Do stuff here } return(View()); } catch (Exception e) { DataLink.LogError(e); throw; } }
protected override void Dispose(bool disposing) { try { if (disposing) { db.Dispose(); } base.Dispose(disposing); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Index(PowerDC powerDC) { try { if (ModelState.IsValid) { ViewModels.CreateUserInputsDC(powerDC.Inputs); } return(View()); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Delete(int id) { try { if (ModelState.IsValid) { ViewModels.DeleteUser(id); } return(RedirectToAction("Delete")); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Edit([Bind(Include = "Id,PotMaxExp,AvailSCC,Duration,IPAddress")] UserInputsDC userInputsDC) { try { if (ModelState.IsValid) { db.Entry(userInputsDC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userInputsDC)); } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult Edit([Bind(Include = "Id,TransSize,Impedance,SCC,FaultClearing,Voltage,FreeAir,IPAddress")] UserInputs60Hz userInputs60Hz) { try { if (ModelState.IsValid) { db.Entry(userInputs60Hz).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userInputs60Hz)); } catch (Exception e) { DataLink.LogError(e); throw; } }
// ------------------------------- These are the important actionresults// // GET: UserInputs60Hz/Details/5 public ActionResult Details(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserInputs60Hz userInputs60Hz = db.userInputs60Hz.Find(id); if (userInputs60Hz == null) { return(HttpNotFound()); } return(View(userInputs60Hz)); } catch (Exception e) { DataLink.LogError(e); throw; } }
//GET: Admin/ReportIP public ActionResult ReportIp() { try { string emailAddress = GetEmailFromToken(FormsAuthentication.FormsCookieName); if (CheckForRootAdmin(emailAddress)) { ViewBag.isAdmin = true; return(View()); } else { ViewBag.isAdmin = false; return(View()); } } catch (Exception e) { DataLink.LogError(e); throw; } }
//GET: Admin/Delete public ActionResult Delete() { try { AdminControl adminControl = new AdminControl(); string emailAddress = GetEmailFromToken(FormsAuthentication.FormsCookieName); if (CheckForRootAdmin(emailAddress)) { ViewBag.isAdmin = true; return(View(adminControl)); } else { ViewBag.isAdmin = false; return(RedirectToAction("ReportHome")); } } catch (Exception e) { DataLink.LogError(e); throw; } }
public ActionResult ChangePassword(ChangePassword changedPassword) { try { //ModelState doesn't seem to serve much of a purpose - manually check if fields are null if (ModelState.IsValid) { //Check that no fields were left blank if (changedPassword.user.Email != null && changedPassword.user.Password != null && changedPassword.confirmPassword != null && changedPassword.newPassword != null) { //Check that the password is complex enough if (CheckComplexity(changedPassword.newPassword)) { //Check that the new and confirmed password match if (changedPassword.newPassword.Equals(changedPassword.confirmPassword)) { //Email is our email Users user = ViewModels.GetUser(changedPassword.user.Email); //Check that the oldpassword matches our password if (Encrypter.VerifyHash(changedPassword.user.Password, user.Password)) { user.Password = Encrypter.ComputeHash(changedPassword.newPassword, null); ViewModels.UpdateUser(user, System.Data.Entity.EntityState.Modified); return(RedirectToAction("ReportHome")); } else { changedPassword.UserOrPasswordError = true; changedPassword.blankFieldError = false; changedPassword.confirmError = false; changedPassword.PasswordComplexityError = false; changedPassword.user.Email = null; changedPassword.user.Password = null; return(View(changedPassword)); } } else { changedPassword.confirmError = true; changedPassword.PasswordComplexityError = false; changedPassword.blankFieldError = false; changedPassword.UserOrPasswordError = false; changedPassword.user.Email = null; changedPassword.user.Password = null; return(View(changedPassword)); } } else { changedPassword.PasswordComplexityError = true; changedPassword.blankFieldError = false; changedPassword.confirmError = false; changedPassword.UserOrPasswordError = false; changedPassword.user.Email = null; changedPassword.user.Password = null; return(View(changedPassword)); } } else { changedPassword.blankFieldError = true; changedPassword.PasswordComplexityError = false; changedPassword.confirmError = false; changedPassword.UserOrPasswordError = false; changedPassword.user.Email = null; changedPassword.user.Password = null; return(View(changedPassword)); } } changedPassword.UserOrPasswordError = true; return(View(changedPassword)); } catch (Exception e) { DataLink.LogError(e); throw; } }