public int InsertData(StudentDetailsData data) { DbHandiler.DbHandiler DbHandle = new DbHandiler.DbHandiler(); string sql = @"insert into student_data (SUBJECT1,SUBJECT2,ADDRESS,MARKS1,MARKS2,NAME,CLASS,AGE,SEX,UID) VALUES (@SUBJECT1,@SUBJECT2,@ADDRESS,@MARKS1,@MARKS2,@NAME,@CLASS,@AGE,@SEX,@UID);"; return(DbHandle.SaveData <StudentDetailsData>(sql, data)); }
// POST api/values/5 public HttpResponseMessage Post(int id, StudentDetailsData dataTobeUpdated) { var responseMessage = DataAccesBuisness.UpdateToDb(dataTobeUpdated); var response = this.Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(responseMessage.ToString(), Encoding.UTF8, "application/json"); return(response); }
public object UpdateToDb(StudentDetailsData data) { DbHandiler.DbHandiler DbHandle = new DbHandiler.DbHandiler(); string sql = @"UPDATE student_data SET SUBJECT1 = @SUBJECT1,SUBJECT2 = @SUBJECT2,ADDRESS = @ADDRESS ,MARKS1 = @MARKS1, MARKS2 = @MARKS2,NAME = @NAME,CLASS = @CLASS ,AGE = @AGE,SEX = @SEX,UID = @UID where ID = @ID "; return(DbHandle.SaveData <StudentDetailsData>(sql, data)); }
// GET: Student/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student student = db.Students.Find(id); if (student == null) { return(HttpNotFound()); } Dictionary <int, string> enrollmentsData = new Dictionary <int, string>(); foreach (Enrollment e in student.Enrollments) { enrollmentsData.Add(e.CourseID, e.Course.Title); } Dictionary <int, string> coursesData = new Dictionary <int, string>(); foreach (Course c in db.Courses) { coursesData.Add(c.CourseID, c.Title); } StudentDetailsData studentDetails = new StudentDetailsData() { ID = student.ID, LastName = student.LastName, FirstMidName = student.FirstMidName, EnrollmentDate = student.EnrollmentDate, Enrollments = enrollmentsData, Courses = coursesData, Person = student }; TempData["StudentID"] = student.ID; return(View(studentDetails)); }
// GET: Student/Details/5 public ActionResult Details(int id) { var db = DAL.DbContext.Create(); if (id <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var studentViewModel = new StudentDetailsData(); studentViewModel.Student = db.Students.Get(id); if (studentViewModel.Student != null) { studentViewModel.Student.Course = db.Courses.Get(studentViewModel.Student.CourseID); studentViewModel.Student.College = db.Colleges.Get(studentViewModel.Student.CollegeID); var tagHistorys = db.SelectStudentTagHistory(studentViewModel.Student.Id); studentViewModel.TagHistory = tagHistorys; foreach (var tagHistory in tagHistorys) { tagHistory.Student = db.Students.Get(tagHistory.StudentID); tagHistory.DeactivationReason = db.DeactivationReason.Get(tagHistory.DeactivationReasonID); } } //IEnumerable<DAL.TagHistory> tagHistorys = db.TagHistorys.All().ToList(); //tagHistorys = tagHistorys.OrderByDescending(t => t.DeactivationDate); if (studentViewModel == null) { return(HttpNotFound()); } return(View(studentViewModel)); }
// GET: Student/Details/5 public ActionResult Details(int id) { var db = DAL.DbContext.Create(); if (id <= 0) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var studentViewModel = new StudentDetailsData(); studentViewModel.Student = db.Students.Get(id); if (studentViewModel.Student != null) { studentViewModel.Student.Course = db.Courses.Get(studentViewModel.Student.CourseID); studentViewModel.Student.College = db.Colleges.Get(studentViewModel.Student.CollegeID); var tagHistorys = db.SelectStudentTagHistory(studentViewModel.Student.Id); studentViewModel.TagHistory = tagHistorys; foreach (var tagHistory in tagHistorys) { tagHistory.Student = db.Students.Get(tagHistory.StudentID); tagHistory.DeactivationReason = db.DeactivationReason.Get(tagHistory.DeactivationReasonID); } } //IEnumerable<DAL.TagHistory> tagHistorys = db.TagHistorys.All().ToList(); //tagHistorys = tagHistorys.OrderByDescending(t => t.DeactivationDate); if (studentViewModel == null) { return HttpNotFound(); } return View(studentViewModel); }