public async Task <IActionResult> Edit(int id, [Bind("enrolledRegisrationId,classSessionId,memberId")] ClassEnrollee classEnrollee) { if (id != classEnrollee.enrolledRegisrationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(classEnrollee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassEnrolleeExists(classEnrollee.enrolledRegisrationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["classSessionId"] = new SelectList(_context.ClassSessions, "classSessionId", "classSessionId", classEnrollee.classSessionId); ViewData["memberId"] = new SelectList(_context.Members, "memberId", "memberId", classEnrollee.memberId); return(View(classEnrollee)); }
public async Task <IActionResult> EnrollMember([Bind("enrolledRegisrationId,classSessionId,memberId")] ClassEnrollee classEnrollee) { if (ModelState.IsValid) { _context.Add(classEnrollee); await _context.SaveChangesAsync(); // update Member's balance int memID = Int32.Parse(Request.Form["memberId"].ToString()); int cID = Int32.Parse(Request.Form["classSessionId"].ToString()); var mem = _context.Members.Where(m => m.memberId == memID).Single();; Member member = (Member)mem; var fclass = _context.ClassSessions.Where(c => c.classSessionId == cID).Include(f => f.FitnessClass).Single(); FitnessClass fc = (FitnessClass)fclass.FitnessClass; double balance = member.currentAmountOwed + fc.fitnessclassFee; member.currentAmountOwed = balance; _context.Update(member); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["classSessionId"] = new SelectList(_context.ClassSessions, "classSessionId", "classSessionId", classEnrollee.classSessionId); ViewData["memberId"] = new SelectList(_context.Members, "memberId", "memberId", classEnrollee.memberId); return(View(classEnrollee)); }
public async Task <IActionResult> Create([Bind("enrolledRegistrationId,classSessionId,memberId")] ClassEnrollee classEnrollee) { if (ModelState.IsValid) { _context.Add(classEnrollee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["classSessionId"] = new SelectList(_context.ClassSessions, "classSessionId", "classSessionId", classEnrollee.classSessionId); ViewData["memberId"] = new SelectList(_context.Members, "memberId", "memberId", classEnrollee.memberId); return(View(classEnrollee)); }