public async Task <ActionResult> ChangeGoal(ChangeGoalViewModel model) { // get current user id string userId = User.Identity.GetUserId(); // change goal //check if user's pay ServiceResult result; bool isPaid = await m_userService.IsPaid(userId); if (isPaid == true) { Session["isPaid"] = "true"; result = await m_classService.ChangeGoalAsync(userId, model.Class.Id, model.NumberOfDays); } else { result = await m_classService.ChangeGoalAsync(userId, model.Class.Id, UNPAID_USER_WORD_AMOUNT); //result = await m_classService.ChangeGoalAsync(userId, model.Class.Id, model.NumberOfDays); Session["isPaid"] = "false"; } // Check result if (result == ServiceResult.Success) { return(RedirectToAction("ClassInfoAndRegister", "LearnWord", new { area = "galaxygate", classId = model.Class.Id })); } else { return(View("Error")); } }
public async Task <ActionResult> ChangeGoal(string classId) { string userId = User.Identity.GetUserId(); //check user's pay // get current goal var cls = await m_classService.GetUserJoinClass(userId, classId); // check if user pay or not bool isPaid = await m_userService.IsPaid(userId); // adding to session if (isPaid == true) { // session is true Session["isPaid"] = "true"; } else { Session["isPaid"] = "false"; } // user not join class if (cls == null) { return(RedirectToAction("CourseInfo", "LearnWord")); } else { ChangeGoalViewModel model = new ChangeGoalViewModel(cls); return(View(model)); } }