public async Task <UserEnrollment> SaveEnrollment(UserEnrollment userEnrollment) { var validator = new ValidateUserEnrollment(); var results = await validator.ValidateAsync(userEnrollment); if (!results.IsValid) { throw new Exception(results.ToString()); } //if (!results.IsValid) //{ // var errorMessages = results.Errors.Select(failure => "Property " + failure.PropertyName + " failed validation. Error was: " + failure.ErrorMessage).ToList(); // throw new Exception(errorMessages.ToString()); //} if (userEnrollment == null) { throw new ArgumentNullException(nameof(userEnrollment)); } return(await _userEnrollmentRepository.SaveEnrollment(userEnrollment)); }
public async Task <UserEnrollment> EnrollUserInCourse(ApplicationUser user, Course course) { using (db = new AthenaDataContext()) { // first ensure user doesnt have an enrollment for this course already. // TODO fix with composite key on context var currentEnrollment = await db.UserEnrollments .Where(enrollment => enrollment.CourseId == course.Id && enrollment.ApplicationUserId == user.Id).FirstOrDefaultAsync(); if (currentEnrollment == null) { currentEnrollment = new UserEnrollment { ApplicationUserId = user.Id, CourseId = course.Id }; db.UserEnrollments.Add(currentEnrollment); await db.SaveChangesAsync(); } return(currentEnrollment); } }
public async Task <int> SaveEnrollmentTransaction(UserEnrollment userEnrollment) { if (userEnrollment == null) { throw new ArgumentNullException(nameof(userEnrollment)); } return(await _userEnrollmentRepository.SaveEnrollmentTransaction(userEnrollment)); }
public void AddUserEnrollment(int userId, int enrollmentId, string action) { UserEnrollment enrollment = new UserEnrollment(); enrollment.UserId = userId; enrollment.UserEnrollmentId = enrollmentId; enrollment.Status = action; _context.UserEnrollments.Add(enrollment); _context.SaveChanges(); }
public async Task <IActionResult> SaveEnrollments(UserEnrollment userEnrollment) { //add obj validation if (userEnrollment == null) { return(NotFound()); } var enrollments = await _userEnrollmentService.SaveEnrollment(userEnrollment); return(Ok(enrollments)); }
public async Task <UserEnrollment> SaveEnrollment(UserEnrollment userEnrollment) { var validator = new ValidateUserEnrollment(); var results = await validator.ValidateAsync(userEnrollment); if (!results.IsValid) { throw new Exception(results.ToString()); } if (userEnrollment == null) { throw new ArgumentNullException(nameof(userEnrollment)); } return(await _userEnrollmentRepository.SaveEnrollment(userEnrollment)); }
protected void Page_Load(object sender, EventArgs e) { //ImFinishedButton.Click += new EventHandler(ImFinishedButton_Click); if (!IsPostBack) { //this.BindPage(); } this.BindPage(); /* Show appropriate image according to user workbook status */ if (WorkbookCompleted(WorkbookId)) { WorkbookStatusDiv.Attributes.Add("class", "classProgressIcon item48 tasks48complete"); WorkbookStatusTitleDiv.Attributes.Add("class", "classProgressIcon item48 tasks48complete"); divCompleteStatus.Style.Add("Display", "block"); divIncompleteStatus.Style.Add("Display", "none"); //ImFinishedButton.Text = "I'll Finish Later"; } else { WorkbookStatusDiv.Attributes.Add("class", "classProgressIcon item48 tasks48"); WorkbookStatusTitleDiv.Attributes.Add("class", "classProgressIcon item48 tasks48"); divIncompleteStatus.Style.Add("Display", "block"); divCompleteStatus.Style.Add("Display", "none"); //ImFinishedButton.Text = "I'm Finished"; } /* Binding Class & course info */ if (this.ClassID > 0) { // get the class _selectedClass = ClassroomController.GetClass(this.ClassID); // get the course //_selectedCourse = ClassroomController.GetCourse(_selectedClass.CourseId); _selectedCourse = CourseInfo.GetCourse(_selectedClass.CourseId); // get sku of user enrollment for course UserEnrollment u = new UserEnrollment(); u = (UserEnrollment)ClassroomController.GetUserEnrollmentByCourse(_selectedClass.CourseId, this.UserId)[0]; ; _courseSku = u.SKU; DataBind(); } ///* Assignin navigate url to go back to class detail */ //if (SelectedWorkbook != null) // lnkBack.NavigateUrl = "~/Classroom/Class.aspx?id=" + SelectedWorkbook.ClassID; }
public async Task <IActionResult> PostUserEnrollment(UserEnrollment userEnrollment) { return(Ok(await userEnrollmentService.SaveEnrollmentTransaction(userEnrollment))); }
protected void Page_Load(object sender, EventArgs e) { //acrdnClass.ItemDataBound += new EventHandler<AjaxControlToolkit.AccordionItemEventArgs>(acrdnClass_ItemDataBound); if (!IsPostBack) { if (this.ClassID > 0) { // get the class _selectedClass = ClassroomController.GetClass(this.ClassID); // get the course //_selectedCourse = ClassroomController.GetCourse(_selectedClass.CourseId); _selectedCourse = CourseInfo.GetCourse(_selectedClass.CourseId); // get sku of user enrollment for course UserEnrollment u = new UserEnrollment(); u = (UserEnrollment)ClassroomController.GetUserEnrollmentByCourse(_selectedClass.CourseId, this.UserId)[0]; ; _courseSku = u.SKU; DataBind(); } } }
public abstract bool UpdateStudentEnrollment(UserEnrollment userEnrollment);
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.BindPage(); ViewState["ClassID"] = _entity.ClassId.ToString(); /* Show appropriate image according to user audio status */ if (AudioCompleted(AudioId)) { AudioStatusDiv.Attributes.Add("class", "classProgressIcon item48 audio48complete"); //FinishedListeningButton.Text = "I'll Finish Later"; } else { AudioStatusDiv.Attributes.Add("class", "classProgressIcon item48 audio48"); //FinishedListeningButton.Text = "I'm Finished Listening"; } /* Binding Class & course info */ if (this.ClassID > 0) { // get the class _selectedClass = ClassroomController.GetClass(this.ClassID); // get the course //_selectedCourse = ClassroomController.GetCourse(_selectedClass.CourseId); _selectedCourse = CourseInfo.GetCourse(_selectedClass.CourseId); // get sku of user enrollment for course UserEnrollment u = new UserEnrollment(); u = (UserEnrollment)ClassroomController.GetUserEnrollmentByCourse(_selectedClass.CourseId, this.UserId)[0]; ; _courseSku = u.SKU; DataBind(); } } /* Assignin navigate url to go back to class detail */ if (SelectedAudio != null) lnkBack.NavigateUrl = "~/Classroom/Class.aspx?id=" + SelectedAudio.ClassId; }
public bool APIGetUser(object[] lStrvalue) { clsGlobalVariable.strExceptionReport = string.Empty; string statusCode = string.Empty; string result = string.Empty; string allCourseResultresult = string.Empty; string singleCourseresult = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; Hashtable htblTestData = new Hashtable(); htblTestData = oGeneric.GetTestData(lStrvalue); bool _Flag = false; UserEnrollment userID = new UserEnrollment(); GetAPICredentials oGetAPICredentials = new GetAPICredentials(); //Get Org ID at runtime clsPage oPage = new clsPage(iWebdriver); _orgID = oPage.GetOrganizationID(); clsAPI.orgID = _orgID; try { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", clsAPI.orgID), oGetAPICredentials, "H2", "", ""); var orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result); Crypto3DES _des = new Crypto3DES(ApplicationSettings.EComModuleEncKey()); _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey); _ecomLoginKey = _des.Decrypt3DES(orgCredential.LoginID); if (htblTestData["RequestType"].ToString() == "All") { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", clsAPI.orgID), userID, htblTestData["MethodType"].ToString(), _ecomLoginKey, _ecomTransactionKey); var userData = JsonConvert.DeserializeObject <List <Users> >(result); if (userData.Count > 1) { _Flag = true; } else { _Flag = false; } return(_Flag); } if (htblTestData["RequestType"].ToString() == "Single") { //Get All Users oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", clsAPI.orgID), userID, htblTestData["MethodType"].ToString(), _ecomLoginKey, _ecomTransactionKey); var userData = JsonConvert.DeserializeObject <List <Users> >(result); if (userData.Count > 0) { //Find the User that we created and get its ID for (int iEnrolUser = 0; iEnrolUser < userData.Count; iEnrolUser++) { if (userData[iEnrolUser].Profile.F015.ToString().Contains(htblTestData["UserEmail"].ToString())) { string userid = userData[iEnrolUser].ID.ToString(); //Use the ID to create a specific URL to get particular user oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSingleUser.Replace("{orgID}", clsAPI.orgID).Replace("{UserID}", userid), userID, htblTestData["MethodType"].ToString(), _ecomLoginKey, _ecomTransactionKey); var singleUserData = JsonConvert.DeserializeObject <Users>(result); if (singleUserData.Profile.F015.Contains(htblTestData["UserEmail"].ToString())) { _Flag = true; break; } else { _Flag = false; } } else { _Flag = false; } } } } return(_Flag); } catch (Exception e) { clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }
/// <summary> /// function to get user transcript /// </summary> /// <param name="orgID">organization id</param> /// <param name="userID">user id</param> /// <param name="testCaseType">positive/negative</param> /// <param name="certificationCourseName">course name</param> /// <returns>true/false</returns> public bool GetUserTranscript(string orgID, string userID, string testCaseType, string certificationCourseName) { bool _flag = false; string statusCode = string.Empty; string result = string.Empty; clsGeneric oGeneric = new clsGeneric(); clsAPITranscript oclsAPITranscript = new clsAPITranscript(); try { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetUserTranscript.Replace("{orgID}", orgID).Replace("{userid}", userID), oclsAPITranscript, "H1", _ecomLoginKey, _ecomTransactionKey); if (testCaseType.ToUpper() == "NEGATIVE") { if (statusCode == "OK/200") { _flag = true; } else { _flag = false; } } else if (testCaseType.ToUpper() == "POSITIVE") { if (statusCode == "OK/200") { _flag = true; } else { _flag = false; } } else if (testCaseType == "CERTIFICATION") { try { var certCourseID = JsonConvert.DeserializeObject <List <clsAPITranscript> >(result); var courseid = certCourseID.Where(cus => cus.CourseName == certificationCourseName); List <ILMS.clsAPITranscript> t = new List <clsAPITranscript>(); t = courseid.ToList(); UserEnrollment ouser = new UserEnrollment(); ouser.userid = userID; oGeneric.GetApiResponseCodeData(out statusCode, out result, "POST", ApplicationSettings.APIURI() + clsAPI.EnrollRecertification.Replace("{orgid}", orgID).Replace("{CourseID}", t[0].CourseID.ToString()), ouser, "H1", _ecomLoginKey, _ecomTransactionKey); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetUserTranscript.Replace("{orgID}", orgID).Replace("{courseID}", t[0].CourseID.ToString()).Replace("{userid}", userID), ouser, "H1", _ecomLoginKey, _ecomTransactionKey); var status = JsonConvert.DeserializeObject <List <clsAPITranscript> >(result); if (status.Count > 0) { courseid = status.Where(cus => cus.CourseName == certificationCourseName); t = courseid.ToList(); if (t[0].Status.ToUpper() == "NOT STARTED") { _flag = true; } else { _flag = false; } } else { _flag = false; } } catch (Exception er) { clsGlobalVariable.strExceptionReport = "Recertification scenario failed"; return(false); } } } catch { clsGlobalVariable.strExceptionReport = "Get transcript scenario failed"; return(false); } return(_flag); }