public void GetData(string sidx, string sord, int?_page)
        {
            int rows = Functions.GetGridNumberOfRows();
            int numberOfPagesToShow = Functions.GetGridNumberOfPagesToShow();
            int currentPage         = _page is null ? 1 : Convert.ToInt32(_page);
            int startRowIndex       = ((currentPage * rows) - rows);
            int totalRecords        = CourseEnrollment.GetRecordCount();
            int totalPages          = (int)Math.Ceiling((float)totalRecords / (float)rows);
            List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);

            // fields and titles
            string[,] fieldNames = new string[, ] {
                { "EnrollmentId", "Enrollment Id" },
                { "CourseName", "Course Name" },
                { "StudentName", "Student Name" },
                { "Comments", "Comments" }
            };

            // assign properties
            CourseEnrollmentData       = objCourseEnrollmentCol;
            CourseEnrollmentFieldNames = fieldNames;
            TotalPages           = totalPages;
            CurrentPage          = currentPage;
            FieldToSort          = String.IsNullOrEmpty(sidx) ? "EnrollmentId" : sidx;
            FieldSortOrder       = String.IsNullOrEmpty(sord) ? "asc" : sord;
            FieldToSortWithOrder = String.IsNullOrEmpty(sidx) ? "EnrollmentId" : (sidx + " " + sord).Trim();
            NumberOfPagesToShow  = numberOfPagesToShow;
            StartPage            = Functions.GetPagerStartPage(currentPage, numberOfPagesToShow, totalPages);
            EndPage = Functions.GetPagerEndPage(StartPage, currentPage, numberOfPagesToShow, totalPages);
        }
示例#2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public void RegisterStudentToCourse(string studentId, string courseId)
        {
            var student = _srepo.Get(studentId) ?? new Student();
            var course  = _crepo.Get(courseId) ?? new Course();

            if (student.Id != null)
            {
                throw new UpdateException(string.Format("Student : {0} already exist", studentId));
            }
            if (course.Id == null)
            {
                throw new UpdateException(string.Format("Course : {0} not found", courseId));
            }
            var enrollment = _cerepo.Get(studentId, courseId) ?? new CourseEnrollment();

            if (enrollment.Id != null)
            {
                throw new UpdateException(string.Format("Student {0} already registered for Course : {1} already found", student, courseId));
            }
            CourseEnrollment e = new CourseEnrollment()
            {
                Id = studentId, CourseId = courseId, IsAdmin = false
            };

            _cerepo.AddAsync(e);
        }
示例#3
0
        /// <summary>
        /// Used when adding or updating a record.
        /// </summary>
        internal static void AddOrEdit(CourseEnrollment model, CrudOperation operation, bool isForListInline = false)
        {
            CourseEnrollment objCourseEnrollment;
            CourseEnrollment objCourseEnrollmentOld = new CourseEnrollment();
            decimal          id = 0;

            if (operation == CrudOperation.Add)
            {
                objCourseEnrollment = new CourseEnrollment();
            }
            else
            {
                objCourseEnrollment    = CourseEnrollment.SelectByPrimaryKey(model.EnrollmentId);
                objCourseEnrollmentOld = objCourseEnrollment.ShallowCopy();
            }

            objCourseEnrollment.EnrollmentId = model.EnrollmentId;
            objCourseEnrollment.CourseName   = model.CourseName;
            objCourseEnrollment.StudentName  = model.StudentName;
            objCourseEnrollment.Comments     = model.Comments;

            if (operation == CrudOperation.Add)
            {
                id = objCourseEnrollment.Insert();
            }
            else
            {
                objCourseEnrollment.Update();
            }
        }
