private void AddCeremonyParticipations(Registration registration, List<CeremonyParticipation> ceremonyParticipations, ModelStateDictionary modelState, bool adminUpdate = false) { ValidateCeremonyParticipations(ceremonyParticipations, modelState); foreach (var a in ceremonyParticipations) { if (a.Participate && (adminUpdate || a.Ceremony.CanRegister())) { registration.AddParticipation(a.Major, a.Ceremony, a.Tickets, a.TicketDistributionMethod); } } }
private void UpdateCeremonyParticipations(Registration registration, List<CeremonyParticipation> ceremonyParticipations, ModelStateDictionary modelState, bool adminUpdate = false) { ValidateCeremonyParticipations(ceremonyParticipations, modelState); foreach (var a in ceremonyParticipations) { var rp = registration.RegistrationParticipations.Where(b => b.Id == a.ParticipationId).SingleOrDefault(); // only allow updates within registration times or during an admin update if (adminUpdate || a.Ceremony.CanRegister()) { // case where we are newly registering if (rp == null && a.Participate && !a.Cancel) registration.AddParticipation(a.Major, a.Ceremony, a.Tickets, a.TicketDistributionMethod); // case where we are cancelling else if (rp != null) { rp.Cancelled = a.Participate && !a.Cancel ? !a.Participate : a.Cancel; rp.DateUpdated = DateTime.UtcNow.ToPacificTime(); rp.NumberTickets = a.Tickets; rp.TicketDistributionMethod = a.TicketDistributionMethod; rp.Major = a.Major; if (adminUpdate) { rp.Major = a.Major; rp.Ceremony = a.Ceremony; } } } } }