public HttpResponseMessage PutShiftStudentSemesterSection(ShiftStudentViewModel svm) { string message = "Student Shifted Successfully"; if (ModelState.IsValid) { stuDB.ShiftStudentSemesterOrSection(svm); return(Request.CreateResponse(HttpStatusCode.OK, message)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public int ShiftStudentSemesterOrSection(ShiftStudentViewModel svm) { try { var shiftStudentList = _db.tblStudents.Where(s => s.YearBatchId == svm.Year_Batch_Id && s.Faculty_Id == svm.Faculty_Id && s.Semester_Id == svm.Semester_Id && s.Section_Id == svm.Section_Id).ToList(); //tblStudent tb = new tblStudent(); // tblStudent tb = _db.tblStudents.Where(s => s.Student_Id == svm.Id).FirstOrDefault(); foreach (var item in shiftStudentList) { tblStudent tb = _db.tblStudents.Where(s => s.Student_Id == item.Student_Id).FirstOrDefault(); tb.Section_Id = svm.ToSectionId; tb.Semester_Id = svm.ToSemesterId; _db.SaveChanges(); } return(0); } catch (Exception ex) { throw ex; } }