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 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_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_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()); }
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 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; }
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; }
private bool CanRemoveEventWave(EventWave waveToRemove, ServiceResult result) { return result.Success; }