public List<AttendeesCodeCampYearResult> Get(AttendeesCodeCampYearQuery query) { var meta = new CodeCampDataContext(); //meta.Log = new SmartInspectLinqToSqlAdapter(); IQueryable<AttendeesCodeCampYear> baseQuery = from myData in meta.AttendeesCodeCampYear select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery,query); if (query.RegisterDateStart != null) { baseQuery = baseQuery.Where(a => a.CreateDate.Value.CompareTo(query.RegisterDateStart.Value) >= 0); } IQueryable<AttendeesCodeCampYearResult> results = GetBaseResultIQueryable(baseQuery); List<AttendeesCodeCampYearResult> resultList = GetFinalResults(results, query); // Put Stuff Here if you want to load another result // The following is done AFTER GetFinalResults so that we don't waste machine cycles sucking in all the // addresses for all results returned, just the ones that are actually being returned. // if (query.WithAddress != null && query.WithAddress == true) // { // foreach (var r in companyResultList) // { // r.CompanyAddressResultList = // CompanyAddressManager.I.Get(new CompanyAddressQuery { CompanyIds = query.Ids, WithAddress = true }); // } // } // return resultList; }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } public List<SessionPicturesResult> Get(SessionPicturesQuery query) { var meta = new CodeCampDataContext(); IQueryable<SessionPictures> baseQuery = from myData in meta.SessionPictures select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery,query); IQueryable<SessionPicturesResult> results = GetBaseResultIQueryable(baseQuery); List<SessionPicturesResult> resultList = GetFinalResults(results, query); // Put Stuff Here if you want to load another result // The following is done AFTER GetFinalResults so that we don't waste machine cycles sucking in all the // addresses for all results returned, just the ones that are actually being returned. // if (query.WithAddress != null && query.WithAddress == true) // { // foreach (var r in companyResultList) // { // r.CompanyAddressResultList = // CompanyAddressManager.I.Get(new CompanyAddressQuery { CompanyIds = query.Ids, WithAddress = true }); // } // } // return resultList; }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } public List<SponsorListContactResult> Get(SponsorListContactQuery query) { var meta = new CodeCampDataContext(); IQueryable<SponsorListContact> baseQuery = from myData in meta.SponsorListContact select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.SponsorListIds != null && query.SponsorListIds.Count > 0) { baseQuery = baseQuery.Where(a => a.SponsorListId != null && query.SponsorListIds.Contains(a.SponsorListId.Value)); } IQueryable<SponsorListContactResult> results = GetBaseResultIQueryable(baseQuery); List<SponsorListContactResult> resultList = GetFinalResults(results, query); List<string> emails = resultList.Select(a => a.EmailAddress).ToList(); List <AttendeesResult> attendeesResults = AttendeesManager.I.Get(new AttendeesQuery() { Emails = emails }); foreach (var r in resultList) { // this could be null which is OK r.UsernameAssociated = attendeesResults.Where(a => a.Email == r.EmailAddress).Select(a => a.Username).FirstOrDefault(); } return resultList; }
public List<LectureRoomsResult> Get(LectureRoomsQuery query) { var meta = new CodeCampDataContext(); IQueryable<LectureRooms> baseQuery = from myData in meta.LectureRooms select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery,query); if (query.SkipIds != null && query.SkipIds.Count() > 0) { baseQuery = from data in baseQuery where !query.SkipIds.Contains(data.Id) select data; } IQueryable<LectureRoomsResult> results = GetBaseResultIQueryable(baseQuery); List<LectureRoomsResult> resultList = GetFinalResults(results, query); foreach (var rec in resultList) { if (!String.IsNullOrEmpty(rec.Number) && rec.Capacity.HasValue) { rec.RoomNumberWithCapacity = String.Format("{0}, Holds {1}", rec.Number, rec.Capacity.Value.ToString()); } else { rec.RoomNumberWithCapacity = rec.Number ?? ""; } } return resultList; }
/// <summary> /// simply check if username exists /// </summary> /// <param name="username"></param> public bool CheckAttendeeUsernameExists(string username) { var meta = new CodeCampDataContext(); bool userExists = (from data in meta.Attendees where data.Username.ToLower().Equals(username.ToLower()) select data).Any(); return userExists; }
/// <summary> /// simply check if email exists /// </summary> /// <param name="email"></param> public bool CheckAttendeeEmailExists(string email) { var meta = new CodeCampDataContext(); bool userExists = (from data in meta.Attendees where data.Email.ToLower().Equals(email.ToLower()) select data).Any(); return userExists; }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } public List<SponsorListJobListingResult> Get(SponsorListJobListingQuery query) { var meta = new CodeCampDataContext(); IQueryable<SponsorListJobListing> baseQuery = from myData in meta.SponsorListJobListing select myData; DateTime today = DateTime.UtcNow; //var result = meta.Meeting.Where(d => today >= start // && d.MeetingDate <= end); if (query.Top5ActiveListings.HasValue && query.Top5ActiveListings.Value) { baseQuery = baseQuery.Where( data => today >= data.StartRunDate && today <= data.EndRunDate && data.HideListing == false).Take(5); } if (query.Top5ForTesting.HasValue && query.Top5ForTesting.Value) { baseQuery = baseQuery.Where( data => data.HideListing == false) .OrderByDescending(a => a.StartRunDate) .Take(5); } // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); IQueryable<SponsorListJobListingResult> results = GetBaseResultIQueryable(baseQuery); List<SponsorListJobListingResult> resultList = GetFinalResults(results, query); foreach (var job in resultList) { job.JobDateFriendly = String.Format("{0:MM/dd/yy}", job.StartRunDate); } //var recs = from data in meta.SessionsJobListing // select data.SessionId // where // Put Stuff Here if you want to load another result // The following is done AFTER GetFinalResults so that we don't waste machine cycles sucking in all the // addresses for all results returned, just the ones that are actually being returned. // if (query.WithAddress != null && query.WithAddress == true) // { // foreach (var r in companyResultList) // { // r.CompanyAddressResultList = // CompanyAddressManager.I.Get(new CompanyAddressQuery { CompanyIds = query.Ids, WithAddress = true }); // } // } // return resultList; }
public List<string> GetUsernameListByCodeCampYearId(int codeCampYearId) { var meta = new CodeCampDataContext(); List<string> userNameList = (from data in meta.Attendees join attendeeccy in meta.AttendeesCodeCampYear on data.Id equals attendeeccy.AttendeesId where attendeeccy.CodeCampYearId == codeCampYearId select data.Username).ToList(); return userNameList; }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } //public List<SessionAttendeeResult> GetByAttendeePKIDCached(Guid userGuid,int codeCampYearId,int cacheTimeOutSeconds) //{ // string cacheName = "SessionAttendeeResult-GetByAttendeePKID-" + " codeCampYearId.ToString(); // var sessionAttendeeResults = HttpContext.Current.Cache[cacheName] as List<SessionAttendeeResult>; // if (sessionAttendeeResults == null) // { // HttpContext.Current.Cache.Insert(cacheName, numberRegistered ?? 0, // null, // DateTime.Now.Add(new TimeSpan(0, 0, cacheTimeOutSeconds)), // TimeSpan.Zero); // } // return sessionAttendeeResults; //} public List<SessionAttendeeResult> Get(SessionAttendeeQuery query) { var meta = new CodeCampDataContext(); IQueryable<SessionAttendee> baseQuery = from myData in meta.SessionAttendee select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery,query); if (query.Attendees_username != null) { baseQuery = baseQuery.Where(a => a.Attendees_username == query.Attendees_username.Value); } if (!String.IsNullOrEmpty(query.EventBoardEmail)) { // might be better to do this in one step var attendeeUsernamePKID = (from data in meta.Attendees where data.EmailEventBoard.Equals(query.EventBoardEmail) select data.PKID).FirstOrDefault(); baseQuery = baseQuery.Where(a => a.Attendees_username == attendeeUsernamePKID); } if (query.CodeCampYearId != null) { var sessionIds = from data in meta.Sessions where data.CodeCampYearId == query.CodeCampYearId.Value select data.Id; baseQuery = baseQuery.Where(a => sessionIds.Contains(a.Sessions_id)); } IQueryable<SessionAttendeeResult> results = GetBaseResultIQueryable(baseQuery); List<SessionAttendeeResult> resultList = GetFinalResults(results, query); // Put Stuff Here if you want to load another result // The following is done AFTER GetFinalResults so that we don't waste machine cycles sucking in all the // addresses for all results returned, just the ones that are actually being returned. // if (query.WithAddress != null && query.WithAddress == true) // { // foreach (var r in companyResultList) // { // r.CompanyAddressResultList = // CompanyAddressManager.I.Get(new CompanyAddressQuery { CompanyIds = query.Ids, WithAddress = true }); // } // } // return resultList; }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } public List<TagsResult> Get(TagsQuery query) { var meta = new CodeCampDataContext(); IQueryable<Tags> baseQuery = from myData in meta.Tags select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.CodeCampYearId.HasValue) { var tagsIds = meta.SessionTagsView.Where(data => data.CodeCampYearId == query.CodeCampYearId) .Select(data => data.TagId); baseQuery = baseQuery.Where(data => tagsIds.Contains(data.Id)); } List<int> tagIdsTagged = null; if (query.SessionId.HasValue) { tagIdsTagged = (from data in meta.SessionTags where data.SessionId == query.SessionId.Value && data.SessionId.HasValue select data.TagId).ToList(); } IQueryable<TagsResult> results = GetBaseResultIQueryable(baseQuery); List<TagsResult> resultList = GetFinalResults(results, query); // query.SessionId may be true but if not tags for session, this will not execute if (tagIdsTagged != null && tagIdsTagged.Count > 0) { foreach (var rec in resultList) { rec.TaggedInSession = tagIdsTagged.Contains(rec.Id); } } // mark sessionId in all records to make REST updates easier if (query.SessionId.HasValue) { foreach (var rec in resultList) { rec.SessionId = query.SessionId.Value; } } return resultList; }
public List<TwitterUpdateResult> Get(TwitterUpdateQuery query) { var meta = new CodeCampDataContext(); IQueryable<TwitterUpdate> baseQuery = from myData in meta.TwitterUpdate select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); IQueryable<TwitterUpdateResult> results = GetBaseResultIQueryable(baseQuery); List<TwitterUpdateResult> resultList = GetFinalResults(results, query); foreach (var r in resultList) { r.PrettyDateDifferenceFromNow = GetPrettyDate(r.Published.Value); } return resultList; }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } public List<SessionsResult> Get(SessionsQuery query) { var meta = new CodeCampDataContext(); IQueryable<Sessions> baseQuery = from myData in meta.Sessions select myData; baseQuery = BaseQueryAutoGen(baseQuery,query,false); IQueryable<SessionsResult> results = (from myData in baseQuery orderby myData.Id select new SessionsResult { Id= myData.Id, SessionLevel_id = myData.SessionLevel_id, Username = myData.Username, Title = myData.Title, Description = myData.Description, Approved = myData.Approved, Createdate = myData.Createdate == null ? null : (DateTime?) new DateTime(myData.Createdate.Value.Ticks,DateTimeKind.Utc), Updatedate = myData.Updatedate == null ? null : (DateTime?) new DateTime(myData.Updatedate.Value.Ticks,DateTimeKind.Utc), AdminComments = myData.AdminComments, InterentAccessRequired = myData.InterentAccessRequired, LectureRoomsId = myData.LectureRoomsId, SessionTimesId = myData.SessionTimesId }); List<SessionsResult> resultList = GetFinalResults(results, query); return resultList; }
public List<ReferringUrlResult> Get(ReferringUrlQuery query) { var meta = new CodeCampDataContext(); IQueryable<ReferringUrl> baseQuery = from myData in meta.ReferringUrl select myData; if (query.SkipAllInReferringUrlGroup != null) { // get list from group, then exclude from query var recs = (from data in meta.ReferringUrlGroup select data.ArticleName).Distinct(); baseQuery = baseQuery.Where(a => recs.Contains(a.ReferringUrlName)); } // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); IQueryable<ReferringUrlResult> results = GetBaseResultIQueryable(baseQuery); List<ReferringUrlResult> resultList = GetFinalResults(results, query); // Put Stuff Here if you want to load another result // The following is done AFTER GetFinalResults so that we don't waste machine cycles sucking in all the // addresses for all results returned, just the ones that are actually being returned. // if (query.WithAddress != null && query.WithAddress == true) // { // foreach (var r in companyResultList) // { // r.CompanyAddressResultList = // CompanyAddressManager.I.Get(new CompanyAddressQuery { CompanyIds = query.Ids, WithAddress = true }); // } // } // return resultList; }
public List<AttendeesResult> Get(AttendeesQuery query) { var meta = new CodeCampDataContext(); // add to codecampyearids (make sure List is always populated) if (query.CodeCampYearId.HasValue) { if (query.CodeCampYearIds != null && query.CodeCampYearIds.Count > 0) { if (!query.CodeCampYearIds.Contains(query.CodeCampYearId.Value)) { query.CodeCampYearIds.Add(query.CodeCampYearId.Value); } } else { query.CodeCampYearIds = new List<int> {query.CodeCampYearId.Value}; } } // query.CodeCampYearId should not be used for hear on out, just the array IQueryable<Attendees> baseQuery = from myData in meta.Attendees select myData; if (query.Emails != null && query.Emails.Count > 0) { baseQuery = baseQuery.Where(data => query.Emails.Contains(data.Email)); } if (!String.IsNullOrEmpty(query.SpeakerNameWithId)) { // looking for "Peter-Kellner-903" (all we really care about is Id at end which is third item. I can't think of any reason (at the moment) why this is bad // someone could get this url to work /hate-codecamp-903 but I don't really see the problem for code camp at any rate // I prefer not to check the first two words because there could be funny data in the old data that was not checked and I still // want the links to work. later we can fix it to check the first/last name if it is an issue. List<string> parts = query.SpeakerNameWithId.Split(new[] {'-'}).ToList(); if (parts.Count == 3) { int attendeeId; if (Int32.TryParse(parts[2], out attendeeId)) { baseQuery = baseQuery.Where(a => a.Id == attendeeId); } } } if (query.CodeCampYearIds != null && query.CodeCampYearIds.Count > 0) { if (query.PresentersOnly != null && query.PresentersOnly.Value) { var speakerIds = (from sessionPresenter in meta.SessionPresenter join session in meta.Sessions on sessionPresenter.SessionId equals session.Id where query.CodeCampYearIds.Contains(session.CodeCampYearId) select sessionPresenter.AttendeeId).ToList(); baseQuery = baseQuery.Where(data => speakerIds.Contains(data.Id)); } //else //{ // // this may blow up with two many attendees in contains (which translates to sql IN) // var speakerIds = (from data in meta.AttendeesCodeCampYear // where query.CodeCampYearIds.Contains(data.CodeCampYearId) // select data.AttendeesId).ToList(); // baseQuery = baseQuery.Where(data => speakerIds.Contains(data.Id)); //} } else { // if codecampyear not specified, thenw we need to deal with presentersonly separately if (query.PresentersOnly != null) { var presenterAttendeeIds = from data in meta.SessionPresenter select data.AttendeeId; baseQuery = baseQuery.Where(a => presenterAttendeeIds.Contains(a.Id)); } } // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.EmailContains != null) { baseQuery = baseQuery.Where(a => a.Email.Contains(query.EmailContains)); } if (query.AttendeesOnlyNoPresenters != null) { var presenterAttendeIds = from data in meta.SessionPresenter select data.AttendeeId; baseQuery = baseQuery.Where(a => !presenterAttendeIds.Contains(a.Id)); } IQueryable<AttendeesResult> results = GetBaseResultIQueryable(baseQuery); List<AttendeesResult> resultList = GetFinalResults(results, query); foreach (var rec in resultList) { rec.AttendeesId = rec.Id; } var sessionsBySpeakerdict = new Dictionary<int, List<SessionPresentResultSmall>>(); if (query.IncludeSessions.HasValue && query.IncludeSessions.Value) { IQueryable<SessionPresentResultSmall> sessionPresentResultSmalls = from sessionPresenter in meta.SessionPresenter join session in meta.Sessions on sessionPresenter.SessionId equals session.Id join roomdata in meta.LectureRooms on session.LectureRoomsId equals roomdata.Id join timedata in meta.SessionTimes on session.SessionTimesId equals timedata.Id select new SessionPresentResultSmall { SessionId = session.Id, CodeCampYearId = session.CodeCampYearId, AttendeeId = sessionPresenter.AttendeeId, PrimarySpeakerId = sessionPresenter.AttendeeId, // PROBLEM, THIS NOW PICKS FIRST AS PRIMARY, WILL BE WRONG 3/14/2013 DoNotShowPrimarySpeaker = session.DoNotShowPrimarySpeaker, Title = session.Title, TitleEllipsized = Utils.GetEllipsized(session.Title, 45, "..."), RoomNumber = roomdata.Number, SessionTime = timedata.StartTimeFriendly, Description = session.Description, DescriptionEllipsized = Utils.GetEllipsized(session.Description, 75, "..."), SessionUrl = String.Format("/Session/{0}/{1}", Utils.ConvertCodeCampYearToActualYear( session.CodeCampYearId.ToString(CultureInfo.InvariantCulture)), Utils.GenerateSlug(session.Title)), }; if (query.CodeCampYearIds != null && query.CodeCampYearIds.Count > 0) { sessionPresentResultSmalls = sessionPresentResultSmalls.Where(a => query.CodeCampYearIds.Contains(a.CodeCampYearId)); } foreach (var rec in sessionPresentResultSmalls) { if (!sessionsBySpeakerdict.ContainsKey(rec.AttendeeId)) { // no speakers in session dictionary so add it from scarch sessionsBySpeakerdict.Add(rec.AttendeeId, new List<SessionPresentResultSmall> { rec }); } else { // add one more speaker to this session List<SessionPresentResultSmall> sessionPresentResultSmallsTemp = sessionsBySpeakerdict[rec.AttendeeId]; sessionPresentResultSmallsTemp.Add(rec); sessionsBySpeakerdict[rec.AttendeeId] = sessionPresentResultSmallsTemp; } } } if (query.IncludeSessions.HasValue && query.IncludeSessions.Value) { foreach (var attendee in resultList) { attendee.SessionIds = new List<int>(); attendee.Sessions = new List<SessionPresentResultSmall>(); List<SessionPresentResultSmall> sessionPresentResultSmallsTemp = sessionsBySpeakerdict[attendee.Id]; if (sessionPresentResultSmallsTemp != null && sessionPresentResultSmallsTemp.Count > 0) { // check and see if this person owns the session AND there name is to be supressed var sessionPresentResultSmallsFiltered = new List<SessionPresentResultSmall>(); foreach (var recc in sessionPresentResultSmallsTemp) { bool supressSpeaker = recc.DoNotShowPrimarySpeaker && recc.PrimarySpeakerId == recc.AttendeeId; if (!supressSpeaker) { sessionPresentResultSmallsFiltered.Add(recc); } } attendee.SessionIds = sessionPresentResultSmallsTemp.Select(a => a.SessionId).ToList(); attendee.Sessions = sessionPresentResultSmallsTemp.ToList(); } } } // blank out info not to be shown if (query.RespectQRCodes != null && query.RespectQRCodes.Value) { foreach (var rec in resultList) { rec.SpeakerPictureUrl = String.Format("http://www.siliconvalley-codecamp.com/DisplayImage.ashx?PKID={0}", rec.PKID); if (!(rec.QRAddressLine1Allow != null && rec.QRAddressLine1Allow.Value)) { rec.AddressLine1 = string.Empty; } if (!(rec.QREmailAllow != null && rec.QREmailAllow.Value)) { rec.Email = string.Empty; } if (!(rec.QRPhoneAllow != null && rec.QRPhoneAllow.Value)) { rec.PhoneNumber = string.Empty; } if (!(rec.QRWebSiteAllow != null && rec.QRWebSiteAllow.Value)) { rec.UserWebsite = string.Empty; } if (!(rec.QRZipCodeAllow != null && rec.QRZipCodeAllow.Value)) { rec.UserZipCode = string.Empty; } else { // Grab up city state from zip rec.City = "CityToSet"; rec.State = "StateToSet"; } } } // only pull AttendeesCodeCampYearData when current code camp year and attendeeId (Id) is specified. // otherwise, quietly ignore. if (query.CodeCampYearId.HasValue && query.IncludeAttendeesCodeCampYearResult.HasValue && query.IncludeAttendeesCodeCampYearResult.Value) { List<int> attendeeIds = resultList.Select(a => a.Id).ToList(); Dictionary<int, AttendeesCodeCampYearResult> codeCampYearResults = meta.AttendeesCodeCampYear.Where( data => attendeeIds.Contains(data.Id) && data.CodeCampYearId == query.CodeCampYearId).Select(a => new AttendeesCodeCampYearResult { Id = a.Id, AttendeesId = a.AttendeesId, AttendSaturday = a.AttendSaturday, AttendSunday = a.AttendSunday, CodeCampYearId = a.CodeCampYearId, Volunteer = a.Volunteer, CreateDate = a.CreateDate }) .ToDictionary( k => k.AttendeesId, v => v); foreach (var rec in resultList) { if (codeCampYearResults.ContainsKey(rec.Id)) { rec.AttendeesCodeCampYearResult = codeCampYearResults[rec.Id]; } } } // need to fill out base record for all current stuff about code camp attendee this year //public bool RegisteredCurrentYear { get; set; } //public bool HasSessionsCurrentYear { get; set; } //public string AttendingDaysChoiceCurrentYear { get; set; } //public bool VolunteeredCurrentYear { get; set; } if (query.CodeCampYearId.HasValue && query.IncludeAttendeesCodeCampYearResult.HasValue && query.IncludeAttendeesCodeCampYearResult.Value) { // avoid to big IN clauses Dictionary<int, AttendeesCodeCampYear> attendeesCodeCampYearResultsDict; List<int> attendeeIdsThatArePresentersThisYear; if (resultList.Count < 100) { List<int> attendeeIds = resultList.Select(a => a.Id).ToList(); attendeesCodeCampYearResultsDict = (from data in meta.AttendeesCodeCampYear where attendeeIds.Contains(data.AttendeesId) && data.CodeCampYearId == query.CodeCampYearId.Value select data).ToDictionary(k => k.AttendeesId, v => v); attendeeIdsThatArePresentersThisYear = (from attendee in meta.Attendees join sessionPresenter in meta.SessionPresenter on attendee.Id equals sessionPresenter.AttendeeId where attendeeIds.Contains(attendee.Id) select attendee.Id).ToList(); } else { attendeesCodeCampYearResultsDict = (from data in meta.AttendeesCodeCampYear where data.CodeCampYearId == query.CodeCampYearId.Value select data).ToDictionary(k => k.AttendeesId, v => v); attendeeIdsThatArePresentersThisYear = (from attendee in meta.Attendees join sessionPresenter in meta.SessionPresenter on attendee.Id equals sessionPresenter.AttendeeId join session in meta.Sessions on sessionPresenter.SessionId equals session.Id where session.CodeCampYearId == query.CodeCampYearId select attendee.Id).ToList(); } foreach (var attendee in resultList) { if (attendeesCodeCampYearResultsDict.ContainsKey(attendee.Id)) { var attendeeCodeCampYear = attendeesCodeCampYearResultsDict[attendee.Id]; attendee.AttendingDaysChoiceCurrentYear = attendeeCodeCampYear.AttendingDaysChoice; attendee.HasSessionsCurrentYear = attendeeIdsThatArePresentersThisYear.Contains(attendee.Id); attendee.RegisteredCurrentYear = attendeesCodeCampYearResultsDict.ContainsKey(attendee.Id); attendee.VolunteeredCurrentYear = attendeesCodeCampYearResultsDict.ContainsKey(attendee.Id) && attendeesCodeCampYearResultsDict[attendee.Id].Volunteer .HasValue && attendeesCodeCampYearResultsDict[attendee.Id].Volunteer.Value; } } } return resultList; }
public List<SponsorListResult> Get(SponsorListQuery query) { var meta = new CodeCampDataContext(); IQueryable<SponsorList> baseQuery = from myData in meta.SponsorList select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.CodeCampYearId.HasValue) { if (query.Visible.HasValue && query.Visible.Value) { var rr = from data in meta.SponsorListCodeCampYear where data.CodeCampYearId == query.CodeCampYearId.Value && data.Visible select data.SponsorListId; baseQuery = baseQuery.Where(a => rr.Contains(a.Id)); } else { var rr = from data in meta.SponsorListCodeCampYear where data.CodeCampYearId == query.CodeCampYearId.Value select data.SponsorListId; baseQuery = baseQuery.Where(a => rr.Contains(a.Id)); } } IQueryable<SponsorListResult> results = GetBaseResultIQueryable(baseQuery); List<SponsorListResult> resultList = GetFinalResults(results, query); List<SponsorListCodeCampYearResult> sponsorListCodeCampYearResults = null; if (query.WithCodeCampYears != null && query.WithCodeCampYears.Value && query.PlatinumLevel.HasValue && query.SilverLevel.HasValue && query.GoldLevel.HasValue && query.BronzeLevel.HasValue) { var sponsorListCodeCampYearQuery = new SponsorListCodeCampYearQuery(); if (query.CodeCampYearId != null) { sponsorListCodeCampYearQuery.CodeCampYearId = query.CodeCampYearId; } sponsorListCodeCampYearResults = SponsorListCodeCampYearManager.I.Get(sponsorListCodeCampYearQuery); } List<SponsorListContactResult> sponsorListContactResults = new List<SponsorListContactResult>(); if (query.WithContacts != null && query.WithContacts.Value) { sponsorListContactResults = SponsorListContactManager.I.Get(new SponsorListContactQuery() { }); } List<SponsorListNoteResult> sponsorListNoteResults = new List<SponsorListNoteResult>(); if (query.WithNotes != null && query.WithNotes.Value) { sponsorListNoteResults = SponsorListNoteManager.I.Get(new SponsorListNoteQuery() { }); } var sponsorListJobListingResults = new List<SponsorListJobListingResult>(); if (query.WithJobListings != null && query.WithJobListings.Value) { sponsorListJobListingResults = SponsorListJobListingManager.I.Get(new SponsorListJobListingQuery() { }); } if (resultList != null) { double platinum = 0; double gold = 0; double silver = 0; double bronze = 0; // this only works if a year is specified var sponsorLevelDictionary = new Dictionary<int, double>(); if (query.IncludeSponsorLevel.HasValue && query.IncludeSponsorLevel.Value && query.CodeCampYearId.HasValue && query.PlatinumLevel.HasValue && query.SilverLevel.HasValue && query.GoldLevel.HasValue && query.BronzeLevel.HasValue) { platinum = Convert.ToDouble(query.PlatinumLevel); gold = Convert.ToDouble(query.GoldLevel); silver = Convert.ToDouble(query.SilverLevel); bronze = Convert.ToDouble(query.BronzeLevel); var recs = (from data in meta.SponsorListCodeCampYear where data.CodeCampYearId == query.CodeCampYearId.Value select data).ToList(); foreach (var sponsorListCodeCampYear in recs) { // need to figure out why we have dupes and fix if (!sponsorLevelDictionary.ContainsKey(sponsorListCodeCampYear.SponsorListId)) { sponsorLevelDictionary.Add(sponsorListCodeCampYear.SponsorListId,sponsorListCodeCampYear.DonationAmount); } } } foreach (var rec in resultList) { rec.ImageURL = String.Format("/sponsorimage/{0}.jpg", rec.Id); if (query.IncludeSponsorLevel.HasValue && query.IncludeSponsorLevel.Value && query.CodeCampYearId.HasValue && query.PlatinumLevel.HasValue && query.SilverLevel.HasValue && query.GoldLevel.HasValue && query.BronzeLevel.HasValue) { if (sponsorLevelDictionary.ContainsKey(rec.Id)) { double dollarAmount = sponsorLevelDictionary[rec.Id]; if (dollarAmount >= platinum) { rec.SponsorSupportLevel = "Platinum"; rec.SponsorSupportLevelOrder = 0; } else if (dollarAmount >= gold) { rec.SponsorSupportLevel = "Gold"; rec.SponsorSupportLevelOrder = 1; } else if (dollarAmount >= silver) { rec.SponsorSupportLevel = "Silver"; rec.SponsorSupportLevelOrder = 2; } else if (dollarAmount >= bronze) { rec.SponsorSupportLevel = "Bronze"; rec.SponsorSupportLevelOrder = 3; } else if (Math.Abs(dollarAmount - 0.0) < .01) { rec.SponsorSupportLevel = "Community"; rec.SponsorSupportLevelOrder = 4; } else { rec.SponsorSupportLevel = "Unknown"; rec.SponsorSupportLevelOrder = 999; } } } if (sponsorListCodeCampYearResults != null) { rec.SponsorListCodeCampYearResults = sponsorListCodeCampYearResults.Where(a => a.SponsorListId == rec.Id).ToList(); } // this is fast if withNotes false rec.SponsorListNoteResults = sponsorListNoteResults.Where(a => a.SponsorListId == rec.Id).ToList(); // this is fast if withContact is false rec.SponsorListContactResults = sponsorListContactResults.Where(a => a.SponsorListId == rec.Id).ToList(); // this is fast if withJobListing is false rec.SponsorListJobListingResults = sponsorListJobListingResults.Where(a => a.SponsorListId == rec.Id).ToList(); } } return resultList; }
public List<CodeCampYearResult> Get(CodeCampYearQuery query) { var meta = new CodeCampDataContext(); IQueryable<CodeCampYear> baseQuery = from myData in meta.CodeCampYear select myData; // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.OnlyYearsWithSessions != null && query.OnlyYearsWithSessions.Value) { var codeCampYearsWithSessions = (from data in meta.Sessions select data.CodeCampYearId).Distinct().ToList(); baseQuery = baseQuery.Where(a => codeCampYearsWithSessions.Contains(a.Id)); } IQueryable<CodeCampYearResult> results = GetBaseResultIQueryable(baseQuery); List<CodeCampYearResult> resultList = GetFinalResults(results, query); if (query.WithSessionDetail != null && query.WithSessionDetail.Value) { // could optimize this based on what years are selected var codeCampYearIds = results.Select(a => a.Id).ToList(); var sessionResults = SessionsManager.I.Get(new SessionsQuery { CodeCampYearIds = codeCampYearIds, WithTags = query.WithTags, WithEvaluations = query.WithEvaluations, WithLectureRoom = query.WithLectureRoom, WithLevel = query.WithLevel, WithSchedule = query.WithSchedule, WithSpeakers = query.WithSpeakers }); foreach (var rec in resultList) { rec.SessionResults = sessionResults.Where(data => data.CodeCampYearId == rec.Id).ToList(); } } //if (query.WithSpeakers != null && query.WithSpeakers.Value) //{ // // could optimize this based on what years are selected // var codeCampYearIds = results.Select(a => a.Id).ToList(); // var attendeesResults = AttendeesManager.I.Get(new AttendeesQuery // { // CodeCampYearIds = codeCampYearIds, // PresentersOnly = true // }); // foreach (var rec in resultList) // { // rec.SpeakerResults = attendeesResults.Where(data => data.Id == rec.Id).ToList(); // } //} //if (query.WithSchedule != null && query.WithSchedule.Value) //{ // //// could optimize this based on what years are selected // //var codeCampYearIds = results.Select(a => a.Id).ToList(); // //var sessionResults = SessionsManager.I.Get(new SessionsQuery // //{ // // CodeCampYearIds = codeCampYearIds, // // WithTags = true // //}); // //foreach (var rec in resultList) // //{ // // rec.SessionResults = sessionResults.Where(data => data.CodeCampYearId == rec.Id).ToList(); // //} //} return resultList; }
/// <summary> /// output html /// </summary> /// <param name="sessionIds"></param> private void ShowAllSessionsWithBasicHtml(CodeCampDataContext codeCampDataContext, List<int> sessionIds) { var sb = new StringBuilder(); var sessions = from data in codeCampDataContext.Sessions where sessionIds.Contains(data.Id) select data; List<int> sessionIdList = (from data in sessions select data.Id).ToList(); // grab all tags for speed List<Tags> allTags = (codeCampDataContext.Tags).ToList(); List<CodeCampSV.SessionTags> allSessionTags = (from mydata in codeCampDataContext.SessionTags where sessionIdList.Contains(mydata.SessionId.Value) select mydata).ToList(); //int cnt = sessions.Count(); sb.Append("<div class=\"pad\">"); foreach (var session in sessions) { sb.AppendLine(String.Format("<h2 class=\"CC_SessionTitle\">{0}</h2>", session.Title)); sb.AppendLine(String.Format("<h4 class=\"CC_SessionStartTime\">{0}</h2>", GetSessionTimeFromSessionTimeId(session.SessionTimesId))); sb.AppendLine(String.Format("<h4 class=\"CC_SessionRoom\">{0}</h2>", GetRoomNameFromLectureRoomId(session.LectureRoomsId))); sb.AppendLine(String.Format("<h4 class=\"CC_SessionTrackName\">{0}</h2>", GetSessionTrackNameFromId(session.Id))); // <a href="https://codecamp.pbworks.com/newpage.php?show_suggestions&page_name=BeyondtheRelayRoutersandQueuesintheNETServiceBus-2009">Wiki Here</a> sb.AppendLine(String.Format( "<h4 class=\"CC_WikiAddress\"><a href=\"ViewWikiPage?SessionId={0}\">Wiki Here</a></h2>", session.Id)); sb.AppendLine(String.Format("<br/><h3><a href=\"Speakers.aspx?id={0}\">Presenter(s)</a></h3>", session.Id)); sb.AppendLine("<ul class=\"CC_SessionPresenters\">"); foreach (var attendeeSpeaker in GetSessionPresenters(codeCampDataContext, session.Id)) { // <a href="Speakers.aspx?id=157">Juval Lowy</a></ sb.AppendLine(String.Format(" <li><a href=\"Speakers.aspx?AttendeeId={2}\">{0} {1}</a></li>", attendeeSpeaker.UserFirstName, attendeeSpeaker.UserLastName, attendeeSpeaker.Id)); } sb.AppendLine("</ul>"); sb.AppendLine("<br/><h3>Session Tags</h3"); sb.AppendLine("<ul class=\"CC_Tags\">"); int iCnt = 0; foreach (var tag in GetSessionTags(allSessionTags, allTags, session.Id)) { iCnt++; // <a href="Sessions.aspx?sortby=title&by=category&tag=44">Architecture</a> sb.AppendLine( String.Format( " <li><a href=\"Sessions.aspx?sortby=title&by=category&tag={0}\">{1}</a></li>", tag.Id, tag.TagName)); if (iCnt > 7) { break; } } sb.AppendLine("</ul>"); sb.AppendLine("<br/><h3>Session Details</h3"); sb.AppendLine(String.Format("<h4 class=\"CC_SessionDetails\">{0}</h2>", CheckForValidHTML(session.Description))); // CheckForValidHTML sb.AppendLine("<br/><h3>Session Interest Levels</h3"); sb.AppendLine(String.Format("<span class=\"CC_InterestLevelRadioButtons\">")); sb.AppendLine( String.Format( " <input class=\"CC_InterestLevelNotInterested\" NAME=\"SILRB{0}\" type=\"radio\">{1}</input>", session.Id, "Not Interested")); sb.AppendLine( String.Format( " <input class=\"CC_InterestLevelInterested\" NAME=\"SILRB{0}\" type=\"radio\">{1}</input> ", session.Id, GetInterestedText(session.Id))); sb.AppendLine( String.Format( " <input class=\"CC_InterestLevelPlanToAttend\" NAME=\"SILRB{0}\" type=\"radio\">{1}</input>", session.Id, GetWillAttendText(session.Id))); sb.AppendLine(String.Format("</span>")); sb.AppendLine("<hr/><br/>"); //break; } sb.AppendLine("</div>"); HtmlForSessionsId.Text = sb.ToString(); }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } public void Upsert(AttendeesCodeCampYearResult result) { var meta = new CodeCampDataContext(); var attendeesCodeCampYear = (from data in meta.AttendeesCodeCampYear where data.CodeCampYearId == result.CodeCampYearId && data.AttendeesId == result.AttendeesId select data).SingleOrDefault(); if (attendeesCodeCampYear != null) { attendeesCodeCampYear.AttendSaturday = result.AttendSaturday; attendeesCodeCampYear.AttendSunday = result.AttendSunday; } else { attendeesCodeCampYear = new AttendeesCodeCampYear() { AttendeesId = result.AttendeesId, CodeCampYearId = result.CodeCampYearId, AttendSaturday = result.AttendSaturday, AttendSunday = result.AttendSunday }; meta.AttendeesCodeCampYear.InsertOnSubmit(attendeesCodeCampYear); } meta.SubmitChanges(); }
public void UpdateSponsorSimple1(SponsorListCodeCampYearResult sponsorListCodeCampYearResult) { var meta = new CodeCampDataContext(); var rec = (from data in meta.SponsorListCodeCampYear where data.Id == sponsorListCodeCampYearResult.Id select data).First(); if (rec != null) { rec.TableRequired = sponsorListCodeCampYearResult.TableRequired; rec.AttendeeBagItem = sponsorListCodeCampYearResult.AttendeeBagItem; rec.ItemSentToFoothill = sponsorListCodeCampYearResult.ItemSentToFoothill; rec.ItemsShippingDescription = sponsorListCodeCampYearResult.ItemsShippingDescription; rec.NoteFromCodeCamp = sponsorListCodeCampYearResult.NoteFromCodeCamp; rec.Comments = sponsorListCodeCampYearResult.Comments; meta.SubmitChanges(); } }
public List<SessionPresenterResult> Get(SessionPresenterQuery query) { var meta = new CodeCampDataContext(); // add to codecampyearids if (query.CodeCampYearId.HasValue) { if (query.CodeCampYearIds != null && query.CodeCampYearIds.Count > 0) { if (!query.CodeCampYearIds.Contains(query.CodeCampYearId.Value)) { query.CodeCampYearIds.Add(query.CodeCampYearId.Value); } } else { query.CodeCampYearIds = new List<int> { query.CodeCampYearId.Value }; } } IQueryable<SessionPresenter> baseQuery = from myData in meta.SessionPresenter select myData; if (query.CodeCampYearIds != null && query.CodeCampYearIds.Count > 0) { // sessionpresenter Ids for this year codecamp var sessionPresenterIds = (from data in meta.SessionPresenter join data1 in meta.Sessions on data.SessionId equals data1.Id where query.CodeCampYearIds.Contains(data1.CodeCampYearId) select data.Id).ToList(); baseQuery = baseQuery.Where(data => sessionPresenterIds.Contains(data.Id)); } // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); IQueryable<SessionPresenterResult> results = GetBaseResultIQueryable(baseQuery); List<SessionPresenterResult> resultList = GetFinalResults(results, query); if (query.WithTitle.HasValue && query.WithTitle.Value) { var sessions = (from data in meta.Sessions where resultList.Select(a => a.SessionId).Contains(data.Id) select data); foreach (var sessionPresenter in resultList) { var session = sessions.FirstOrDefault(a => a.Id == sessionPresenter.SessionId); if (session != null) { sessionPresenter.Title = session.Title; sessionPresenter.Description = session.Description; } } } if (query.WithSpeaker.HasValue && query.WithSpeaker.Value) { var speakerDict = (AttendeesManager.I.Get(new AttendeesQuery() { Ids = results.Select(a => a.AttendeeId).ToList() })).ToDictionary(k => k.Id, v => v); foreach (var result in results) { result.Presenter = speakerDict.ContainsKey(result.AttendeeId) ? speakerDict[result.AttendeeId] : new AttendeesResult(); } } return resultList; }
protected void Page_Load(object sender, EventArgs e) { RadioButtonSatSunPressed = false; RadioButtonTimesListPressed = false; SearchButtonPressed = false; //_sessionJobListingDictionary = Utils.GetSessionsJobListingDictionary(Utils.GetCurrentCodeCampYear(),true); _sessionSponsorListDictionary = Utils.GetSessionJobDictionary(Utils.GetCurrentCodeCampYear(), true); // _sessionListPbWikiShow = Utils.GetSessionListPbWikiShow(Utils.GetCurrentCodeCampYear(), true); // these are cached _boxFolderIdDictionary = Utils.GetBoxFolderIdsBySessionDict(Utils.GetCurrentCodeCampYear()); _materialsDictionary = Utils.GetMaterialsUrlBySessionDict(Utils.GetCurrentCodeCampYear()); if (!IsPostBack) { if ((ConfigurationManager.AppSettings["ShowVideoOnSessionIfExists"] != null && ConfigurationManager.AppSettings["ShowVideoOnSessionIfExists"].ToLower().Equals("true")) || Utils.CheckUserIsAdmin() || Utils.CheckUserIsVideoEditor()) { CheckBoxJustSessionsWithVideo.Visible = true; } RegisteredForCurrentYear = Utils.IsRegisteredForCurrentCodeCampYear(Context.User.Identity.Name, Utils.CurrentCodeCampYear); } if (Request.QueryString["Search"] != null && !IsPostBack) { SearchText = Request.QueryString["Search"]; SearchButtonPressed = true; TextBox1.Text = SearchText; SearchButtonCode(SearchText); } else { SearchText = string.Empty; } if (ConfigurationManager.AppSettings["SessionsPageUsingExtJS"] != null && ConfigurationManager.AppSettings["SessionsPageUsingExtJS"].ToLower().Equals("true")) { using (var codeCampDataContext = new CodeCampDataContext()) { List<int> sessionIds = GetListOfSessionsBasedOnQueryParams(codeCampDataContext); ShowAllSessionsWithBasicHtml(codeCampDataContext, sessionIds); } } else { if (Utils.CheckUserIsScheduler() || Utils.CheckUserIsAdmin()) { CheckBoxShowOnlyAssigned.Visible = true; } else { CheckBoxShowOnlyAssigned.Visible = false; } // always get this because if person logs out, it goes away _listSessionAttendees = new SessionAttendeeODS().GetByUsername(Context.User.Identity.Name); //FormsAuthentication.SetAuthCookie("pkellner",true); if (!IsPostBack) { //RadioButtonSatSunPressed = true; // on first time, force prerender event to fire //RadioButtonTimesListPressed = true; if (ConfigurationManager.AppSettings["ShowAgendaOnSchedule"] != null && ConfigurationManager.AppSettings["ShowAgendaOnSchedule"].ToLower().Equals("true")) { RadioButtonSatOrSundayList.Visible = true; // start out showing sat/sun choice RadioButtonListTimes.Visible = true; } else { RadioButtonSatOrSundayList.Visible = false; RadioButtonListTimes.Visible = false; } if (Request.QueryString["track"] != null) { IdSortBy.Visible = false; IdTrackDescription.Visible = true; // Get Track Description var recs = TrackManager.I.Get(new TrackQuery {Id = Convert.ToInt32(Request.QueryString["track"])}); if (recs != null && recs.Count > 0) { LiteralTitle.Text = String.Format("{0} Track Sessions", recs[0].Named); LiteralTrackDescription.Text = recs[0].Description; } } else { if (ConfigurationManager.AppSettings["SessionsPageUsingExtJS"] == null || !ConfigurationManager.AppSettings["SessionsPageUsingExtJS"].ToLower().Equals("true")) { IdSortBy.Visible = true; IdTrackDescription.Visible = false; LiteralTitle.Text = "Sessions"; } } // Get List of Tracks sorted by const string cacheSessionsTrackSessionsResults = "CacheSessionsTrackSessionResults"; TrackSessionResults = (List<TrackSessionResult>) HttpContext.Current.Cache[cacheSessionsTrackSessionsResults]; if (TrackSessionResults == null) { TrackSessionResults = (from mydata in TrackSessionManager.I.GetAll() select mydata).ToList(); HttpContext.Current.Cache.Insert(cacheSessionsTrackSessionsResults, TrackSessionResults, null, DateTime.Now.Add(new TimeSpan(0, 0, Utils .RetrieveSecondsForSessionCacheTimeout ())), TimeSpan.Zero); } // Get List of Tracks sorted by Name string cacheSessionsTrackResults = String.Format("CacheSessionsTrackResults-{0}", Utils.GetCurrentCodeCampYear()); TrackResults = (List<TrackResult>) HttpContext.Current.Cache[cacheSessionsTrackResults]; if (TrackResults == null) { TrackResults = (from mydata in TrackManager.I.Get(new TrackQuery() { CodeCampYearId = Utils.GetCurrentCodeCampYear(), Visible = true }) where mydata.Named != null orderby mydata.Named.ToLower() select mydata).ToList(); HttpContext.Current.Cache.Insert(cacheSessionsTrackResults, TrackResults, null, DateTime.Now.Add(new TimeSpan(0, 0, Utils. RetrieveSecondsForSessionCacheTimeout ())), TimeSpan.Zero); } var trackNamesByIdDictionary = TrackResults.ToDictionary(trackResult => trackResult.Id, trackResult => trackResult.Named); TrackNameAssignedToSession = new Dictionary<int, string>(); foreach (var trackSessionResult in TrackSessionResults) { // this takes care of Visible problem from track above if (trackNamesByIdDictionary.ContainsKey(trackSessionResult.TrackId)) { TrackNameAssignedToSession.Add(trackSessionResult.SessionId, trackNamesByIdDictionary[trackSessionResult.TrackId]); } } //<asp:ListItem Value="Time">Session Time</asp:ListItem> // <asp:ListItem Value="Speaker">Session Speaker</asp:ListItem> // <asp:ListItem Value="Title">Session Title</asp:ListItem> // <asp:ListItem Value="Submitted">Session Submission</asp:ListItem> DropDownListSessionSortBy.Items.Add(new ListItem("Session Speaker", "Speaker")); DropDownListSessionSortBy.Items.Add(new ListItem("Session Title", "Title")); DropDownListSessionSortBy.Items.Add(new ListItem("Session Submission", "Submitted")); DropDownListSessionSortBy.Items[2].Selected = true; bool showingTimes = false; if (ConfigurationManager.AppSettings["ShowAgendaOnSchedule"].ToLower().Equals("true") || Utils.CheckUserIsScheduler() || Utils.CheckUserIsAdmin()) { DropDownListSessionSortBy.Items.Add(new ListItem("Session Time", "Time")); showingTimes = true; } // if sortby is title, then need to force it here because of tags if (Request.QueryString["sortby"] != null && Request.QueryString["sortby"].Equals("title")) { DropDownListSessionSortBy.SelectedIndex = DropDownListSessionSortBy.Items.IndexOf (DropDownListSessionSortBy.Items.FindByValue("Title")); } if (Context.User.Identity.IsAuthenticated) { if (showingTimes) { DropDownListSessionSortBy.SelectedIndex = DropDownListSessionSortBy.Items.IndexOf (DropDownListSessionSortBy.Items.FindByValue("Time")); } CheckBoxShowOnlyAssigned.Checked = Utils.GetProfileDataBool(Utils.ProfileDataShowOnlyAssignedSessions, false); } else { // If not authenticated, make default sort title // make default title DropDownListSessionSortBy.SelectedIndex = DropDownListSessionSortBy.Items.IndexOf (DropDownListSessionSortBy.Items.FindByValue("Title")); } if (Request.QueryString["ForceSortBySessionTime"] != null && Request.QueryString["ForceSortBySessionTime"].ToLower().Equals("true")) { Repeater1.DataSourceID = "ObjectDataSourceSessions"; DropDownListSessionSortBy.SelectedIndex = DropDownListSessionSortBy.Items.IndexOf (DropDownListSessionSortBy.Items.FindByValue("Time")); } } // need this to be default 2 because if choose 2, it will be no postback // and the default needs to be by title Repeater1.DataSourceID = "ObjectDataSourceBySessionTitle"; // get checkbox states if (Context.User.Identity.IsAuthenticated) { if (CheckBoxShowOnlyAssigned.Checked) { Repeater1.DataSourceID = "ObjectDataSourceSessionsOnlyAssigned"; } else { Repeater1.DataSourceID = "ObjectDataSourceSessions"; } // Need to set the correct object for retrieveal if (DropDownListSessionSortBy.SelectedValue.Equals("Time")) { //if (CheckBoxShowOnlyAssigned.Checked) //{ // Repeater1.DataSourceID = "ObjectDataSourceSessionsOnlyAssigned"; //} //else //{ Repeater1.DataSourceID = "ObjectDataSourceSessions"; //} } else if (DropDownListSessionSortBy.SelectedValue.Equals("Speaker")) { Repeater1.DataSourceID = "ObjectDataSourceBySessionPresenter"; } else if (DropDownListSessionSortBy.SelectedValue.Equals("Title")) { Repeater1.DataSourceID = "ObjectDataSourceBySessionTitle"; } else if (DropDownListSessionSortBy.SelectedValue.Equals("Submitted")) { Repeater1.DataSourceID = "ObjectDataSourceSessionSubmitted"; //ObjectDataSourceSessionSubmitted.FilterExpression = "Id = 540"; } } ObjectDataSourceSessionSubmitted.FilterExpression = ""; // get from Cache on load se we can use in page DropDownListLevels.DataBind(); SessionLevelsDictionary = new Dictionary<int, string>(DropDownListLevels.Items.Count); foreach (ListItem listItem in DropDownListLevels.Items) { SessionLevelsDictionary.Add(Convert.ToInt32(listItem.Value), listItem.Text); } // else if's protect the "id" below if (Request.QueryString["by"] != null && Request.QueryString["tag"] != null) { RadioButtonSatOrSundayList.Visible = false; // hide sat/sun choice if not doing full list RadioButtonListTimes.Visible = false; Repeater1.DataSourceID = "ObjectDataSourceByTag"; } else if (Request.QueryString["track"] != null) { RadioButtonSatOrSundayList.Visible = false; // hide sat/sun choice if not doing full list RadioButtonListTimes.Visible = false; Repeater1.DataSourceID = "ObjectDataSourceByTrack"; } else if (Request.QueryString["sessionid"] != null) { RadioButtonSatOrSundayList.Visible = false; // hide sat/sun choice if not doing full list RadioButtonListTimes.Visible = false; int outInt = 0; string str = Request.QueryString["sessionid"]; bool good = Int32.TryParse(str, out outInt); if (!good) { Response.Redirect("~/Sessions.aspx"); } Repeater1.DataSourceID = "ObjectDataSourceBySessionIdOnly"; } else if (Request.QueryString["id"] != null) { RadioButtonSatOrSundayList.Visible = false; // hide sat/sun choice if not doing full list RadioButtonListTimes.Visible = false; int outInt = 0; string str = Request.QueryString["id"]; bool good = Int32.TryParse(str, out outInt); if (!good) { Response.Redirect("~/Sessions.aspx"); } // if OnlyOne is in the URL as a request param, then don't get all sessions, just one. Repeater1.DataSourceID = Request.QueryString["OnlyOne"] == null ? "ObjectDataSourceGetSessionsBySession" : "ObjectDataSourceBySessionId"; } else if (Request.QueryString["PKID"] != null) { RadioButtonSatOrSundayList.Visible = false; // hide sat/sun choice if not doing full list RadioButtonListTimes.Visible = false; string guidString = Request.QueryString["PKID"]; string username = Utils.GetAttendeeUsernameByGUID(guidString); if (!String.IsNullOrEmpty(username)) { if (!Utils.GetIgnoreAutoSignOnGuid(username)) { if (!string.IsNullOrEmpty(username)) { if (User.Identity.IsAuthenticated) { FormsAuthentication.SignOut(); } FormsAuthentication.SetAuthCookie(username, true); Response.Redirect("~/Sessions.aspx", true); } } } } else if (Request.QueryString["AttendeeId"] != null) { RadioButtonSatOrSundayList.Visible = false; // hide sat/sun choice if not doing full list RadioButtonListTimes.Visible = false; Repeater1.DataSourceID = "ObjectDataSourceGetSessionsByAttendeeId"; } } }
public List<SponsorListCodeCampYearResult> Get(SponsorListCodeCampYearQuery query) { var meta = new CodeCampDataContext(); //Dictinary<int, string> sponsorNameById = (from data in meta.SponsorList // select data).ToDictionary(k => k.Id, v => v.SponsorName); //Dictinary<int, string> sponsorCommentById = (from data in meta.SponsorList // select data).ToDictionary(k => k.Id, v => v.Comment); IQueryable<SponsorListCodeCampYear> baseQuery = from myData in meta.SponsorListCodeCampYear select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.DonationAmtMin != null) { baseQuery = baseQuery.Where(a => a.DonationAmount >= query.DonationAmtMin.Value); } if (query.DonationAmtMax != null) { baseQuery = baseQuery.Where(a => a.DonationAmount <= query.DonationAmtMax.Value); } IQueryable<SponsorListCodeCampYearResult> results = GetBaseResultIQueryable(baseQuery); List<SponsorListCodeCampYearResult> resultList = GetFinalResults(results, query); var recs = (from data in meta.SponsorList select data).ToList(); foreach (var rec in resultList) { rec.CurrentCodeCampYearId = Convert.ToInt32(ConfigurationManager.AppSettings["CurrentCodeCampYearId"] ?? "0"); rec.SponsorName = recs.Where(a => a.Id == rec.SponsorListId).Select(a => a.SponsorName).FirstOrDefault(); } //List<SponsorListCodeCampYearNoteResult> sponsorListCodeCampYearNoteResults = null; //if (query.WithNotes != null && query.WithNotes.Value) //{ // var sponsorListCodeCampYearNoteQuery = // new SponsorListCodeCampYearNoteQuery(); // if (query.CodeCampYearId != null) // { // sponsorListCodeCampYearNoteQuery.SponsorListCodeCampYearId = query.CodeCampYearId; // } // sponsorListCodeCampYearNoteResults = // SponsorListCodeCampYearNoteManager.I.Get(sponsorListCodeCampYearNoteQuery); // foreach (var rec in resultList) // { // rec.SponsorListNoteResults = // sponsorListCodeCampYearNoteResults.Where(a => a.SponsorListCodeCampYearId == rec.Id).ToList(); // } //} //List<SponsorListCodeCampYearContactResult> sponsorListCodeCampYearCodeCampYearContactResults = null; //if (query.WithContacts != null && query.WithContacts.Value) //{ // var sponsorListCodeCampYearContactQuery = // new SponsorListCodeCampYearContactQuery(); // if (query.CodeCampYearId != null) // { // sponsorListCodeCampYearContactQuery.SponsorListCodeCampYearId = query.CodeCampYearId; // } // sponsorListCodeCampYearCodeCampYearContactResults = // SponsorListCodeCampYearContactManager.I.Get(sponsorListCodeCampYearContactQuery); // foreach (var rec in resultList) // { // rec.SponsorListContactResults = // sponsorListCodeCampYearCodeCampYearContactResults.Where( // a => a.SponsorListCodeCampYearId == rec.Id).ToList(); // } //} return resultList; }
private static IEnumerable<Attendees> GetSessionPresenters(CodeCampDataContext codeCampDataContext, int sessionId) { // make sure primary presenter is first List<int> attendeeIds = (from data in codeCampDataContext.SessionPresenter where data.SessionId == sessionId orderby data.Id select data.AttendeeId).ToList(); // going through one at a time to make sure list stays sorted the way we want it // rather than doing a .Contains type statement. Most sessions are one speaker so it's // not that important. var attendeesList = new List<Attendees>(); foreach (int attendeeId in attendeeIds) { int id = attendeeId; Attendees attendeeOne = (from data in codeCampDataContext.Attendees where data.Id == id select data).FirstOrDefault(); attendeesList.Add(attendeeOne); } return attendeesList; }
// public override void Insert(LoadResult result) // { // base.Insert(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // foreach (CargoResult c in result.Cargos) // { // c.LoadId = result.Id; // CargoManager.I.Insert(c); // } // } // } // // public override void Update(LoadResult result) // { // base.Update(result); // if (result.Cargos != null && result.Cargos.Count > 0) // { // CargoManager.I.Update(result.Cargos); // } // } //public static object Olock = new Object(); //public List<SessionTagsResult> GetByCodeCampYearIdCached(int codeCampYearId,int cacheTimeOutSeconds) //{ // string cacheString = "SessionTagsManagerCacheAll-" + codeCampYearId.ToString(); // var o = (List<SessionTagsResult>)HttpContext.Current.Cache[cacheString]; // if (o == null) // { // lock (Olock) // { // o = Get(new SessionTagsQuery() { CodeCampYearId = codeCampYearId }); // HttpContext.Current.Cache.Insert(cacheString, o, // null, // DateTime.Now.Add(new TimeSpan(0, 0, cacheTimeOutSeconds)), // TimeSpan.Zero); // } // } // return o; //} public List<SessionTagsResult> Get(SessionTagsQuery query) { var meta = new CodeCampDataContext(); IQueryable<SessionTags> baseQuery = from myData in meta.SessionTags select myData; // next is automated query formation from AutoGen Shared Class // (do not remove next line or filters will go away) baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.CodeCampYearId != null) { int codeCampYearId = query.CodeCampYearId.Value; var tagsCodeCampYear = meta.SessionTagsView.Where(data => data.CodeCampYearId == codeCampYearId).Select(data => data.TagId); baseQuery = baseQuery.Where(data => tagsCodeCampYear.Contains(data.TagId)); } Dictionary<int, string> dict = null; if (query.WithTagDescription.HasValue && query.WithTagDescription.Value) { dict = (from data in meta.Tags select data).ToDictionary(k => k.Id, v => v.TagName); } IQueryable<SessionTagsResult> results = GetBaseResultIQueryable(baseQuery); List<SessionTagsResult> resultList = GetFinalResults(results, query); if (dict != null) { foreach (var rec in resultList) { if (dict.ContainsKey(rec.TagId)) { rec.TagName = dict[rec.TagId].Trim(); } } } if (query.WithAllTagsAllYears.HasValue && query.WithAllTagsAllYears.Value && dict != null) { List<int> tagsInSession = resultList.Select(a=>a.TagId).ToList(); var finalList = new List<SessionTagsResult>(); var sessionTagsAll = from myData in meta.SessionTags select myData; finalList.AddRange(sessionTagsAll.Select(rec => new SessionTagsResult { Id = rec.Id, SessionId = rec.SessionId, TagId = rec.TagId, TagName = dict[rec.TagId], AssignedToSession = dict.ContainsKey(rec.TagId) })); resultList = finalList; } return resultList.OrderBy(a => a.TagName).ToList(); }
private List<int> GetListOfSessionsBasedOnQueryParams(CodeCampDataContext codeCampDataContext) { var sessionIds = new List<int>(); // need to get all query params and do filter here var sessionsOds = new SessionsODS(); int outInt = 0; string str = Request.QueryString["id"]; bool foundId = Int32.TryParse(str, out outInt); if (foundId) { sessionIds = new List<int>() {outInt}; } else { //var sessions = // codeCampDataContext.Sessions.Where(a => a.CodeCampYearId == Utils.CurrentCodeCampYear).ToList(); sessionIds = codeCampDataContext.Sessions.Where(a => a.CodeCampYearId == Utils.CurrentCodeCampYear).Select(a => a.Id) .ToList(); } return sessionIds; }
public List<SessionsResult> Get(SessionsQuery query) { if (query.CodeCampYearId.HasValue) { query.CodeCampYearIds = new List<int>() { query.CodeCampYearId.Value}; } var meta = new CodeCampDataContext(); IQueryable<Sessions> baseQuery = from myData in meta.Sessions select myData; // .Where(a => a.Id == 594).ToList(); baseQuery = BaseQueryAutoGen(baseQuery, query); if (query.SkipRoomIds != null && query.SkipRoomIds.Any()) { baseQuery = from data in baseQuery where data.LectureRoomsId.HasValue && !query.SkipRoomIds.Contains(data.LectureRoomsId.Value) select data; } if (query.RoomIds != null && query.RoomIds.Any()) { baseQuery = from data in baseQuery where data.LectureRoomsId.HasValue && query.RoomIds.Contains(data.LectureRoomsId.Value) select data; } var sessionIdsPlanToAttend = new List<int>(); var sessionIdsInterested = new List<int>(); if (query.WithInterestOrPlanToAttend != null && HttpContext.Current != null && HttpContext.Current.User.Identity.IsAuthenticated ) { string username = HttpContext.Current.User.Identity.Name; Guid? PKID = (from data in meta.Attendees where data.Username.Equals(username) select data.PKID).FirstOrDefault(); if (PKID != null) { sessionIdsPlanToAttend = (from data in meta.SessionAttendee where data.Interestlevel == 3 && data.Attendees_username == PKID.Value select data.Sessions_id).ToList(); sessionIdsInterested = (from data in meta.SessionAttendee where data.Interestlevel == 2 && data.Attendees_username == PKID.Value select data.Sessions_id).ToList(); } } if (query.CodeCampYearIds != null && query.CodeCampYearIds.Count > 0) { baseQuery = baseQuery.Where(data => query.CodeCampYearIds.Contains(data.CodeCampYearId)); } List<int> sponsorIdsWithActiveJobs; if (query.JustActiveJobListings != null && query.JustActiveJobListings.Value) { sponsorIdsWithActiveJobs = (from data in meta.SponsorListJobListing where data.StartRunDate.HasValue && data.EndRunDate.HasValue && data.StartRunDate.Value.CompareTo(DateTime.Now) < 0 && data.EndRunDate.Value.CompareTo(DateTime.Now) > 0 && data.HideListing == false select data.SponsorListId).ToList(); baseQuery = baseQuery.Where( data => data.SponsorId != null && sponsorIdsWithActiveJobs.Contains(data.SponsorId.Value)); } var speakerResults = new List<AttendeesResult>(); var sessionPresenterResults =new List<SessionPresenterResult>(); if (query.WithSpeakers != null && query.WithSpeakers.Value) { //var attendeesQuery = new AttendeesQuery // { // PresentersOnly = true // }; var sessionPresenterQuery = new SessionPresenterQuery(); if (query.CodeCampYearIds != null && query.CodeCampYearIds.Count > 0) { //attendeesQuery.CodeCampYearIds = query.CodeCampYearIds; sessionPresenterQuery.CodeCampYearIds = query.CodeCampYearIds; //attendeesQuery.CodeCampYearIds = query.CodeCampYearIds; } sessionPresenterResults = SessionPresenterManager.I.Get(sessionPresenterQuery); List<int> speakerIdsAll = sessionPresenterResults.Select(a => a.AttendeeId).ToList(); speakerResults = AttendeesManager.I.Get(new AttendeesQuery() { Ids = speakerIdsAll }); } IQueryable<SessionsResult> results = GetBaseResultIQueryable(baseQuery); List<SessionsResult> resultList = GetFinalResults(results, query); var tagsResults = new List<TagsResult>(); var sessionTagsManagers = new List<SessionTagsResult>(); if (query.WithTags != null && query.WithTags.Value) { tagsResults = TagsManager.I.GetAll(); // could be smarter, but not that many tags sessionTagsManagers = SessionTagsManager.I.GetAll(); } //// next several lines are just for the single speaker that is associated with the session. not the multiple speaker option //List<int> speakerIds = (resultList.Select(data => data.Attendeesid)).ToList(); //var presentersQuery = from attend in meta.Attendees // where speakerIds.Contains(attend.Id) // select new // { // attend.Id, // SpeakerName = attend.UserFirstName + " " + attend.UserLastName, // attend.UserWebsite, // attend.PKID // }; //var speakerDict = // presentersQuery.ToDictionary(presenter => presenter.Id, presenter => presenter.SpeakerName); //var speakerUrlDict = new Dictionary<int, string>(); //var speakerImageUrl = new Dictionary<int, string>(); //foreach (var presenter in presentersQuery) //{ // speakerUrlDict.Add(presenter.Id, presenter.UserWebsite); // speakerImageUrl.Add(presenter.Id,presenter.PKID.ToString()); //} var lectureRoomsDict = (from data in meta.LectureRooms select data).ToDictionary(k => k.Id, v => v.Number); var sessionTimesDict = (from data in meta.SessionTimes select data).ToDictionary(k => k.Id, v => v.StartTimeFriendly); var planCountsDict = (from data in meta.SessionAttendee where data.Interestlevel == 3 group data by data.Sessions_id into g orderby g.Key ascending select new { cnt = g.Count(), id = g.Key }).ToDictionary(k => k.id, v => v.cnt); var interestCountsDict = (from data in meta.SessionAttendee where data.Interestlevel == 2 group data by data.Sessions_id into g orderby g.Key ascending select new { cnt = g.Count(), id = g.Key }).ToDictionary(k => k.id, v => v.cnt); var sessionTimesFullDict = new Dictionary<int, SessionTimes>(); if (query.WithSchedule != null) { sessionTimesFullDict = (from data in meta.SessionTimes select data).ToDictionary(k => k.Id, v => v); } var sessionLevelsDict = new Dictionary<int, string>(); if (query.WithLevel.HasValue && query.WithLevel.Value) { sessionLevelsDict = (from data in meta.SessionLevels select data).ToDictionary(k => k.Id, v => v.Description); } foreach (var session in resultList) { if (query.WithLevel.HasValue && query.WithLevel.Value) { if (session.SessionLevel_id.HasValue && sessionLevelsDict.ContainsKey(session.SessionLevel_id.Value)) { session.SessionLevel = sessionLevelsDict[session.SessionLevel_id.Value]; } } session.SessionUrl = String.Format("/Session/{0}/{1}", Utils.ConvertCodeCampYearToActualYear( session.CodeCampYearId.ToString(CultureInfo.InvariantCulture)), Utils.GenerateSlug(session.Title)); if (query.WithSchedule != null && session.SessionTimesId.HasValue) { if (sessionTimesFullDict.ContainsKey(session.SessionTimesId.Value)) { var st = sessionTimesFullDict[session.SessionTimesId.Value]; session.SessionTimesResult = new SessionTimesResult() { // no doing all the parameters, not necessary CodeCampYearId = st.CodeCampYearId, StartTime = st.StartTime, EndTime = st.EndTime, Id = st.Id, Description = st.Description }; } } if (query.WithInterestOrPlanToAttend != null) { if (sessionIdsInterested.Contains(session.Id)) { session.LoggedInUserInterested = true; } if (sessionIdsPlanToAttend.Contains(session.Id)) { session.LoggedInUserPlanToAttend = true; } } if (session.Createdate != null) { var ts = DateTime.Now.Subtract(session.Createdate.Value); session.SessionPosted = (ts.Days + 1).ToString(CultureInfo.InvariantCulture); } else { session.SessionPosted = "Up"; } // http://localhost:5691/Web/DisplayImage.ashx?sizex=100&PKID=33a199dd-1154-45cb-bc94-40ffc5a99391 // (the next 3 lines maybe overwritten if speaker is set to be removed) // GOING FORWARD WE DON'T WANT TO USE SINGLE PICTURE FOR SESSIONS SPEAKER SINCE CAN HAVE MULTIPLE SPEAKERS //session.SpeakerPictureUrl = String.Format("DisplayImage.ashx?sizex=150&PKID={0}", speakerImageUrl[session.Attendeesid]); //session.PresenterName = speakerDict[session.Attendeesid]; //session.PresenterURL = speakerUrlDict[session.Attendeesid]; session.SpeakerPictureUrl = "DO NOT USE, USE SpeakersList instead"; session.PresenterName = "DO NOT USE, USE SpeakersList instead"; session.PresenterURL = "DO NOT USE, USE SpeakersList instead"; if (query.WithSpeakers != null && query.WithSpeakers.Value) { SessionsResult session1 = session; var speakerIdsForList = sessionPresenterResults.Where(a => a.SessionId == session1.Id) .Select(a => a.AttendeeId) .ToList(); // quick and dirty cleansing of speaker data so just public data will be shown var tempSpeakerResults = Enumerable.OrderBy(speakerResults.Where(a => speakerIdsForList.Contains(a.Id)), a => a.UserLastName == null ? string.Empty : a.UserLastName.ToUpper()); session.SpeakersList = new List<SpeakerResult>(); foreach (var rec in tempSpeakerResults) { //// need to figure out if removing primary speaker is necessary //if (session.DoNotShowPrimarySpeaker) //{ // string userNameOfSpeakerFromSession = session.Username; // string userNameOfSpeakerFromSessionSpeaker = rec.Username; // if (!userNameOfSpeakerFromSession.Equals(userNameOfSpeakerFromSessionSpeaker)) // { // session.SpeakersList.Add(new AttendeesResult() // { // Id = rec.Id, // Email = rec.Email, // TwitterHandle = rec.TwitterHandle, // Username = rec.Username, // City = rec.City, // State = rec.State, // UserBio = rec.UserBio, // UserFirstName = rec.UserFirstName, // UserLastName = rec.UserLastName, // UserZipCode = rec.UserZipCode, // UserWebsite = rec.UserWebsite, // SpeakerPictureUrl = // String.Format( // String.Format("attendeeimage/{0}.jpg", rec.Id), // rec.Id) // }); // // kind of klugy if there are more than 2 speakers, but for now, we should push someone who is not the primary speaker // // into the primary slot. // session.Username = "******"; // session.PresenterName = "DO NOT USE THIS. USE SpeakersList instead"; // session.PresenterURL = rec.UserWebsite; // session.SpeakerPictureUrl = "DO NOT USE THIS. USE SpeakersList instead"; // } //} //else //{ var attendeeResult = new SpeakerResult() { AttendeeId = rec.Id, Email = rec.Email, TwitterHandle = rec.TwitterHandle, Username = rec.Username, City = "", State = rec.State, UserBio = rec.UserBio, UserBioEllipsized = Utils.GetEllipsized(rec.UserBio, 90, "..."), UserFirstName = rec.UserFirstName, UserLastName = rec.UserLastName, UserZipCode = rec.UserZipCode, UserWebsite = rec.UserWebsite, SpeakerLocalUrl = String.Format("/Presenter/{0}/{1}-{2}-{3}", Utils .ConvertCodeCampYearToActualYear (session.CodeCampYearId.ToString( CultureInfo.InvariantCulture)), Utils.AlphaNumericOnly( rec.UserFirstName), Utils.AlphaNumericOnly( rec.UserLastName), rec.Id), ImageUrl = String.Format( String.Format("/attendeeimage/{0}.jpg", rec.Id), rec.PKID) }; session.SpeakersList.Add(attendeeResult); //} } // need to update speakersshort var sbSpeakersShort = new StringBuilder(); if (session.SpeakersList.Count > 0 && session.SpeakersList.Count <= 1) { session.SpeakersShort = session.SpeakersList[0].UserFirstName + " " + session.SpeakersList[0].UserLastName; } else if (session.SpeakersList.Count > 1) { foreach (var speaker in session.SpeakersList) { sbSpeakersShort.Append(speaker.UserLastName); sbSpeakersShort.Append(", "); } session.SpeakersShort = sbSpeakersShort.ToString().Trim(); if (session.SpeakersShort.Length > 2) { session.SpeakersShort.Remove(session.SpeakersShort.Length - 2); } } else { session.SpeakersShort = "Unknown Speaker"; } //session.SpeakersList = speakerResults.Where(a => speakerIdsForList.Contains(a.Id)).ToList(); } session.RoomNumber = session.LectureRoomsId != null && lectureRoomsDict.ContainsKey(session.LectureRoomsId.Value) ? lectureRoomsDict[session.LectureRoomsId.Value] : "ROOM NOT FOUND/PROBLEM!"; session.RoomNumberNew = session.RoomNumber; session.SessionTime = session.SessionTimesId != null && sessionTimesDict.ContainsKey(session.SessionTimesId.Value) ? sessionTimesDict[session.SessionTimesId.Value] : "TIME NOT FOUND/PROBLEM!"; session.TitleWithPlanAttend = planCountsDict.ContainsKey(session.Id) ? string.Format("PA: {0} {1} ", planCountsDict[session.Id], session.Title) : "PS: 0 " + session.Title; if (planCountsDict.ContainsKey(session.Id)) { session.PlanAheadCount = planCountsDict[session.Id].ToString(); session.PlanAheadCountInt = planCountsDict[session.Id]; } else { session.PlanAheadCount = "SessionId: " + session.Id + " Not Found"; session.PlanAheadCountInt = 0; } if (interestCountsDict.ContainsKey(session.Id)) { session.InterestCount = interestCountsDict[session.Id].ToString(); session.InterestCountInt = interestCountsDict[session.Id]; } else { session.PlanAheadCount = "SessionId: " + session.Id + " Not Found"; session.PlanAheadCountInt = 0; } if (query.WithTags != null && query.WithTags.Value) { List<int> tagIds = sessionTagsManagers.Where(a => a.SessionId == session.Id).Select(a => a.TagId).ToList(); session.TagsResults = (tagsResults.Where(data => tagIds.Contains(data.Id))).ToList(); foreach (var r in session.TagsResults) { r.SessionId = session.Id; } } session.SessionSlug = Utils.GenerateSlug(session.Title); session.TitleEllipsized = Utils.GetEllipsized(session.Title, 48, "..."); session.DescriptionEllipsized = Utils.GetEllipsized(session.Description, 90, "..."); } return resultList; }
private static IEnumerable<Attendees> GetSessionPresenters(CodeCampDataContext codeCampDataContext, int sessionId) { // make sure primary presenter is first List<int> attendeeIds = (from data in codeCampDataContext.SessionPresenter where data.SessionId == sessionId orderby data.Id select data.AttendeeId).ToList(); // going through one at a time to make sure list stays sorted the way we want it // rather than doing a .Contains type statement. Most sessions are one speaker so it's // not that important. var attendeesList = new List<Attendees>(); foreach (int attendeeId in attendeeIds) { int id = attendeeId; Attendees attendeeOne = (from data in codeCampDataContext.Attendees where data.Id == id select data).FirstOrDefault(); attendeesList.Add(attendeeOne); } return attendeesList; //// make sure primary presenter is first //List<int> attendeeIds = (from data in codeCampDataContext.Sessions // where data.Id == sessionId // select data.Attendeesid).ToList(); //// the orderby id forces the primary speaker to be listed first (hopefully) //List<Attendees> attendeeSpeakers = (from data in codeCampDataContext.Attendees // where attendeeIds.Contains(data.Id) // orderby data.Id // select data).ToList(); //var rec = from data in codeCampDataContext.Attendees // where data.Username.Equals("pkellner") // select data; //attendeeSpeakers.Add(rec.FirstOrDefault()); //return attendeeSpeakers; }