public ActionResult Edit(CeremonyEditModel ceremonyEditModel)
        {
            Check.Require(ceremonyEditModel.Ceremony != null, "Ceremony cannot be null.");
            //Check.Require(!ceremonyEditModel.id.HasValue, "Ceremony Id is required.");

            var destCeremony = Repository.OfType<Ceremony>().GetNullableById(ceremonyEditModel.id.Value);
            if (ceremonyEditModel.Ceremony == null) return this.RedirectToAction(a => a.Index());

            if (!destCeremony.IsEditor(User.Identity.Name))
            {
                Message = "You do not have permission to edit selected ceremony.";
                return this.RedirectToAction(a => a.Index());
            }

            // update the term
            var termCode = _termRepository.GetNullableById(ceremonyEditModel.Term);
            destCeremony.TermCode = termCode;

            // copy all the fields
            CopyCeremony(destCeremony, ceremonyEditModel.Ceremony, ceremonyEditModel.CeremonyMajors, ceremonyEditModel.Colleges, ceremonyEditModel.TicketDistributionMethods);

            ModelState.Clear();

            // validate the ceremony
            destCeremony.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                Repository.OfType<Ceremony>().EnsurePersistent(destCeremony);
                _ceremonyService.ResetUserCeremonies();
                return this.RedirectToAction(a => a.Index());
            }

            var viewModel = CeremonyViewModel.Create(Repository, User, _majorService, destCeremony);

            return View(viewModel);
        }
        public ActionResult Create(CeremonyEditModel ceremonyEditModel)
        {
            ModelState.Clear();

            if (string.IsNullOrEmpty(ceremonyEditModel.Term))
            {
                ModelState.AddModelError("Term Code", "Term code must be selected.");
            }

            var termCode = _termRepository.GetNullableById(ceremonyEditModel.Term);

            if (termCode == null && !string.IsNullOrEmpty(ceremonyEditModel.Term))
            {
                // term code doesn't exist, create a new one
                var vTermCode = _vTermRepository.GetNullableById(ceremonyEditModel.Term);

                termCode = new TermCode(vTermCode);
            }

            Ceremony ceremony = new Ceremony();
            CopyCeremony(ceremony, ceremonyEditModel.Ceremony, ceremonyEditModel.CeremonyMajors, ceremonyEditModel.Colleges, ceremonyEditModel.TicketDistributionMethods);
            ceremony.TermCode = termCode;
            ceremony.AddEditor(_userService.GetCurrentUser(User), true);

            // fix the time on the end dates, so it ends on

            ceremony.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                // save
                _termRepository.EnsurePersistent(termCode, true);
                Repository.OfType<Ceremony>().EnsurePersistent(ceremony);
                TermService.UpdateCurrent(termCode);    // update the cache.

                // null out the current list of ceremonies the user has access to
                _ceremonyService.ResetUserCeremonies();

                // display a message
                Message = "Ceremony has been created.";

                // redirect to the list
                return this.RedirectToAction(a => a.Edit(ceremony.Id));
            }

            // redirect back to the page
            var viewModel = CeremonyViewModel.Create(Repository, User, _majorService, ceremony);
            viewModel.Ceremony = ceremony;

            return View(viewModel);
        }