Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
 private bool CanRemoveEventWave(EventWave waveToRemove, ServiceResult result)
 {
     return result.Success;
 }