public ActionResult DeleteConfirmed(int id) { UniversityStaff universityStaff = db.UniversityStaffs.Find(id); db.UniversityStaffs.Remove(universityStaff); db.SaveChanges(); return(RedirectToAction("Index")); }
static void InheritenceExample() { //Person person = new Person("John", "Smith"); Person student = new Student("John", "Smith", 1234); UniversityStaff uniStaff = new UniversityStaff("John", "Smith", "*****@*****.**"); Lecturer lectuer = new Lecturer("John", "Smith", "*****@*****.**", 1); UniversityStaff uniStaff2 = lectuer as UniversityStaff; }
public ActionResult Edit([Bind(Include = "ID,Username,Password,Birthday")] UniversityStaff universityStaff) { if (ModelState.IsValid) { db.Entry(universityStaff).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(universityStaff)); }
public ActionResult Create([Bind(Include = "ID,Username,Password,Birthday")] UniversityStaff universityStaff) { if (ModelState.IsValid) { db.UniversityStaffs.Add(universityStaff); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(universityStaff)); }
static void InterfaceDemo() { Person student = new Student("Jenny", "Smith", 1235); UniversityStaff uniStaff = new UniversityStaff("John", "Smith", "*****@*****.**"); Lecturer lectuer = new Lecturer("Adam", "Doe", "*****@*****.**", 2); PersonDetailsProvider.PrintDetail(student); PersonDetailsProvider.PrintDetail(uniStaff); PersonDetailsProvider.PrintDetail(lectuer); Console.WriteLine(); }
public UniversityStaff GetStaffByUsername(string username) { UniversityStaff staff = null; var query = from s in db.UniversityStaffs where s.Username == username select s; foreach (var s in query) { staff = s; } return(staff); }
// GET: UniversityStaff/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UniversityStaff universityStaff = db.UniversityStaffs.Find(id); if (universityStaff == null) { return(HttpNotFound()); } return(View(universityStaff)); }
// GET: Login public ActionResult Login(string username, string password, string role) { if (username != null && password != null && role != null) { if (role.Equals("student")) { Student student = studentDao.GetStudentByUsername(username); if (student == null) { TempData["Message"] = "Username does not exist,please check again!"; return(RedirectToAction("index", "Home")); } else if (student != null && !student.Password.Equals(password)) { TempData["Message"] = "Password is not correct,please try again!"; return(RedirectToAction("index", "Home")); } else { HttpContext.Session.Add("ID", student.ID); return(RedirectToAction("index", "Student")); } } else if (role.Equals("staff")) { UniversityStaff staff = universityStaffDao.GetStaffByUsername(username); if (staff == null) { TempData["Message"] = "Username does not exist,please check again!"; return(RedirectToAction("index", "Home")); } else if (staff != null && !staff.Password.Equals(password)) { TempData["Message"] = "Password is not correct,please try again!"; return(RedirectToAction("index", "Home")); } else { HttpContext.Session.Add("ID", staff.ID); return(RedirectToAction("Index", "UniversityStaff")); } } else if (role.Equals("landlord")) { Landlord landlord = landlordDao.GetLandlordByUsername(username); if (landlord == null) { TempData["Message"] = "Username does not exist,please check again!"; return(RedirectToAction("index", "Home")); } else if (landlord != null && !landlord.Password.Equals(password)) { TempData["Message"] = "Password is not correct,please try again!"; return(RedirectToAction("index", "Home")); } else { HttpContext.Session.Add("ID", landlord.ID); return(RedirectToAction("index", "Landlord")); } } else { TempData["Message"] = "Please select your role!"; return(RedirectToAction("index", "Home")); } } else { TempData["Message"] = "Username & Password & Role can not be empty!"; return(RedirectToAction("index", "Home")); } }