public async Task<ActionResult>Charge(CourseRegistrationModel model) { //if(!ModelState.IsValid) //{ // return View(model); //} var chargeId = await ProcessPayment(model, (int)TempData["courseid"] ); Course @course = db.Courses.Find((int)TempData["courseid"]); var courseReg = new Course_Registration(); foreach (var p in model.Participant) { if (p.Name != null) { courseReg = new Course_Registration() { Transaction_ID = chargeId, Course_ID = (int)TempData["courseid"], Id = User.Identity.GetUserId(), P_Name = p.Name, P_Phone = p.PhoneNumber, P_UnderAge = p.UnderAge }; db.Course_Registration.Add(courseReg); @course.Participating_Students++; db.SaveChanges(); } } return View("PaymentSuccessful"); }
public ActionResult FreeRegistration(CourseRegistrationModel model) { var courseReg = new Course_Registration(); Course @course = db.Courses.Find((int)TempData["courseid"]); foreach (var p in model.Participant) { if (p.Name != null) { courseReg = new Course_Registration() { Transaction_ID = "Free Course", Course_ID = (int)TempData["courseid"], Id = User.Identity.GetUserId(), P_Name = p.Name, P_Phone = p.PhoneNumber, P_UnderAge = p.UnderAge }; db.Course_Registration.Add(courseReg); @course.Participating_Students++; db.SaveChanges(); } } return View("PaymentSuccessful"); }