public ActionResult BeltApplication(Guid id, string message)
        {
            Guid currentMemberId = GetCurrentMember().Id;

            // Check for an existing open application
            bool alreadyApplied = db.MemberBelts.Any(
                mb => mb.MemberId == currentMemberId
                    && mb.BeltId == id
                    && mb.Awarded == null
                    && mb.RejectedDate == null);
            if (alreadyApplied)
            {
                return Json("OK");
            }

            Guid beltId = id;
            MemberBelt application = new MemberBelt
            {
                MemberId = GetCurrentMember().Id,
                BeltId = beltId,
                ApplicationDate = DateTime.UtcNow,
                ApplicationNotes = message
            };
            db.MemberBelts.Add(application);
            db.SaveChanges();
            return Json("OK");
        }
        public ActionResult Create(MemberBelt memberbelt)
        {
            if (ModelState.IsValid)
            {
                memberbelt.Id = Guid.NewGuid();
                db.MemberBelts.Add(memberbelt);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.AwardedByAdultId = new SelectList(db.Adults, "Id", "FirstName", memberbelt.AwardedByAdultId);
            ViewBag.BeltId = new SelectList(db.Belts, "Id", "Color", memberbelt.BeltId);
            ViewBag.MemberId = new SelectList(db.Members, "Id", "FirstName", memberbelt.MemberId);
            return View(memberbelt);
        }
 public ActionResult Edit(MemberBelt memberbelt)
 {
     if (ModelState.IsValid)
     {
         db.Entry(memberbelt).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.AwardedByAdultId = new SelectList(db.Adults, "Id", "FirstName", memberbelt.AwardedByAdultId);
     ViewBag.BeltId = new SelectList(db.Belts, "Id", "Color", memberbelt.BeltId);
     ViewBag.MemberId = new SelectList(db.Members, "Id", "FirstName", memberbelt.MemberId);
     return View(memberbelt);
 }