public HttpResponseMessage UpdateStudent(tblStudent student) { int result = 0; var oldStudent = DBcontext.tblStudents.Where(s => s.StudentID == student.StudentID).FirstOrDefault(); oldStudent.FirstName = student.FirstName; oldStudent.LastName = student.LastName; oldStudent.Address = student.Address; oldStudent.Email = student.Email; DBcontext.Entry(oldStudent).State = EntityState.Modified; DBcontext.SaveChanges(); result = 1; return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public IHttpActionResult PutStudent(int id, Student student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != student.stu_id) { return(BadRequest()); } db.Entry(student).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "id,batch1,year")] batch batch) { if (ModelState.IsValid) { db.Entry(batch).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(batch)); }
public ActionResult Edit([Bind(Include = "stdId,stdName,stdBranch,stdCity,stdPhn")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit(Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit([Bind(Include = "id,first_name,last_name,Password,email")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit([Bind(Include = "Id,BiSt,Predmet,Ocena")] Ispit ispit) { if (ModelState.IsValid) { db.Entry(ispit).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ispit)); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Age,Class,Religion")] Table_Student table_Student) { if (ModelState.IsValid) { db.Entry(table_Student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(table_Student)); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,BirthDate,MobileNo,Address")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit([Bind(Include = "StudentID,FirstName,LastName,Score")] StudentTable studentTable) { if (ModelState.IsValid) { db.Entry(studentTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentTable)); }
public ActionResult Edit([Bind(Include = "id,course1,duration")] course course) { if (ModelState.IsValid) { db.Entry(course).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ActionResult Edit([Bind(Include = "id,firstname,lastname,username,password")] user user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public async Task <ActionResult> Edit([Bind(Include = "Deptid,DeptName")] Department department) { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("List")); } return(View(department)); }
public ActionResult Edit([Bind(Include = "courseId,stuId,courseName,courseDuration")] Cours cours) { if (ModelState.IsValid) { db.Entry(cours).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.stuId = new SelectList(db.Students, "stdId", "stdName", cours.stuId); return(View(cours)); }
public async Task <ActionResult> Edit(Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit([Bind(Include = "id,firstname,lastname,nic,course_id,batch_id,telno")] resistration resistration) { if (ModelState.IsValid) { db.Entry(resistration).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.batch_id = new SelectList(db.batches, "id", "batch1", resistration.batch_id); ViewBag.course_id = new SelectList(db.courses, "id", "course1", resistration.course_id); return(View(resistration)); }
/// <summary> /// Save changes on an existing student /// </summary> /// <param name="student"></param> public void SaveStudent(Student student) { //Get student entity from context var entity = db.Students.Where(c => c.Id == student.Id).AsQueryable().FirstOrDefault(); if (entity != null) { //update entity with new values try { db.Entry(entity).CurrentValues.SetValues(student); } catch { //For testing purposes, when mocking context, CurrentValues property does not exists entity = student; db.Entry(entity).State = EntityState.Modified; } try { db.SaveChanges(); } catch (DbEntityValidationException e) { string validationErrors = ""; foreach (var eve in e.EntityValidationErrors) { validationErrors += String.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { validationErrors += String.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw new Exception(validationErrors); } } }
public HttpResponseMessage UpdateStudent(StudentTable astudent) { int result = 0; try { dbContext.StudentTables.Attach(astudent); dbContext.Entry(astudent).State = EntityState.Modified; dbContext.SaveChanges(); result = 1; } catch (Exception e) { result = 0; } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
private void OnComfirmChangePasswordCommand(object obj) { if (CheckCorrectPasswordError == true || CorrectPasswordProperty == string.Empty) { warningAudio.SpeakAsync("Incorrect current password. Please try again.."); } else if (CheckNewPasswordError == true) { warningAudio.SpeakAsync("New password not match. Please try again.."); } else { var updateStudent = ST.StudentUser.Find(User[0].UserName); updateStudent.Pasworkd = NewPassword; ST.Entry(updateStudent).State = System.Data.Entity.EntityState.Modified; ST.SaveChanges(); warningAudio.SpeakAsync("Change password successfully.."); } }
public void UpdateModel(T model) { _context.Entry(model).State = System.Data.Entity.EntityState.Modified; }