public void Save(User user) { try { db.Users.Add(user); db.SaveChanges(); } catch (Exception ex) { } }
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)); } }
public void save(Teacher tch) { db1.Teachers.Add(tch); db1.SaveChanges(); }
public void Save(Student stu) { db.Students.Add(stu); db.SaveChanges(); }