public IActionResult DeleteIncident(string id) { using (mypidbContext db = new mypidbContext()) { IncidentData deleteMe = db.IncidentData.Where(x => x.IncidentId == id).FirstOrDefault(); db.IncidentData.Remove(deleteMe); db.SaveChanges(); return(RedirectToAction("EmpTable")); } }
public IActionResult EditComment(string id, IncidentData updatedIncident) { using (mypidbContext db = new mypidbContext()) { IncidentData incident = db.IncidentData.Where(x => x.IncidentId == id).FirstOrDefault(); if (incident != null) { incident.AdminComments = updatedIncident.AdminComments; db.SaveChanges(); } } return(RedirectToAction("EmpTable")); }
public ActionResult Register(HomeAccount account) { Console.WriteLine("User input data, from register"); Console.WriteLine("Username: "******"Password: "******"Email: " + account.EmailAddress); Console.WriteLine("First Name: " + account.FirstName); Console.WriteLine("Last Name: " + account.LastName); Console.WriteLine("Address: " + account.HomeAccountAddress); Console.WriteLine("PIN: " + account.AccountPin); Console.WriteLine("Phone Number: " + account.PhoneNumber); if (account.AccountPin == 0) { ViewBag.Message = "Unable to register, PIN must be a numerical value"; } else if (account.PhoneNumber == 0 || account.PhoneNumber.ToString().Length != 10) { ViewBag.Message = "Unable to register, phone number must be valid"; } else if (!isValidEmail(account.EmailAddress)) { ViewBag.Message = "Unable to register, invalid email address"; } else { try { using (mypidbContext db = new mypidbContext()) { db.HomeAccount.Add(account); db.SaveChanges(); } ViewBag.Message = account.EmailAddress + " successfully registered"; } catch { ViewBag.Message = "Unable to register user, please try again."; } } return(View()); }
public IActionResult Index(HomeAccount account) { using (mypidbContext db = new mypidbContext()) { HomeAccount loggedInAccount = db.HomeAccount.Where(x => x.AccountUsername == account.AccountUsername && x.AccountPassword == account.AccountPassword).FirstOrDefault(); if (loggedInAccount == null) { ViewBag.Message = "Incorrect username or password, please try again"; return(View()); } else { //Save user info to session HttpContext.Session.SetInt32("Id", loggedInAccount.AccountId); HttpContext.Session.SetString("Username", loggedInAccount.AccountUsername); return(RedirectToAction("UserTable")); } } }
public IActionResult Emplogon(Employee emp) { using (mypidbContext db = new mypidbContext()) { Employee loggedInEmployee = db.Employee.Where(x => x.EmployeeId == emp.EmployeeId && x.EmployeeUsername == emp.EmployeeUsername && x.EmployeePassword == emp.EmployeePassword).FirstOrDefault(); if (loggedInEmployee == null) { ViewBag.Message = "Incorrect credentials, please try again"; return(View()); } else { //Save user info to session HttpContext.Session.SetInt32("Id", loggedInEmployee.EmployeeId); HttpContext.Session.SetString("Username", loggedInEmployee.EmployeeUsername); ViewBag.Employee = "1"; return(RedirectToAction("EmpTable")); } } }
public UserAccountsController(mypidbContext context) { _context = context; }
public HomeAccountsController(mypidbContext context) { _context = context; }
public IncidentDatasController(mypidbContext context) { _context = context; }
public EmployeesController(mypidbContext context) { _context = context; }