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_UpdateEventDate([DataSourceRequest] DataSourceRequest request, EventDate eventDate)
        {
            if (ModelState.IsValid)
            {
                ServiceResult result = _eventService.UpdateEventDate(eventDate);

                if (!result.Success)
                    Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors());
            }

            return Json(ModelState.ToDataSourceResult());
        }
Ejemplo n.º 3
0
        public ActionResult Ajax_DeleteEventDate([DataSourceRequest] DataSourceRequest request, EventDate eventDate)
        {
            ServiceResult result = _eventService.RemoveEventDate(eventDate.EventDateId);

            if (!result.Success)
                Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors());

            return Json(ModelState.ToDataSourceResult());
        }
Ejemplo n.º 4
0
        public ActionResult Ajax_CreateEventDate([DataSourceRequest] DataSourceRequest request, EventDate eventDate, int masterEventId)
        {
            if (ModelState.IsValid)
            {
                eventDate.EventId = masterEventId;
                ServiceResult result = _eventService.CreateEventDate(eventDate);

                if (!result.Success)
                    Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors());
            }

            return Json(new[] { eventDate }.ToDataSourceResult(request, ModelState));
        }
Ejemplo n.º 5
0
        public ServiceResult UpdateEventDate(EventDate ed)
        {
            var result = new ServiceResult();

            try
            {
                if (ValidateEventDate(ed, result))
                {
                    EventDate updateDate = _repository.EventDates.Find(x => x.EventDateId == ed.EventDateId);
                    updateDate.DateOfEvent = ed.DateOfEvent;

                    foreach (EventWave w in updateDate.EventWaves)
                    {
                        w.StartTime = new DateTime(ed.DateOfEvent.Year, ed.DateOfEvent.Month, ed.DateOfEvent.Day,
                                                   w.StartTime.Hour, w.StartTime.Minute, w.StartTime.Second);
                        w.EndTime = new DateTime(ed.DateOfEvent.Year, ed.DateOfEvent.Month, ed.DateOfEvent.Day,
                                                 w.EndTime.Hour, w.EndTime.Minute, w.EndTime.Second);
                    }
                    _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 CreateEventDate(EventDate ed)
        {
            var result = new ServiceResult();
            try
            {

                if (ValidateCreateEventDate(ed, result))
                {
                    _repository.EventDates.Create(ed);
                    _repository.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }
            return result;
        }
Ejemplo n.º 8
0
        private bool ValidateEventDate(EventDate dateToValidate, ServiceResult result)
        {
            if (dateToValidate.DateOfEvent.Date < DateTime.Now.Date)
                result.AddServiceError("DateOfEvent", "You can not add an event date that is in the past");
            else
            {
                if (
                    _repository.EventDates.Find(
                        x =>
                        dateToValidate.EventDateId != x.EventDateId && dateToValidate.DateOfEvent == x.DateOfEvent &&
                        dateToValidate.EventId == x.EventId) != null)
                    result.AddServiceError("DateOfEvent", "This date is already attached to this event.");
            }

            return result.Success;
        }
Ejemplo n.º 9
0
 private bool CanRemoveEventDate(EventDate dateToRemove, ServiceResult result)
 {
     return result.Success;
 }
Ejemplo n.º 10
0
 private bool CanGenerateWaves(EventDate eventDate, ServiceResult result)
 {
     return result.Success;
 }