public IHttpActionResult PostCalificaion(StudentCourseDTO calification) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var remoteServer = (ICourseLogic)Activator.GetObject( typeof(ICourseLogic), RemoteAddress); try { string response = remoteServer.AddCalificationRemoting(calification.CourseName, calification.StudentId, calification.Calification); if (response.Equals("OK")) { Logs.SendTimestamp("AddCalification", "admin", "Calification added: " + calification.Calification); return(Ok(response)); } else { return(BadRequest(response)); } } catch (Exception e) { return(BadRequest(e.Message)); } }
public static StudentCourseViewModel MapStudentCourseDTOtoView(StudentCourseDTO courseItem) { var studentCourseView = new StudentCourseViewModel { CourseId = courseItem.CourseId, CourseTitle = courseItem.CourseTitle }; return(studentCourseView); }
public IHttpActionResult Edit([FromBody] StudentCourseDTO sc) { try { var t = DB.StudentCourses.Where(r => (r.CourseCode == sc.CourseCode && r.StudentId == sc.StudentId)).FirstOrDefault(); t.Grade = sc.Grade; DB.SaveChanges(); return(Ok(true)); } catch (Exception e) { return(Ok(new { StatusCode = 200, e })); } }
public async Task GetStudentRecords_Should() { var studentRecords = new List <StudentRecordDTO>(); var studentCourses = new List <StudentCourseDTO>(); var studentCourse = new StudentCourseDTO() { CourseId = 5, CourseTitle = "Microsoft SQL Server Database Development" }; studentCourses.Add(studentCourse); var studentExams = new List <StudentExamDTO>(); var studentExam = new StudentExamDTO() { ExamId = 6, ExamTitle = "Microsoft SQL Server 2008, Database Development" }; studentExams.Add(studentExam); var studentCertifications = new List <StudentCertificationDTO>(); var studentCertification = new StudentCertificationDTO() { CertificationId = 5, CertificationTitle = "Microsoft Certified Technical Specialist in SQL Server 2008, Database Development" }; studentCertifications.Add(studentCertification); var studentRecord = new StudentRecordDTO() { StudentId = 1, FirstName = "Steve", LastName = "Miazga", Email = "*****@*****.**", Courses = studentCourses, Exams = studentExams, Certifications = studentCertifications }; studentRecords.Add(studentRecord); _mockQueryRepository.Setup(x => x.GetStudentRecords(0)).Returns(studentRecords); var query = new GetStudentRecordsQuery(); var handler = new GetStudentRecordsQueryHandler(_mockQueryRepository.Object); var result = await handler.Handle(query, CancellationToken.None); Assert.NotNull(result); }
private IEnumerable <StudentCourseDTO> GetClasses(int studentID) { var result = new List <StudentCourseDTO>(); if (studentID <= 0) { return(result); } var courses = Database.StudentCourses.Where(x => x.StudentId == studentID).ToList(); if (courses != null && courses.Count > 0) { foreach (var c in courses) { var newStudentCourse = new StudentCourseDTO(); newStudentCourse.StudentID = c.StudentId; newStudentCourse.CourseID = c.CourseId; newStudentCourse.Grade = c.Grade; newStudentCourse.EnrolledYear = c.EnrolledYear; newStudentCourse.EnrolledSemester = c.EnrolledSemester; newStudentCourse.Completed = c.Completed; newStudentCourse.Dropped = c.Dropped; newStudentCourse.DroppedTime = c.DroppedTime; //add the course data. var targetCourse = Database.Courses.Where(x => x.CourseId == c.CourseId).FirstOrDefault(); if (targetCourse != null) { var courseDetail = new CourseDTO() { CourseID = targetCourse.CourseId, Name = targetCourse.Name, Credits = targetCourse.Credits, DepartmentID = targetCourse.DepartmentId }; newStudentCourse.Course = courseDetail; } result.Add(newStudentCourse); } } return(result); }
public IHttpActionResult Add([FromBody] StudentCourseDTO sc) { try { if (sc != null) { DB.StudentCourses.Add(new StudentCourse { CourseCode = sc.CourseCode, StudentId = sc.StudentId, Grade = sc.Grade }); DB.SaveChanges(); } return(Ok(true)); } catch (Exception e) { return(Ok(new { StatusCode = 200, e })); } }
private StudentCourseDTO CreateStudentCourse(StudentCourseDTO StudentCourse) { var newObj = new StudentCourses { StudentId = StudentCourse.StudentID, CourseId = StudentCourse.CourseID, Grade = StudentCourse.Grade, EnrolledYear = StudentCourse.EnrolledYear, EnrolledSemester = StudentCourse.EnrolledSemester, Completed = StudentCourse.Completed, Dropped = StudentCourse.Dropped, DroppedTime = StudentCourse.DroppedTime }; Database.StudentCourses.Add(newObj); Database.SaveChanges(); return(StudentCourse); }
// GET: Student/Course public ActionResult Index() { var userId = User.Identity.GetUserId(); var studentCourse = new StudentCourseDTO(); studentCourse.Enrollment = db.Enrollment .Include(e => e.Course) .Include(e => e.ApplicationUser) .Where(e => e.ApplicationUserId.Equals(userId)); return(View(studentCourse)); /*var enrollments = db.Enrollment.Where(r => r.ApplicationUserId == userId).Where(r => r.CourseId == ); * IEnumerable<Course> course = new List<Course>(); * ViewBag.Invoices = enrollments; * StudentCourse Course = new StudentCourse(); * Course.ApplicationUserID = userId; * Course.Course = new List<Course>(); * ViewBag.Course = course; * return View(orders.ToList()); * * return View(users);*/ }