Skip to content

Commit

Permalink
Merge pull request #267 from niharikasingh84/SB-13695_EnrollmentEndDa…
Browse files Browse the repository at this point in the history
…te_Fix

Sb 13695 enrollment end date fix
  • Loading branch information
rahul-tarento authored Jul 17, 2019
2 parents 6aace13 + f21a546 commit a6ca608
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ private void enrollCourseBatch(Request actorMessage) {
Map<String, Object> courseMap = (Map<String, Object>) actorMessage.getRequest();
CourseBatch courseBatch = courseBatchDao.readById((String) courseMap.get(JsonKey.BATCH_ID));
validateCourseBatch(
courseBatch, courseMap, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY));
courseBatch,
courseMap,
(String) actorMessage.getContext().get(JsonKey.REQUESTED_BY),
ActorOperations.ENROLL_COURSE.getValue());

UserCourses userCourseResult = userCourseDao.read(UserCoursesService.getPrimaryKey(courseMap));

Expand Down Expand Up @@ -165,7 +168,10 @@ private void unenrollCourseBatch(Request actorMessage) {
Map<String, Object> request = actorMessage.getRequest();
CourseBatch courseBatch = courseBatchDao.readById((String) request.get(JsonKey.BATCH_ID));
validateCourseBatch(
courseBatch, request, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY));
courseBatch,
request,
(String) actorMessage.getContext().get(JsonKey.REQUESTED_BY),
ActorOperations.UNENROLL_COURSE.getValue());
UserCourses userCourseResult = userCourseDao.read(UserCoursesService.getPrimaryKey(request));
UserCoursesService.validateUserUnenroll(userCourseResult);
Response result = updateUserCourses(userCourseResult);
Expand Down Expand Up @@ -249,7 +255,10 @@ public static Map<String, Object> getCourseObjectFromEkStep(
* @Params
*/
private void validateCourseBatch(
CourseBatch courseBatchDetails, Map<String, Object> request, String requestedBy) {
CourseBatch courseBatchDetails,
Map<String, Object> request,
String requestedBy,
String actorOperation) {

if (ProjectUtil.isNull(courseBatchDetails)) {
ProjectCommonException.throwClientErrorException(
Expand Down Expand Up @@ -280,7 +289,9 @@ private void validateCourseBatch(
if (StringUtils.isNotBlank(courseBatchDetails.getEnrollmentEndDate())) {
courseBatchEnrollmentEndDate = format.parse(courseBatchDetails.getEnrollmentEndDate());
}
if (courseBatchEnrollmentEndDate != null && courseBatchEnrollmentEndDate.before(todaydate)) {
if (ActorOperations.ENROLL_COURSE.getValue().equals(actorOperation)
&& courseBatchEnrollmentEndDate != null
&& courseBatchEnrollmentEndDate.before(todaydate)) {
ProjectLogger.log(
"CourseEnrollmentActor validateCourseBatch Enrollment Date has ended.",
LoggerEnum.INFO.name());
Expand Down

0 comments on commit a6ca608

Please sign in to comment.