// // GET: /User/ public ActionResult DashboardIndex() { AlumniEntities db = new AlumniEntities(); new GernalFunction().CheckUserLogin(); string Email = HttpContext.Request.Cookies["UserCookies"]["Email"]; string Password = HttpContext.Request.Cookies["UserCookies"]["Password"]; var s = db.Students.FirstOrDefault(x => x.Email == Email && x.Password == Password); return(View(s)); }
public ActionResult SignIn(Student student) { AlumniEntities db = new AlumniEntities(); var s = db.Students.FirstOrDefault(x => x.Email == student.Email && x.Password == student.Password); if (s != null) { new GernalFunction().SetUserCookies(s); return(RedirectToAction("DashboardIndex")); } ViewBag.LoginError = "Login or UserName is Incorrect."; return(View()); }
public ActionResult ChangePassword(string old, string newpass, string confrim) { if (old != null && old != "" && newpass != null && newpass != "" && confrim != null && confrim != "") { if (newpass == confrim) { HttpCookie cookie = HttpContext.Request.Cookies["AdminCookies"]; int ID = Convert.ToInt32(cookie.Values["ID"]); User usr = new UserModel().GetUserByID(ID); if (usr.Password == old) { usr.Password = newpass; var user = new User() { ID = ID, Password = newpass }; using (var dbpass = new AlumniEntities()) { try { dbpass.Users.Attach(user); dbpass.Entry(user).Property(x => x.Password).IsModified = true; dbpass.SaveChanges(); TempData["AlertTask"] = "Password Successfully Update"; return(RedirectToAction("DashboardIndex", "user")); } catch { } } } else { ViewBag.ErrorMsg = "oldpass"; } } else { ViewBag.ErrorMsg = "PasswordsNotMatch"; } } else { ViewBag.ErrorMsg = "CannotEmpty"; } return(View()); }
public JsonResult InsertSalary(List <SalaryRecord> salaryrecords) { using (AlumniEntities entities = new AlumniEntities()) { //Truncate Table to delete all old records. entities.Database.ExecuteSqlCommand("TRUNCATE TABLE [SalaryRecord]"); //Check for NULL. if (salaryrecords == null) { salaryrecords = new List <SalaryRecord>(); } //Loop and insert records. foreach (SalaryRecord SalaryRecord in salaryrecords) { entities.SalaryRecords.Add(SalaryRecord); } int insertedRecords = entities.SaveChanges(); return(Json(insertedRecords)); } }