public async Task <ActionResult> ClassInfoAndRegister(string classId) { DateTime start = DateTime.Now; // Get user id string userId = User.Identity.GetUserId(); // check user registered class before or not bool isRegister = await this.m_classService.IsUserRegisteredClassAsync(userId, classId); // get class info Class classInfo = await this.m_classService.GetClassAsync(classId); // get course info Course courseInfo = await this.m_courseService.GetCourseByIdAsync(Constraint.HepaCourse.TU_VUNG); // Get list of words user has to learn today IList <TodayWord> todayWords = await this.m_learnWordService.GetListWordsTodayAsync(userId, classId); // create model ClassInfoAndRegisterViewModel model = new ClassInfoAndRegisterViewModel(classInfo, courseInfo, todayWords, isRegister); // check if user is paid bool isPaid = await m_userService.IsPaid(userId); if (isPaid == true) { Session["isPaid"] = "true"; } else { Session["isPaid"] = "false"; } System.Diagnostics.Debug.WriteLine("Class info and register: {0}", (DateTime.Now - start)); // return model return(View(model)); }
public async Task <ActionResult> RegisterConfirm(ClassInfoAndRegisterViewModel model) { // CHECK NUMBER OF WEEKS if (model.NumberOfWeeks <= 0) { model.NumberOfWeeks = 8; } // Get current user id string userId = User.Identity.GetUserId(); // Register to a class ServiceResult result; if (await m_userService.IsPaid(userId) == true) { Session["isPaid"] = true; result = await m_classService .RegisterToClassAsync(userId, model.CourseInfo.Id, model.ClassInfo.Id, model.NumberOfWeeks); } else { Session["isPaid"] = false; //result = await m_classService //.RegisterToClassAsync(userId, model.CourseInfo.Id, model.ClassInfo.Id, model.NumberOfWeeks); result = await m_classService .RegisterToClassAsync(userId, model.CourseInfo.Id, model.ClassInfo.Id, UNPAID_USER_WORD_AMOUNT); } if (result == ServiceResult.Success) { // Go to class return(RedirectToAction("Resume", "LearnWord", new { area = "galaxygate", classId = model.ClassInfo.Id })); } else { return(View("Error")); } }