public ActionResult Login(User user) { User userRes = new User(); bool isSignedin = false; using (var client = new DatamantraAPIClient()) { string requestUri = "User/Login"; var _loginResponse = client.PostAsJsonAsync(requestUri, user).Result; if (_loginResponse != null && _loginResponse.IsSuccessStatusCode) { userRes = _loginResponse.Content.ReadAsAsync <User>().Result; if (userRes != null && userRes.Status == StatusType.Success) { //2nd Param for Remember Me Session[SessionItemKey.UserId] = userRes.UserId; Session[SessionItemKey.EmailAddress] = userRes.EmailAddress.ToString(); Session[SessionItemKey.UserName] = userRes.UserName; Session[SessionItemKey.RoleID] = Utility.GetInt(userRes.RoleId); FormsAuthentication.SetAuthCookie(userRes.EmailAddress, false); isSignedin = true; //return RedirectToAction("Courses", "Datamantra"); //return Json(isSignedin, JsonRequestBehavior.AllowGet); } } } return(Json(isSignedin, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveUser(User user, FormCollection form) { user.StaffCourseLst = new List <CourseAuthorMapping>(); bool is_saved = false; for (int i = 1; i < 10; i++) { if (form["CategoryId" + i] != null) { CourseAuthorMapping _CourseAuthorMapping = new CourseAuthorMapping(); _CourseAuthorMapping.CourseId = Utility.GetLong(form["CourseId" + i]); _CourseAuthorMapping.CategoryId = Utility.GetLong(form["CategoryId" + i]); _CourseAuthorMapping.UserId = user.UserId; user.StaffCourseLst.Add(_CourseAuthorMapping); } } using (var client = new DatamantraAPIClient()) { string requestUri = "User/SaveUser"; var _UserResponse = client.PostAsJsonAsync(requestUri, user).Result; if (_UserResponse != null && _UserResponse.IsSuccessStatusCode) { var userinfo = _UserResponse.Content.ReadAsAsync <User>().Result; is_saved = (userinfo.UserId > 0) ? true : false; } } return(Json(is_saved, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveRoles(FormCollection form, Role role) { bool is_saved = false; using (var client = new DatamantraAPIClient()) { string requestUri = "Admin/SaveRole"; var _UserResponse = client.PostAsJsonAsync(requestUri, role).Result; if (_UserResponse != null && _UserResponse.IsSuccessStatusCode) { is_saved = _UserResponse.Content.ReadAsAsync <bool>().Result; } } return(Json(is_saved, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveCategory(Category category) { bool is_saved = false; //form["editor1"] using (var client = new DatamantraAPIClient()) { string requestUri = "Admin/SaveCategory"; var _UserResponse = client.PostAsJsonAsync(requestUri, category).Result; if (_UserResponse != null && _UserResponse.IsSuccessStatusCode) { is_saved = _UserResponse.Content.ReadAsAsync <bool>().Result; } } return(Json(is_saved, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveReview(string comments, long courseId, long?reviewId, decimal?rating) { bool issaved = false; Review review = new Review(); review.Comments = comments; review.UserId = Utility.GetUserIdFromSession(); review.CourseId = courseId; review.ReviewId = reviewId ?? 0; review.Rating = rating ?? 0; using (var client = new DatamantraAPIClient()) { string requestUri = "User/SaveCourseReview"; var _ReviewResponse = client.PostAsJsonAsync(requestUri, review).Result; if (_ReviewResponse != null && _ReviewResponse.IsSuccessStatusCode) { issaved = _ReviewResponse.Content.ReadAsAsync <bool>().Result; } } return(Json(issaved, JsonRequestBehavior.AllowGet)); }
public ActionResult SignUp(User user) { User userRes = new User(); using (var client = new DatamantraAPIClient()) { string requestUri = "User/SaveUser"; var _UserResponse = client.PostAsJsonAsync(requestUri, user).Result; if (_UserResponse != null && _UserResponse.IsSuccessStatusCode) { userRes = _UserResponse.Content.ReadAsAsync <User>().Result; if (userRes != null && userRes.Status == StatusType.Success) { SessionEncryption.SetSessionValue(SessionItemKey.RoleID, userRes.RoleId); SessionEncryption.SetSessionValue(SessionItemKey.UserId, userRes.UserId); SessionEncryption.SetSessionValue(SessionItemKey.UserName, userRes.UserName); SessionEncryption.SetSessionValue(SessionItemKey.EmailAddress, userRes.EmailAddress); } } } return(Json(userRes, JsonRequestBehavior.AllowGet)); }