public ActionResult NewEvent(NewCalendarEvent newEvent) { // if a create another was clicked instead of just submitting the event. bool createAnother = false; if (Request.Form["createAnother"] != null) createAnother = true; bool createAndTrack = false; if (Request.Form["createTrack"] != null) createAndTrack = true; try { var memId = RDN.Library.Classes.Account.User.GetMemberId(); List<long> listOfGroupIds = new List<long>(); if (!String.IsNullOrEmpty(newEvent.ToGroupIds)) { foreach (string guid in newEvent.ToGroupIds.Split(',')) { long temp = new long(); if (Int64.TryParse(guid, out temp)) listOfGroupIds.Add(temp); } } EndsWhenReoccuringEnum endsWhenn = (EndsWhenReoccuringEnum)Enum.Parse(typeof(EndsWhenReoccuringEnum), newEvent.EndsWhen); int monthlyIntervalId = 0; if (!String.IsNullOrEmpty(newEvent.MonthlyIntervalId)) monthlyIntervalId = Convert.ToInt32(newEvent.MonthlyIntervalId); FrequencyTypeEnum frequency = (FrequencyTypeEnum)Enum.Parse(typeof(FrequencyTypeEnum), newEvent.RepeatsFrequencySelectedId); //we set if the event is reocurring Guid eventIdd = new Guid(); if (!newEvent.IsReoccurring) eventIdd = CalendarEventFactory.CreateNewEvent(newEvent.CalendarId, newEvent.StartDate, newEvent.EndDate, new Guid(newEvent.SelectedLocationId), newEvent.Name, newEvent.Link, newEvent.Notes, newEvent.AllowSelfCheckIn, newEvent.IsPublicEvent, false, new Guid(), Convert.ToInt64(newEvent.SelectedEventTypeId), newEvent.BroadcastEvent, newEvent.TicketUrl, newEvent.ColorTempSelected, listOfGroupIds, memId); else eventIdd = CalendarEventFactory.CreateNewEventReOcurring(newEvent.CalendarId, newEvent.StartDate, newEvent.EndDate, new Guid(newEvent.SelectedLocationId), newEvent.Name, newEvent.Link, newEvent.Notes, newEvent.AllowSelfCheckIn, frequency, newEvent.IsSunday, newEvent.IsMonday, newEvent.IsTuesday, newEvent.IsWednesday, newEvent.IsThursday, newEvent.IsFriday, newEvent.IsSaturday, endsWhenn, Convert.ToInt32(newEvent.EndsOccurences), endsWhenn == EndsWhenReoccuringEnum.On ? Convert.ToDateTime(newEvent.EndsDate) : new DateTime(), Convert.ToInt64(newEvent.SelectedEventTypeId), newEvent.BroadcastEvent, newEvent.IsPublicEvent, monthlyIntervalId, newEvent.TicketUrl, newEvent.ColorTempSelected, listOfGroupIds, memId); if (createAnother) { return Redirect(Url.Content("~/calendar/new/" + newEvent.CalendarType.ToString().Replace("-", "") + "/" + newEvent.CalendarId.ToString().Replace("-", "") + "/true")); } else if (createAndTrack) { return Redirect(Url.Content("~/calendar/event/checkin-l/" + newEvent.CalendarType.ToString().Replace("-", "") + "/" + newEvent.CalendarId.ToString().Replace("-", "") + "/" + eventIdd.ToString().Replace("-", ""))); } else { return Redirect(Url.Content("~/calendar/event/" + newEvent.CalendarType.ToString().Replace("-", "") + "/" + newEvent.CalendarId.ToString().Replace("-", "") + "/" + eventIdd.ToString().Replace("-", ""))); } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: newEvent.SelectedLocationId); } if (MemberCache.GetCalendarDefaultView(RDN.Library.Classes.Account.User.GetUserId()) == CalendarDefaultViewEnum.List_View) return Redirect(Url.Content("~/calendar/" + newEvent.CalendarType.ToString().Replace("-", "") + "/" + newEvent.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sww)); else return Redirect(Url.Content("~/calendar/view/" + newEvent.CalendarType.ToString().Replace("-", "") + "/" + newEvent.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sww)); }
public ActionResult ViewEvent(string type, string calId, string eventId) { NewCalendarEvent cal = new NewCalendarEvent(); try { var memId = RDN.Library.Classes.Account.User.GetMemberId(); var league = MemberCache.GetLeagueOfMember(memId); if (league != null) SetCulture(league.CultureSelected); var calEvent = CalendarEventFactory.GetEvent(new Guid(eventId), memId, new Guid(calId)); if (calEvent == null) if (MemberCache.GetCalendarDefaultView(memId) == CalendarDefaultViewEnum.List_View) return Redirect(Url.Content("~/calendar/" + type + "/" + calId + "?u=" + SiteMessagesEnum.dex)); else return Redirect(Url.Content("~/calendar/view/" + type + "/" + calId + "?u=" + SiteMessagesEnum.dex)); cal = new NewCalendarEvent(calEvent); cal.CalendarId = new Guid(calId); cal.CalendarType = type; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return View(cal); }
public ActionResult ViewStartedSkating(string id, string name) { NewCalendarEvent cal = new NewCalendarEvent(); try { Guid memberId = RDN.Library.Classes.Account.User.GetMemberId(); var calEvent = CalendarEventFactory.GetStartedSkatingEvent(new Guid(id)); calEvent.CalendarId = MemberCache.GetCalendarIdForMemberLeague(memberId); calEvent.CalendarType = CalendarOwnerEntityEnum.league.ToString(); cal = new NewCalendarEvent(calEvent); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return View(cal); }
public ActionResult CheckInSmall(string type, string calendarId, string eventId) { var memId = RDN.Library.Classes.Account.User.GetMemberId(); var calen = CalendarEventFactory.GetEvent(new Guid(eventId), memId, new Guid(calendarId)); NewCalendarEvent cal = new NewCalendarEvent(calen); try { var league = MemberCache.GetLeagueOfMember(memId); if (league != null) SetCulture(league.CultureSelected); ViewBag.IsSuccessful = false; if (calen == null) return Redirect(Url.Content("~/calendar/" + type + "/" + calendarId)); cal.CalendarId = new Guid(calendarId); Guid entityId = CalendarFactory.GetEntityOwnerId(new Guid(calendarId), (CalendarOwnerEntityEnum)Enum.Parse(typeof(CalendarOwnerEntityEnum), type)); cal.CalendarType = type; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return View(cal); }
public ActionResult ExportEventRoster(NewCalendarEvent calEvent) { var memId = RDN.Library.Classes.Account.User.GetMemberId(); var league = MemberCache.GetLeagueOfMember(memId); var calEventTemp = CalendarEventFactory.GetEvent(calEvent.CalendarItemId, memId, calEvent.CalendarId); using (ExcelPackage p = new ExcelPackage()) { try { p.Workbook.Properties.Author = "RDNation.com"; p.Workbook.Properties.Title = "Event Roster " + calEventTemp.Name + " - " + calEventTemp.StartDate.ToString("yyyy-M-d"); //we create the first sheet. ExcelWorksheet reportSheet = p.Workbook.Worksheets.Add("Roster"); reportSheet.Name = RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly("Roster " + calEventTemp.Name + " - " + calEventTemp.StartDate.ToString("yyyy-M-d")); //Setting Sheet's name reportSheet.Cells.Style.Font.Size = 11; //Default font size for whole sheet reportSheet.Cells.Style.Font.Name = "Calibri"; //Default Font name for whole sheet reportSheet.Cells[1, 1].Value = "Derby Name"; reportSheet.Cells[1, 2].Value = "#"; reportSheet.Cells[1, 3].Value = "Full Name"; reportSheet.Cells[1, 4].Value = "Present-" + calEventTemp.EventType.PointsForNotPresent; reportSheet.Cells[1, 5].Value = "Partial-" + calEventTemp.EventType.PointsForPartial; reportSheet.Cells[1, 6].Value = "Not Present-" + calEventTemp.EventType.PointsForNotPresent; reportSheet.Cells[1, 7].Value = "Excused-" + calEventTemp.EventType.PointsForExcused; reportSheet.Cells[1, 8].Value = "Tardy-" + calEventTemp.EventType.PointsForTardy; reportSheet.Cells[1, 9].Value = "Addnl Pnts."; reportSheet.Cells[1, 10].Value = "Notes"; int rowReport = 2; foreach (var attendee in calEventTemp.Attendees) { try { reportSheet.Cells[rowReport, 1].Value = attendee.MemberName; reportSheet.Cells[rowReport, 2].Value = attendee.MemberNumber; reportSheet.Cells[rowReport, 3].Value = attendee.FullName; switch (attendee.PointType) { case CalendarEventPointTypeEnum.Present: reportSheet.Cells[rowReport, 4].Value = "X"; break; case CalendarEventPointTypeEnum.Partial: reportSheet.Cells[rowReport, 5].Value = "X"; break; case CalendarEventPointTypeEnum.Not_Present: reportSheet.Cells[rowReport, 6].Value = "X"; break; case CalendarEventPointTypeEnum.Excused: reportSheet.Cells[rowReport, 7].Value = "X"; break; case CalendarEventPointTypeEnum.Tardy: reportSheet.Cells[rowReport, 8].Value = "X"; break; } reportSheet.Cells[rowReport, 4].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; reportSheet.Cells[rowReport, 5].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; reportSheet.Cells[rowReport, 6].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; reportSheet.Cells[rowReport, 7].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; reportSheet.Cells[rowReport, 8].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; if (attendee.AdditionalPoints != 0) reportSheet.Cells[rowReport, 9].Value = attendee.AdditionalPoints; reportSheet.Cells[rowReport, 9].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; reportSheet.Cells[rowReport, 10].Value = attendee.Note; rowReport += 1; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } //create the remaining sheets with the names. foreach (var attendee in calEventTemp.MembersToCheckIn) { try { reportSheet.Cells[rowReport, 1].Value = attendee.MemberName; reportSheet.Cells[rowReport, 2].Value = attendee.MemberNumber; reportSheet.Cells[rowReport, 3].Value = attendee.FullName; rowReport += 1; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } reportSheet.Cells["A1:K20"].AutoFitColumns(); for (int i = 1; i < 11; i++) { for (int j = 1; j < rowReport; j++) { reportSheet.Cells[j, i].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; reportSheet.Cells[j, i].Style.Border.Top.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; reportSheet.Cells[j, i].Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; reportSheet.Cells[j, i].Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; } } reportSheet.Cells[1, 1, rowReport, 10].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Medium); reportSheet.Cells[rowReport, 5, rowReport, 6].Merge = true; reportSheet.Cells[rowReport, 5, rowReport, 6].Value = "Provided by RDNation"; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } //Generate A File with Random name Byte[] bin = p.GetAsByteArray(); string file = "EventRoster_" + RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(calEventTemp.Name) + "_" + calEventTemp.StartDate.ToString("yyyyMMdd") + ".xlsx"; return File(bin, RDN.Utilities.IO.FileExt.GetMIMEType(file), file); } }
public ActionResult EditReoccurringEvent(string type, string calId, string reoccuringEventId) { NewCalendarEvent cal = new NewCalendarEvent(); try { var calEvent = CalendarEventFactory.GetEventReocurring(new Guid(reoccuringEventId), new Guid(calId)); if (calEvent == null) return Redirect(Url.Content("~/calendar/" + type + "/" + calId)); cal = new NewCalendarEvent(calEvent); cal.CalendarId = new Guid(calId); cal.CalendarType = type; cal.LeagueId = MemberCache.GetLeagueIdOfMember(RDN.Library.Classes.Account.User.GetMemberId()); var colors = ColorDisplayFactory.GetLeagueColors(cal.LeagueId); cal.ColorList = new SelectList(colors, "HexColor", "NameOfColor"); var locs = RDN.Library.Classes.Calendar.CalendarFactory.GetLocationsOfCalendar(new Guid(calId)); var eventTypes = RDN.Library.Classes.Calendar.CalendarFactory.GetEventTypesOfCalendar(new Guid(calId)); var AllowSelfCheckin = CalendarFactory.GetCalendar(new Guid(calId), (CalendarOwnerEntityEnum)Enum.Parse(typeof(CalendarOwnerEntityEnum), type)); if (cal.Location != null) cal.Locations = new SelectList(locs, "LocationId", "LocationName", (object)cal.Location.LocationId); else cal.Locations = new SelectList(locs, "LocationId", "LocationName"); if (cal.EventType != null) cal.EventTypes = new SelectList(eventTypes, "CalendarEventTypeId", "EventTypeName", (object)cal.EventType.CalendarEventTypeId); else cal.EventTypes = new SelectList(eventTypes, "CalendarEventTypeId", "EventTypeName"); cal.AllowSelfCheckIn = AllowSelfCheckin.AllowSelfCheckIn; var repeatsFrequency = (from ScheduleWidget.Enums.FrequencyTypeEnum d in Enum.GetValues(typeof(ScheduleWidget.Enums.FrequencyTypeEnum)) where d.ToString() != "None" select new SelectListItem { Value = ((int)d).ToString(), Text = d.ToString(), Selected = FrequencyTypeEnum.Weekly == d }); if (String.IsNullOrEmpty(cal.RepeatsFrequencySelectedId)) cal.RepeatsFrequencyDropDown = new SelectList(repeatsFrequency, "Value", "Text", ((object)2)); else cal.RepeatsFrequencyDropDown = new SelectList(repeatsFrequency, "Value", "Text", ((object)cal.RepeatsFrequencySelectedId)); var montlhyInterval = (from ScheduleWidget.Enums.MonthlyIntervalEnum d in Enum.GetValues(typeof(ScheduleWidget.Enums.MonthlyIntervalEnum)) select new SelectListItem { Value = ((int)d).ToString(), Text = d.ToString(), Selected = MonthlyIntervalEnum.First == d }); if (String.IsNullOrEmpty(cal.MonthlyIntervalId)) cal.MonthlyInterval = new SelectList(montlhyInterval, "Value", "Text", ((object)1)); else cal.MonthlyInterval = new SelectList(montlhyInterval, "Value", "Text", ((object)cal.MonthlyIntervalId)); cal.EndsOccurences = "0"; List<string> repeatCount = new List<string>(); for (int i = 1; i < 50; i++) { repeatCount.Add(i.ToString()); } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return View(cal); }
public ActionResult EditReoccurringEvent(NewCalendarEvent eventUpdated) { var memId = RDN.Library.Classes.Account.User.GetUserId(); try { List<long> listOfGroupIds = new List<long>(); if (!String.IsNullOrEmpty(eventUpdated.ToGroupIds)) { foreach (string guid in eventUpdated.ToGroupIds.Split(',')) { long temp = new long(); if (Int64.TryParse(guid, out temp)) listOfGroupIds.Add(temp); } } int monthlyIntervalId = 0; if (!String.IsNullOrEmpty(eventUpdated.MonthlyIntervalId)) monthlyIntervalId = Convert.ToInt32(eventUpdated.MonthlyIntervalId); FrequencyTypeEnum frequency = (FrequencyTypeEnum)Enum.Parse(typeof(FrequencyTypeEnum), eventUpdated.RepeatsFrequencySelectedId); EndsWhenReoccuringEnum endsWhenn = (EndsWhenReoccuringEnum)Enum.Parse(typeof(EndsWhenReoccuringEnum), eventUpdated.EndsWhen); var calEvent = CalendarEventFactory.UpdateEventReOcurring(eventUpdated.CalendarId, eventUpdated.CalendarItemId, Convert.ToDateTime(eventUpdated.StartDateDisplay), Convert.ToDateTime(eventUpdated.EndDateDisplay), new Guid(eventUpdated.SelectedLocationId), eventUpdated.Name, eventUpdated.Link, eventUpdated.Notes, eventUpdated.AllowSelfCheckIn, frequency, eventUpdated.IsSunday, eventUpdated.IsMonday, eventUpdated.IsTuesday, eventUpdated.IsWednesday, eventUpdated.IsThursday, eventUpdated.IsFriday, eventUpdated.IsSaturday, endsWhenn, endsWhenn == EndsWhenReoccuringEnum.On ? Convert.ToDateTime(eventUpdated.EndsDate) : new DateTime(), Convert.ToInt64(eventUpdated.SelectedEventTypeId), monthlyIntervalId, eventUpdated.ColorTempSelected, eventUpdated.IsPublicEvent, listOfGroupIds, memId); if (MemberCache.GetCalendarDefaultView(memId) == CalendarDefaultViewEnum.List_View) return Redirect(Url.Content("~/calendar/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.re)); else return Redirect(Url.Content("~/calendar/view/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.re)); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: eventUpdated.StartDateDisplay + ":" + eventUpdated.EndDateDisplay); } if (MemberCache.GetCalendarDefaultView(memId) == CalendarDefaultViewEnum.List_View) return Redirect(Url.Content("~/calendar/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sww)); else return Redirect(Url.Content("~/calendar/view/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sww)); }
public ActionResult EditEvent(NewCalendarEvent eventUpdated) { try { List<long> listOfGroupIds = new List<long>(); if (!String.IsNullOrEmpty(eventUpdated.ToGroupIds)) { foreach (string guid in eventUpdated.ToGroupIds.Split(',')) { long temp = new long(); if (Int64.TryParse(guid, out temp)) listOfGroupIds.Add(temp); } } var calEvent = CalendarEventFactory.UpdateEvent(eventUpdated.CalendarId, eventUpdated.CalendarItemId, Convert.ToDateTime(eventUpdated.StartDateDisplay), Convert.ToDateTime(eventUpdated.EndDateDisplay), new Guid(eventUpdated.SelectedLocationId), eventUpdated.Name, eventUpdated.Link, eventUpdated.Notes, eventUpdated.AllowSelfCheckIn, Convert.ToInt64(eventUpdated.SelectedEventTypeId), eventUpdated.TicketUrl, eventUpdated.ColorTempSelected, eventUpdated.IsPublicEvent, listOfGroupIds); if (MemberCache.GetCalendarDefaultView(RDN.Library.Classes.Account.User.GetUserId()) == CalendarDefaultViewEnum.List_View) return Redirect(Url.Content("~/calendar/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.re)); else return Redirect(Url.Content("~/calendar/view/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.re)); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: eventUpdated.StartDateDisplay + "," + eventUpdated.EndDateDisplay); } if (MemberCache.GetCalendarDefaultView(RDN.Library.Classes.Account.User.GetUserId()) == CalendarDefaultViewEnum.List_View) return Redirect(Url.Content("~/calendar/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sww)); else return Redirect(Url.Content("~/calendar/view/" + eventUpdated.CalendarType + "/" + eventUpdated.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sww)); }