示例#4
0
    /// <summary>
    /// Shows how to get a specific number of sorted records, starting from an index, based on Search Parameters.  The number of records are also retrieved.
    /// </summary>
    private void SelectSkipAndTakeDynamicWhere()
    {
        int    startRetrievalFromRecordIndex = 0;
        int    numberOfRecordsToRetrieve     = 10;
        string sortBy = "EnrollmentId";
        //string sortBy = "EnrollmentId desc";

        // search parameters, everything is nullable, only items being searched for should be filled
        // note: fields with String type uses a LIKE search, everything else uses an exact match
        // also, every field you're searching for uses the AND operator
        // e.g. int? productID = 1; string productName = "ch";
        // will translate to: SELECT....WHERE productID = 1 AND productName LIKE '%ch%'
        int?   enrollmentId = null;
        int?   courseName   = null;
        int?   studentName  = null;
        string comments     = null;

        // 1. select a specific number of sorted records starting from the index you specify based on Search Parameters
        List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectSkipAndTakeDynamicWhere(enrollmentId, courseName, studentName, comments, numberOfRecordsToRetrieve, startRetrievalFromRecordIndex, sortBy);

        // to use objCourseEnrollmentCol please see the SelectAll() method examples
        // No need for Examples 1 and 2 because the Collection here is already sorted
        // Example 3:  directly bind to a GridView - for ASP.NET Web Forms
        // Example 4:  loop through all the CourseEnrollment(s).  The example above will only loop for 10 items.
    }
