This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using new NetworkManager for Course Enrollment (#791)
- Loading branch information
1 parent
f7b9206
commit 0a37051
Showing
5 changed files
with
46 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// OEXCourseInfoViewController+Swift.swift | ||
// edX | ||
// | ||
// Created by Saeed Bashir on 8/25/16. | ||
// Copyright © 2016 edX. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension OEXCourseInfoViewController { | ||
|
||
func enrollInCourse(courseID: String, emailOpt: Bool) { | ||
guard let _ = OEXSession.sharedSession()?.currentUser else { | ||
OEXRouter.sharedRouter().showSignUpScreenFromController(self, completion: { | ||
self.enrollInCourse(courseID, emailOpt: emailOpt) | ||
}) | ||
return; | ||
} | ||
|
||
let environment = OEXRouter.sharedRouter().environment; | ||
|
||
if let _ = environment.dataManager.enrollmentManager.enrolledCourseWithID(courseID) { | ||
showMainScreenWithMessage(Strings.findCoursesAlreadyEnrolledMessage, courseID: courseID) | ||
return | ||
} | ||
|
||
let request = CourseCatalogAPI.enroll(courseID) | ||
environment.networkManager.taskForRequest(request) {[weak self] response in | ||
if response.response?.httpStatusCode.is2xx ?? false { | ||
environment.analytics.trackUserEnrolledInCourse(courseID) | ||
self?.showMainScreenWithMessage(Strings.findCoursesEnrollmentSuccessfulMessage, courseID: courseID) | ||
} | ||
else { | ||
self?.showOverlayMessage(Strings.findCoursesEnrollmentErrorDescription) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters