public string GetShareBodyText(Team team, EventWave eventWave, User user, EventDate eventDate, bool includeJavascriptLineBreaks) { if (team == null || user == null || eventDate == null) { return(string.Empty); } var filePath = HostingEnvironment.MapPath(string.Format("~/{0}/{1}", DirtyGirlServiceConfig.Settings.EmailTemplatePath, DirtyGirlServiceConfig.Settings.TeamInviteBody)) ?? ""; var bodyText = System.IO.File.ReadAllText(filePath) .Replace("{RegistrantName}", string.Format("{0} {1}", user.FirstName, user.LastName)) .Replace("{EventID}", team.Event.EventId.ToString()) .Replace("{RaceLocation}", team.Event.GeneralLocality) .Replace("{DayOfWeek}", eventDate.DateOfEvent.ToString("dddd")) .Replace("{Month}", eventDate.DateOfEvent.ToString("MMMM")) .Replace("{Day}", eventDate.DateOfEvent.ToString("dd")) .Replace("{Year}", eventDate.DateOfEvent.ToString("yyyy")) .Replace("{WaveNumber}", eventWave.EventWaveId.ToString()) .Replace("{BeginTime}", eventWave.StartTime.ToString("hh:mm tt")) .Replace("{EndTime}", eventWave.EndTime.ToString("hh:mm tt")) .Replace("{TeamCode}", team.Code) .Replace("{LineBreak}", (includeJavascriptLineBreaks ? "\\" : "")); return(bodyText); }
public ServiceResult UpdateEventWave(EventWave ew) { var result = new ServiceResult(); try { if (ValidateEventWave(ew, result)) { EventWave updateWave = _repository.EventWaves.Find(x => x.EventWaveId == ew.EventWaveId); updateWave.StartTime = ew.StartTime; updateWave.EndTime = ew.EndTime; updateWave.IsActive = ew.IsActive; updateWave.MaxRegistrants = ew.MaxRegistrants; _repository.EventWaves.Update(updateWave); if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult RemoveEventWave(int eventWaveId) { var result = new ServiceResult(); try { EventWave waveToDelete = _repository.EventWaves.Find(x => x.EventWaveId == eventWaveId); if (CanRemoveEventWave(waveToDelete, result)) { _repository.EventWaves.Delete(waveToDelete); if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult RemoveEventDate(int eventDateId) { var result = new ServiceResult(); try { EventDate dateToDelete = _repository.EventDates.Find(x => x.EventDateId == eventDateId); List <int> waveIds = dateToDelete.EventWaves.Select(x => x.EventWaveId).ToList(); foreach (int waveId in waveIds) { EventWave wave = dateToDelete.EventWaves.Single(x => x.EventWaveId == waveId); if (CanRemoveEventWave(wave, result)) { _repository.EventWaves.Delete(wave); } } if (result.Success && CanRemoveEventDate(dateToDelete, result)) { _repository.EventDates.Delete(dateToDelete); _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public static string GetShareBodyText(Team team, EventWave eventWave, User user, EventDate eventDate, bool includeJavascriptLineBreaks) { IEmailService emailService = new EmailService(); return(emailService.GetShareBodyText(team, eventWave, user, eventDate, includeJavascriptLineBreaks)); }
public ActionResult EventSelection(Guid itemId, int?eventId, int?eventDateId, int?eventWaveId, bool?returnToRegDetails, bool?redemption) { int eId = (eventId.HasValue)? eventId.Value : 0; var vm = new vmRegistration_EventSelection { ItemId = itemId, CartFocus = SessionManager.CurrentCart.CheckOutFocus, EventOverview = (eventId.HasValue && eventId > 0 ? _service.GetEventOverviewById(eId) : new EventOverview()), EventDateCount = (eventId.HasValue && eventId > 0 ? GetEventDateCount(eId) : 0), LockEvent = true, ReturnToRegistrationDetails = false }; if (eventWaveId.HasValue) { EventWave selectedWave = _service.GetEventWaveById(eventWaveId.Value); vm.EventId = selectedWave.EventDate.EventId; vm.EventDateId = selectedWave.EventDateId; vm.EventWaveId = selectedWave.EventWaveId; } else if (eventDateId.HasValue) { EventDate selectedDate = _service.GetEventDateById(eventDateId.Value); vm.EventId = selectedDate.EventId; vm.EventDateId = selectedDate.EventDateId; } else if (eventId.HasValue) { Event selectedEvent = _service.GetEventById(eventId.Value); vm.EventId = eventId.Value; vm.EventDateId = selectedEvent.EventDates.First().EventDateId; vm.EventName = selectedEvent.GeneralLocality; } // did the cart timeout? if (!SessionManager.CurrentCart.ActionItems.ContainsKey(itemId)) { return(RedirectToAction("Index", "home")); } if (SessionManager.CurrentCart.ActionItems[itemId].ActionType == CartActionType.EventChange || SessionManager.CurrentCart.CheckOutFocus == CartFocusType.Redemption) { vm.LockEvent = false; } if (returnToRegDetails.HasValue && returnToRegDetails.Value == true) { vm.ReturnToRegistrationDetails = true; } return(View(vm)); }
private bool ValidateEventWave(EventWave waveToValidate, ServiceResult result) { EventDate eventDate = _repository.EventDates.Find(x => x.EventDateId == waveToValidate.EventDateId); waveToValidate.StartTime = new DateTime(eventDate.DateOfEvent.Year, eventDate.DateOfEvent.Month, eventDate.DateOfEvent.Day, waveToValidate.StartTime.Hour, waveToValidate.StartTime.Minute, waveToValidate.StartTime.Second); waveToValidate.EndTime = new DateTime(eventDate.DateOfEvent.Year, eventDate.DateOfEvent.Month, eventDate.DateOfEvent.Day, waveToValidate.EndTime.Hour, waveToValidate.EndTime.Minute, waveToValidate.EndTime.Second); return(result.Success); }
public ServiceResult GenerateEventDate(int eventId, DateTime eventDate, DateTime startTime, DateTime endTime, int duration, int maxRegistrants) { var result = new ServiceResult(); try { var newDate = new EventDate { EventId = eventId, DateOfEvent = eventDate, IsActive = true }; if (ValidateEventDate(newDate, result)) { _repository.EventDates.Create(newDate); DateTime newWaveStartTime = startTime; while (newWaveStartTime.TimeOfDay < endTime.TimeOfDay) { var newWave = new EventWave { EventDateId = newDate.EventDateId, StartTime = new DateTime(eventDate.Year, eventDate.Month, eventDate.Day, newWaveStartTime.Hour, newWaveStartTime.Minute, newWaveStartTime.Second) }; newWave.EndTime = newWave.StartTime.AddMinutes(duration - 1); newWave.IsActive = true; newWave.MaxRegistrants = maxRegistrants; newWaveStartTime = newWaveStartTime.AddMinutes(duration); _repository.EventWaves.Create(newWave); } if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult CreateEventWave(EventWave ew) { var result = new ServiceResult(); try { if (ValidateEventWave(ew, result)) { _repository.EventWaves.Create(ew); if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ActionResult WaveSelected(int eventWaveId, Guid itemId, bool ReturnToRegistrationDetails, int?initialWaveId, int?initialEventId) { if (!Utilities.IsValidCart()) { return(RedirectToAction("Index", "home")); } SessionManager.CurrentCart.CheckOutFocus = CartFocusType.Registration; //save event city for thank you page... EventWave selectedWave = _service.GetEventWaveById(eventWaveId); SessionManager.CurrentCart.EventCity = selectedWave.EventDate.Event.GeneralLocality; var action = SessionManager.CurrentCart.ActionItems[itemId]; switch (action.ActionType) { case CartActionType.NewRegistration: ((Registration)action.ActionObject).EventWaveId = eventWaveId; if (ReturnToRegistrationDetails) { return(RedirectToAction("RegistrationDetails", new { itemId })); } return(RedirectToAction("CreateTeam", new { itemId })); case CartActionType.EventChange: if (EventChanged(initialEventId, eventWaveId)) { ((ChangeEventAction)action.ActionObject).UpdatedEventWaveId = eventWaveId; action.ItemReadyForCheckout = true; return(RedirectToAction("checkout", "cart")); } // remove it from the cart, we are not going to be charging the user // is only a wave change, process it as such var eventChangeResult = ChangeWave(((ChangeEventAction)action.ActionObject).RegistrationId, eventWaveId, itemId, initialWaveId); if (eventChangeResult != null) { return(eventChangeResult); } break; case CartActionType.WaveChange: // ok, it changed, update var result = ChangeWave(((ChangeWaveAction)action.ActionObject).RegistrationId, eventWaveId, itemId, initialWaveId); if (result != null) { return(result); } break; } return(RedirectToAction("EventSelection", new { eventWaveId, itemId })); }
public ActionResult RegistrationDetails(vmRegistration_Details model) { if (!Utilities.IsValidCart()) { return(RedirectToAction("Index", "home")); } var regAction = SessionManager.CurrentCart.ActionItems[model.ItemId]; var reg = (Registration)regAction.ActionObject; if (_service.IsDuplicateRegistration(reg.EventWaveId, CurrentUser.UserId, model.RegistrationDetails.FirstName, model.RegistrationDetails.LastName)) { ModelState.AddModelError("FirstName", "You have already registered for this event wave. You may select another wave above, or, if you would like to register another participant for this wave, please enter their name below."); } var fullName = model.RegistrationDetails.FirstName + model.RegistrationDetails.LastName; if (fullName.Replace(" ", "") == model.RegistrationDetails.EmergencyContact.Replace(" ", "")) { ModelState.AddModelError("EmergencyContact", "Emergency contact cannot be the same as the registrant."); } EventWave wave = _service.GetEventWaveById(reg.EventWaveId); if (model.RegistrationDetails.Birthday.HasValue) { if (model.RegistrationDetails.Birthday.Value.AddYears(14) > wave.EventDate.DateOfEvent) { ModelState.AddModelError("Birthday", "The participant must be 14 years or older to join the event.."); } } else { ModelState.AddModelError("Birthday", "Registrants Birthday is required."); } model.RegistrationDetails.Address1 = reg.Address1 = CurrentUser.Address1; model.RegistrationDetails.Address2 = reg.Address2 = CurrentUser.Address2; model.RegistrationDetails.Locality = reg.Locality = CurrentUser.Locality; model.RegistrationDetails.RegionId = reg.RegionId = CurrentUser.RegionId; model.RegistrationDetails.PostalCode = reg.PostalCode = CurrentUser.PostalCode; if (ModelState.IsValid) { reg.AgreeToTerms = model.RegistrationDetails.AgreeToTerms; reg.CartItemId = model.RegistrationDetails.CartItemId; reg.DateAdded = model.RegistrationDetails.DateAdded; reg.Email = model.RegistrationDetails.Email; reg.EmergencyContact = model.RegistrationDetails.EmergencyContact; reg.EmergencyPhone = model.RegistrationDetails.EmergencyPhone; reg.EventLeadId = model.RegistrationDetails.EventLeadId; reg.FirstName = model.RegistrationDetails.FirstName; reg.Gender = model.RegistrationDetails.Gender; reg.IsFemale = model.RegistrationDetails.IsFemale; reg.IsOfAge = model.RegistrationDetails.IsOfAge; reg.IsThirdPartyRegistration = model.RegistrationDetails.IsThirdPartyRegistration; reg.LastName = model.RegistrationDetails.LastName; reg.MedicalInformation = model.RegistrationDetails.MedicalInformation; reg.ParentRegistrationId = model.RegistrationDetails.ParentRegistrationId; reg.Phone = model.RegistrationDetails.Phone; reg.ReferenceAnswer = model.RegistrationDetails.ReferenceAnswer; reg.RegistrationStatus = RegistrationStatus.Active; reg.RegistrationType = model.RegistrationDetails.RegistrationType; reg.SpecialNeeds = model.RegistrationDetails.SpecialNeeds; reg.Birthday = model.RegistrationDetails.Birthday.Value.Date; reg.TShirtSize = model.RegistrationDetails.TShirtSize; reg.PacketDeliveryOption = (model.RegistrationDetails.PacketDeliveryOption.HasValue ? model.RegistrationDetails.PacketDeliveryOption : RegistrationMaterialsDeliveryOption.OnSitePickup); reg.UserId = CurrentUser.UserId; reg.Signature = model.RegistrationDetails.Signature; reg.IsIAmTheParticipant = model.RegistrationDetails.IsIAmTheParticipant; reg.IsSignatureConsent = model.RegistrationDetails.IsSignatureConsent; reg.AgreeTrademark = model.RegistrationDetails.AgreeTrademark; reg.ConfirmationCode = model.RegistrationDetails.ConfirmationCode; regAction.ActionObject = reg; regAction.ItemReadyForCheckout = true; // should check this better... if (((int)reg.PacketDeliveryOption.Value == 1)) { ActionItem shippingFeeItem = _service.CreateShippingFee(model.ItemId, reg.EventWaveId, reg.PacketDeliveryOption); SessionManager.CurrentCart.ActionItems.Add(Guid.NewGuid(), shippingFeeItem); } if (CheckAddProcessingFee(reg, model.ItemId)) { ActionItem processingFeeItem = _service.CreateProcessingFee(model.ItemId, reg.EventWaveId, reg.PacketDeliveryOption); SessionManager.CurrentCart.ActionItems.Add(Guid.NewGuid(), processingFeeItem); } else { // check to see if the processing fee is already in the cart. If so, we know we do not want it, so remove it. RemoveProcessingFee(model.ItemId); } return(RedirectToAction("checkout", "cart")); } model.EventWave = wave; model.EventOverview = _service.GetEventOverviewById(wave.EventDate.EventId); model.RegionList = _service.GetRegionsByCountry(DirtyGirlConfig.Settings.DefaultCountryId); model.RegistrationTypeList = DirtyGirlExtensions.ConvertToSelectList <RegistrationType>(); model.EventLeadList = _service.GetEventLeads(wave.EventDate.EventId, true); model.PacketDeliveryOptionList = DirtyGirlExtensions.ConvertToSelectList <RegistrationMaterialsDeliveryOption>(); model.TShirtSizeList = DirtyGirlExtensions.ConvertToSelectList <TShirtSize>(); model.TShirtSizeList.RemoveAt(0); return(View(model)); }
private bool CanRemoveEventWave(EventWave waveToRemove, ServiceResult result) { return(result.Success); }
public ActionResult Ajax_DeleteEventWave([DataSourceRequest] DataSourceRequest request, EventWave eventWave) { ServiceResult result = _eventService.RemoveEventWave(eventWave.EventWaveId); if (!result.Success) { Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors()); } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult Ajax_UpdateEventWave([DataSourceRequest] DataSourceRequest request, EventWave eventWave) { if (ModelState.IsValid) { ServiceResult result = _eventService.UpdateEventWave(eventWave); if (!result.Success) { Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors()); } } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult Ajax_CreateEventWave([DataSourceRequest] DataSourceRequest request, EventWave eventWave, int masterEventDateId) { if (ModelState.IsValid) { eventWave.EventDateId = masterEventDateId; ServiceResult result = _eventService.CreateEventWave(eventWave); if (!result.Success) { Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors()); } } return(Json(ModelState.ToDataSourceResult())); }