示例#5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // delete registration info
            if (MessageBox.Show("Do you want to delete this record ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    var enrollment = new CourseEnrollment();
                    enrollment.Id = Convert.ToInt32(gridRegistration.SelectedRows[0].Cells[0].Value.ToString());

                    var result = CourseEnrollmentDataAccess.delete(enrollment);

                    if (result == true)
                    {
                        MessageBox.Show("Record has been deleted successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        gridRefresh(); // call grid refresh method
                        clearField();  // call clear field method
                    }
                    else
                    {
                        MessageBox.Show("Unable to delete record", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed : " + ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                return;
            }
        }
示例#6
0
        /// <summary>
        /// Gets the list of data for use by the jqgrid plug-in
        /// </summary>
        public IActionResult OnGetGridData(string sidx, string sord, int _page, int rows, bool isforJqGrid = true)
        {
            int totalRecords  = CourseEnrollment.GetRecordCount();
            int startRowIndex = ((_page * rows) - rows);
            List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (objCourseEnrollmentCol is null)
            {
                return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }"));
            }

            var jsonData = new
            {
                total = totalPages,
                _page,
                records = totalRecords,
                rows    = (
                    from objCourseEnrollment in objCourseEnrollmentCol
                    select new
                {
                    id = objCourseEnrollment.EnrollmentId,
                    cell = new string[] {
                        objCourseEnrollment.EnrollmentId.ToString(),
                        objCourseEnrollment.CourseName.ToString(),
                        objCourseEnrollment.StudentName.ToString(),
                        objCourseEnrollment.Comments
                    }
                }).ToArray()
            };

            return(new JsonResult(jsonData));
        }
示例#7
0
        public void DeregisterStudent_Should_Remove_All_Enrollment([Frozen] Mock <ICourseEnrollmentRepository> cerepo, [Frozen] Mock <IStudentRepository> srepo, Student student, string studentId, StudentService sut)
        {
            //arrange
            var e1 = new CourseEnrollment()
            {
                Id = student.Id, CourseId = "x"
            };
            var e2 = new CourseEnrollment()
            {
                Id = student.Id, CourseId = "y"
            };
            var enrollment = new List <CourseEnrollment>()
            {
                e1, e2
            };

            srepo.Setup(r => r.Get(studentId)).Returns(new Student());
            cerepo.Setup(r => r.GetAll()).Returns(enrollment);
            cerepo.Setup(r => r.Remove(e1)).Callback(() => enrollment.Remove(e1));
            cerepo.Setup(r => r.Remove(e2)).Callback(() => enrollment.Remove(e2));

            //act
            sut.DeregisterStudent(student.Id);

            //assert
            enrollment.ShouldBeEmpty();
        }
示例#8
0
        //Enrolls selected student in courses
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Student = await _context.Student.FindAsync(id);

            //If no courses are selected, throw an error message.
            if (CourseIDs.Length == 0)
            {
                ModelState.AddModelError("No Course Selected", "You must select at least one course to enroll this student in");
                return(Page());
            }
            //Loop through the CourseIds and add the enrollments to the selected student.
            foreach (int CourseId in CourseIDs)
            {
                CourseEnrollment studentEnrollment = new CourseEnrollment {
                    StudentID = Student.StudentID, CourseID = CourseId
                };
                _context.CourseEnrollment.Add(studentEnrollment);
            }
            //Save changes
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public void EnrollmentService_SqlEnrollmentRepository_UnEnroll_a_Enrolled_Student()
        {
            IEnrollmentService service = new EnrollmentService(new SqlEnrollmentRepository());

            // First enroll a student
            //
            var courseEnrollment = new CourseEnrollment
            {
                CourseOfferingNo = 0,
                StudentId        = -98,
                GradeNo          = 1,
                StatusId         = 1,
                ImportDate       = DateTime.Now,
                ImportConversion = "Student Portal"
            };
            int isEnrolled = service.EnrollStudent(courseEnrollment);

            Assert.AreEqual(1, isEnrolled);

            // Then Un-Enroll that student
            //
            var isUnEnrolled = service.UnEnrollStudent(courseEnrollment.StudentId, courseEnrollment.CourseOfferingNo);

            Assert.IsTrue(isUnEnrolled);
        }
示例#10
0
        public bool CourseAlreadyTaken(int courseId, CourseEnrollment courseEnrollment)
        {
            string query = "SELECT * FROM IsCourseAlreadyTakenView WHERE Student_RegNo='" + aCourseEnrollment.AStudent.RegNo + "'";

            aConnection = new SqlConnection(connection);
            aConnection.Open();

            aCommand = new SqlCommand(query, aConnection);

            aReader = aCommand.ExecuteReader();
            if (aReader.HasRows)
            {
                while (aReader.Read())
                {
                    int tempCourseId = (int)aReader[0];
                    if (tempCourseId == courseId)
                    {
                        return(false);
                    }
                }
            }

            aConnection.Close();
            return(true);
        }
示例#11
0
        public CourseEnrollment CheckRegNo(string regNo)
        {
            aCourseEnrollment = new CourseEnrollment();
            aConnection       = new SqlConnection(connection);


            string registrationNumber = regNo;
            string query1             = "SELECT * FROM CourseEnrollmentView1 WHERE Student_RegNo='" + registrationNumber + "'";


            aConnection.Open();

            aCommand = new SqlCommand(query1, aConnection);

            aReader = aCommand.ExecuteReader();
            if (aReader.HasRows)
            {
                while (aReader.Read() && studentCount == 0)
                {
                    aCourseEnrollment.AStudent.RegNo = aReader[0].ToString();
                    aCourseEnrollment.AStudent.Name  = aReader[1].ToString();
                    aCourseEnrollment.AStudent.Email = aReader[2].ToString();
                    studentCount++;
                }
                studentCount = 0;
            }
            aConnection.Close();



            return(GetCourseInfo(aCourseEnrollment));
        }
示例#12
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Course = await _context.Course.FindAsync(id);

            if (StudentIDs.Length == 0)
            {
                ModelState.AddModelError("No Student Selected", "You must select at least one student to enroll in course.");
                return(Page());
            }
            //Loop through StudentIDs and enroll each selected student to the selected course.
            foreach (int StudentId in StudentIDs)
            {
                CourseEnrollment studentEnrollment = new CourseEnrollment {
                    CourseID = Course.CourseID, StudentID = StudentId
                };
                _context.CourseEnrollment.Add(studentEnrollment);
            }
            //Save changes
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
示例#13
0
    /// <summary>
    /// The example below shows how to Select the EnrollmentId and Comments columns for use with a with a Drop Down List, Combo Box, Checked Box List, List View, List Box, etc
    /// </summary>
    private void SelectCourseEnrollmentDropDownListData()
    {
        List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectCourseEnrollmentDropDownListData();

        // Example 1:  directly bind to a drop down list - for ASP.NET Web Forms
        // DropDownList ddl1 = new DropDownList();
        // ddl1.DataValueField = "EnrollmentId";
        // ddl1.DataTextField = "Comments";
        // ddl1.DataSource = objCourseEnrollmentCol;
        // ddl1.DataBind();

        // Example 2:  add each item through a loop - for ASP.NET Web Forms
        // DropDownList ddl2 = new DropDownList();

        // foreach (CourseEnrollment objCourseEnrollment in objCourseEnrollmentCol)
        // {
        //     ddl2.Items.Add(new ListItem(objCourseEnrollment.Comments, objCourseEnrollment.EnrollmentId.ToString()));
        // }

        // Example 3:  bind to a combo box.  for Windows Forms (WinForms)
        // ComboBox cbx1 = new ComboBox();

        // foreach (CourseEnrollment objCourseEnrollment in objCourseEnrollmentCol)
        // {
        //     cbx1.Items.Add(new ListItem(objCourseEnrollment.Comments, objCourseEnrollment.EnrollmentId.ToString()));
        // }
    }
示例#14
0
        async Task EnrollStudent(StudentEnrollCommand command)
        {
            Student student = await _students.GetStudentAsync(command.StudentEmail);

            if (student == null)
            {
                throw new DomainException($"Student email '{command.StudentEmail}' doens't exist");
            }

            bool suceed;

            do
            {
                CourseEnrollment enrollment = await _courses.GetCourseEnrollmentAsync(command.CourseTitle);

                if (enrollment == null)
                {
                    throw new DomainException($"Course {command.CourseTitle} doesn't exist");
                }

                int version = enrollment.CourseVersion;

                enrollment.AddStudent(student);

                suceed = await _courses.SetCourseEnrollmentAsync(version, enrollment);
            } while(!suceed);
        }
示例#15
0
        public ViewResult EnrollInCourse(CourseEnrollment courseEnrollment)
        {
            CourseEnrollmentViewModel viewModel = new CourseEnrollmentViewModel
            {
                Students = StudentGateway.GetStudents()
            };

            if (!ModelState.IsValid)
            {
                viewModel.CourseEnrollment = courseEnrollment;

                ViewBag.Message = "Saved";

                return(View(viewModel));
            }

            int rowAffected = StudentGateway.Enroll(courseEnrollment);

            if (rowAffected > 0)
            {
                ViewBag.Message = "Saved";
            }
            else
            {
                ViewBag.Message = "Error";
            }

            return(View(viewModel));
        }
示例#16
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public void RegisterTeacherToCourse(string teacherId, string courseId)
        {
            var teacher = _trepo.Get(teacherId) ?? new Teacher();
            var course  = _crepo.Get(courseId) ?? new Course();

            if (teacher.Id != null)
            {
                throw new UpdateException(string.Format("Teacher : {0} already exist", teacherId));
            }
            if (course.Id == null)
            {
                throw new UpdateException(string.Format("Course : {0} not found", courseId));
            }
            var enrollment = _cerepo.Get(teacherId, courseId) ?? new CourseEnrollment();

            if (enrollment.Id != null)
            {
                throw new UpdateException(string.Format("Teacher {0} already registered for Course : {1} already found", teacher, courseId));
            }
            CourseEnrollment e = new CourseEnrollment()
            {
                Id = teacherId, CourseId = courseId, IsAdmin = true
            };

            _cerepo.AddAsync(e);
        }
        /// <summary>
        /// Handler, deletes a record.
        /// </summary>
        public IActionResult OnGetRemove(int id)
        {
            CourseEnrollment CourseEnrollment = CourseEnrollment.SelectByPrimaryKey(id);

            CourseEnrollment.Delete(id);
            return(new JsonResult(true));
        }
        /// <summary>
        /// Handler, updates a record.
        /// </summary>
        public IActionResult OnGetUpdate(string serializedData)
        {
            CourseEnrollment objCourseEnrollment = JsonConvert.DeserializeObject <CourseEnrollment>(serializedData);

            CourseEnrollmentFunctions.AddOrEdit(objCourseEnrollment, CrudOperation.Update, true);
            return(new JsonResult(true));
        }
        public async Task <ActionResult> CourseEnrollment(Course model)
        {
            var courseId = model.Id;
            var user     = await GetCurrentUserAsync();

            var userId    = user?.Id;
            var userRoles = await _userManager.GetRolesAsync(user);

            var inrole = await _userManager.IsInRoleAsync(user, "Student");


            var courseEnroll = await _context.CourseEnrollments
                               .FirstOrDefaultAsync(m => m.Id == courseId && m.UserId == userId);

            if (courseEnroll != null)
            {
                StatusMessage = "You are already enrolled";
                return(RedirectToAction("Details", new { id = model.Id }));
            }

            if (!inrole)
            {
                StatusMessage = "You are not eligible to enroll in this course";
                return(RedirectToAction("Details", new { id = model.Id }));
            }
            var enrollment = new CourseEnrollment();

            enrollment.UserId   = userId;
            enrollment.CourseId = model.Id;

            _context.CourseEnrollments.Add(enrollment);
            await _context.SaveChangesAsync();

            return(View());
        }
示例#20
0
    /// <summary>
    /// Shows how to Select all records by Course, related to column CourseName
    /// </summary>
    private void SelectCourseEnrollmentCollectionByCourseName()
    {
        int courseNameSample = 12;

        List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectCourseEnrollmentCollectionByCourseName(courseNameSample);

        // Example 1:  you can optionally sort the collection in ascending order by your chosen field
        objCourseEnrollmentCol.Sort(CourseEnrollment.ByCourseName);

        // Example 2:  to sort in descending order, add this line to the Sort code in Example 1
        objCourseEnrollmentCol.Reverse();

        // Example 3:  directly bind to a GridView - for ASP.NET Web Forms
        // GridView grid = new GridView();
        // grid.DataSource = objCourseEnrollmentCol;
        // grid.DataBind();

        // Example 4:  loop through all the CourseEnrollment(s)
        foreach (CourseEnrollment objCourseEnrollment in objCourseEnrollmentCol)
        {
            int    enrollmentId = objCourseEnrollment.EnrollmentId;
            int    courseName   = objCourseEnrollment.CourseName;
            int    studentName  = objCourseEnrollment.StudentName;
            string comments     = objCourseEnrollment.Comments;

            // get the Course related to CourseName.
            Course objCourseRelatedToCourseName = objCourseEnrollment.CourseNameNavigation;

            // get the Student related to StudentName.
            Student objStudentRelatedToStudentName = objCourseEnrollment.StudentNameNavigation;
        }
    }
        public CourseEnrollment CheckRegNo(string regNo)
        {
            aCourseEnrollment = new CourseEnrollment();

            aCourseEnrollment = aCourseEnrollmentGateway.CheckRegNo(regNo);

            return(aCourseEnrollment);
        }
示例#22
0
    /// <summary>
    /// Shows how to Select all records sorted by column name in either ascending or descending order.
    /// </summary>
    private void SelectAllWithSortExpression()
    {
        // select all records sorted by EnrollmentId in ascending order
        string sortBy = "EnrollmentId"; // ascending order
        //string sortBy = "EnrollmentId desc"; // descending order

        List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectAll(sortBy);
    }
示例#23
0
    /// <summary>
    /// Shows how to Select all records by Student, related to column StudentName sorted by column name in either ascending or descending order.
    /// </summary>
    private void SelectCourseEnrollmentCollectionByStudentNameWithSortExpression()
    {
        int    studentNameSample = 12;
        string sortBy            = "EnrollmentId"; // ascending order
        //string sortBy = "EnrollmentId desc"; // descending order

        List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectCourseEnrollmentCollectionByStudentName(studentNameSample, sortBy);
    }
        public ActionResult UnEnroll(string CourseOfferingNo, int pageNumber)
        {
            CourseEnrollment CourseEnrollment = new CourseEnrollment();
            var studentNo = Session[UserController.SessionKeyStudentNo].ToString();

            try
            {
                IEnrollmentService service = new EnrollmentService();
                bool isUnEnroll            = service.UnEnrollStudent(int.Parse(studentNo), int.Parse(CourseOfferingNo));
                int  selectedTerm          = Convert.ToInt32(Session[UserController.SessionKeyCourseOfferingTermId]);
                // Load Terms
                Dictionary <int, DateTime> terms = null;
                terms = service.FetchTermsForOnlineEnrollment();
                ViewData["enrollmentTerms"] = terms;

                // Load Course
                var courseOffering = GetCourseOffering(service, studentNo, selectedTerm, pageNumber);
                //int totalRows = 0;
                //var courseOffering = service.FetchCourseOfferings(Convert.ToInt32(studentNo), selectedTerm, out totalRows, pageNumber, PageSize);
                //int totalPages = totalRows / PageSize;
                //ViewData["pageNumberLast"] = totalPages;
                ////int pageNumber = 1;
                //// Decrement page number only if it doesn't pass the minimum page number.
                //ViewData["pageNumberPrev"] = (pageNumber <= 1) ? 1 : pageNumber - 1;

                //ViewData["pageNumberCurrent"] = pageNumber;

                //// Increment page number only if it doesn't pass the maximum page number.
                //ViewData["pageNumberNext"] = (pageNumber >= totalPages) ? totalPages : pageNumber + 1;

                if (isUnEnroll)
                {
                    ViewData["successMsgUnEnroll"] = "1";
                }
                else
                {
                    var sb = new StringBuilder();
                    sb.AppendFormat("Unable to enroll student. EnrollStudent returned: {0}, EnrollmentData:{1}", isUnEnroll,
                                    CourseEnrollment);

                    _logger.Warn(sb.ToString());

                    Response.Redirect(AppHelper.SharedUrl("Reply/Error"));
                }
                return(View("Enroll", courseOffering));
            }
            catch (Exception ex)
            {
                var sb = new StringBuilder();
                sb.AppendFormat("Exception Occurred. StudentNo: {0}, EnrollmentData:{1}", studentNo,
                                CourseEnrollment);

                _logger.Error(sb.ToString(), ex);

                Response.Redirect(AppHelper.SharedUrl("Reply/Error"));
                return(null);
            }
        }
 // add course enrollment
 public static bool addEnrollment(CourseEnrollment enrollment)
 {
     using (var db = new NipunaDataContext())
     {
         db.CourseEnrollments.Add(enrollment);
         db.SaveChanges();
         return(true);
     }
 }
示例#26
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public void DeregisterFromCourse(string Id, string courseId)
        {
            CourseEnrollment enrollment = _cerepo.Get(Id, courseId) ?? new CourseEnrollment();

            if (enrollment.Id == null)
            {
                throw new UpdateException(string.Format("No enrollment record found for user with id {0}", Id));
            }
            _cerepo.Remove(enrollment);
        }
示例#27
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public CourseEnrollment GetEnrollmentDetails(string Id, string courseId)
        {
            CourseEnrollment enrollment = _cerepo.Get(Id, courseId) ?? new CourseEnrollment();

            if (enrollment.Id == null)
            {
                throw new NotFoundException(string.Format("No enrollment record found for user with id {0}", Id));
            }
            return(enrollment);
        }
示例#28
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public bool IsEnrolled(string studentId, string courseId)
        {
            CourseEnrollment enrollment = _cerepo.Get(studentId, courseId) ?? new CourseEnrollment();

            if (enrollment.Id == null)
            {
                return(false);
            }
            return(true);
        }
示例#29
0
        public int SaveCourseResult(CourseEnrollment courseEnrollment)
        {
            int rowAffected = 0;

            Query   = "Update CourseEnrollment set Grade = '" + courseEnrollment.Grade + "' Where StudentId = '" + courseEnrollment.StudentId + "' And CourseId = '" + courseEnrollment.CourseId + "' And Valid = 'true'";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            rowAffected = Command.ExecuteNonQuery();
            Connection.Close();
            return(rowAffected);
        }
        public void LoadPage(int id, string returnUrl)
        {
            // select a record by primary key(s)
            CourseEnquiry1API.BusinessObject.CourseEnrollment objCourseEnrollment = CourseEnrollment.SelectByPrimaryKey(id);

            // assign values to this page's bound property
            CourseEnrollment = objCourseEnrollment;

            // assign the return url
            ReturnUrl = returnUrl;
        }