public static List<CurrentAttendee> WaitList() { var ctx = new ICCData(); return ctx.CurrentAttendees.Where(a => a.EventID == NextEventId) .Skip(Config.MaxAttendees).ToList(); }
public static User Create(string FirstName, string LastName, string Password, string Email, string DisplayName, string Site, string Organization, string Comments, string City, string Region, string Country) { if (!IsEmailUnique(Email)) return new User(); var newUser = new User() { FirstName = FirstName, LastName = LastName, DisplayName = DisplayName, Email = Email, Site = Site, Organization = Organization, City = City, Region = Region, Country = Country, Comments = Comments, ValidationCode = Guid.NewGuid().ToString(), IsValidated = false }; if (newUser.DisplayName.Trim().Length < 1) DisplayName = FirstName + " " + LastName; SetPassword(newUser, Password); var ctx = new ICCData(); ctx.Users.InsertOnSubmit(newUser); ctx.SubmitChanges(); return newUser; }
public static CurrentSpeaker Select(int speakerKey) { var ctx = new ICCData(); return ctx.CurrentSpeakers .Where(currentSpeaker => currentSpeaker.SpeakerKey == speakerKey) .First(); }
public static List<CurrentSession> ListByTitle() { var ctx = new ICCData(); return ctx.CurrentSessions .OrderBy(currentSession => currentSession.Title) .ToList(); }
public static Event GetNextEvent() { var data = new ICCData(); var nextevent = data.Events.Where(e => e.StartOn.Date >= DateTime.Today) .OrderBy(e=>e.StartOn).FirstOrDefault(); return nextevent; }
public static List<CurrentSession> List() { var ctx = new ICCData(); return ctx.CurrentSessions .OrderBy(currentSession => currentSession.RoomOrdinal) .OrderBy(currentSession => currentSession.SessionTimeOrdinal) .ToList(); }
public static bool Add(CurrentAttendee attendee) { attendee.EventID = NextEventId; var ctx = new ICCData(); ctx.CurrentAttendees.InsertOnSubmit(attendee); ctx.SubmitChanges(); return true; }
public static List<CurrentSession> SpeakerSessions(int speakerKey) { var ctx = new ICCData(); return ctx.CurrentSessions .OrderBy(currentSession => currentSession.RoomOrdinal) .OrderBy(currentSession => currentSession.SessionTimeOrdinal) .Where(currentSession => currentSession.SpeakerKey == speakerKey) .ToList(); }
public static List<Session> GetAllSessions() { var ctx = new ICCData(); int eId = Event.GetNextEvent().Id; var sessions = from s in ctx.Sessions where s.EventId == eId && s.IsApproved select s; var sessions1 = ctx.Sessions.Where(sess => sess.EventId == eId); return sessions.ToList(); }
public static bool AddUserToRole(string UserName, string RoleName) { ICCData ctx = new ICCData(); var user = (from u in ctx.Users where string.Compare(u.Email, UserName, true) == 0 select u).FirstOrDefault(); var role = (from r in ctx.Roles where string.Compare(r.Name, RoleName, true) == 0 select r).FirstOrDefault(); if (user.Id > 0 && role.Id > 0) { var ur = new UserRole() { UserId = user.Id, RoleId = role.Id }; ctx.UserRoles.InsertOnSubmit(ur); ctx.SubmitChanges(); return true; } return false; }
public static List<Session> GetProposedSessions() { var ctx = new ICCData(); int eId = 0; Event ev = Event.GetNextEvent(); if (ev != null) eId = ev.Id; var sessions = from s in ctx.Sessions where s.IsApproved == false && s.EventId == eId //let SpeakerName = s.Speakers. select s; return sessions.ToList(); }
public static void Propose(string Email, string SessionTitle, string SessionAbstract) { var ctx = new ICCData(); int eId = Event.GetNextEvent().Id; var session = new Session() { Title = SessionTitle, Abstract = SessionAbstract, EventId = eId }; ctx.Sessions.InsertOnSubmit(session); ctx.SubmitChanges(); var user = ctx.Users.Where(u => string.Compare(u.Email, Email, true) == 0).FirstOrDefault(); Speaker speak = new Speaker() { SessionId = session.Id, UserId = user.Id }; ctx.Speakers.InsertOnSubmit(speak); ctx.SubmitChanges(); }
public override string[] GetRolesForUser(string email) { email = email ?? ""; var ctx = new ICCData(); //get userid int MyUserID = ctx.Users.Where(u => u.Email == email).FirstOrDefault().Id; //get user roles IQueryable<UserRole> UserRoles = ctx.UserRoles.Where(ur => ur.UserId == MyUserID); //load role ids into arraylist var alUserRoles = new ArrayList(UserRoles.Count()); UserRoles.ToList().ForEach(ur => { alUserRoles.Add(ur.RoleId); }); //get roles for user based on id IQueryable<Role> roles = (from r in ctx.Roles select r).AsQueryable(); var alRoles = new ArrayList(); roles.ToList().ForEach(r => { if (alUserRoles.Contains(r.Id)) alRoles.Add(r.Name); }); //convert roles to string array return alRoles.ToArray(typeof (string)) as string[]; }
public static User Get(string email) { email = email ?? ""; var ctx = new ICCData(); return (from u in ctx.Users where string.Compare(u.Email, email, true) == 0 select u).FirstOrDefault(); }
public static bool Update(int SessionId, string Title, string Abstract, bool IsApproved, int SpeakerID) { var ctx = new ICCData(); var session = (from s in ctx.Sessions where s.Id == SessionId select s).First(); session.Title = Title; session.Abstract = Abstract; session.IsApproved = IsApproved; var speakers = (from s in ctx.Speakers where s.SessionId == SessionId select s).First(); ctx.SubmitChanges(); return true; }
public static List<CurrentSpeaker> List() { var ctx = new ICCData(); return ctx.CurrentSpeakers.OrderBy(currentSpeaker => currentSpeaker.SpeakerName).ToList(); }
public static int GetTotalCount() { var ctx = new ICCData(); return ctx.CurrentAttendees.Where(a => a.EventID == NextEventId).Count(); }
public static List<User> GetAttendees() { var ctx = new ICCData(); var speakers = (from u in ctx.Users where u.IsValidated == true orderby u.LastName, u.FirstName select u).ToList(); return speakers; }
public static List<User> GetCurrentEventAttendees() { var ctx = new ICCData(); //HACK clearly unfinished return (from u in ctx.Users where u.IsValidated == true select u).ToList(); }
public static bool ValidateUserAccount(string code) { ICCData ctx = new ICCData(); var userMatch = (from u in ctx.Users where u.ValidationCode == code select u).FirstOrDefault(); if (userMatch.Id > 0) { userMatch.IsValidated = true; ctx.SubmitChanges(); AddUserToRole(userMatch.Email, "attendees"); return true; } return false; }
public static bool Validate(string email, string password) { email = email ?? ""; password = password ?? ""; ICCData ctx = new ICCData(); var matches = from u in ctx.Users where u.Email == email && u.IsValidated select u; if (matches.Count() < 1) return false; string passwordHash = CreatePasswordHash(password, matches.First().PasswordSalt); return passwordHash == matches.First().Password; }
public static void Update(string email, string firstname, string lastname, string password, string displayname, string site, string organization, string city, string region, string country, string comments) { var ctx = new ICCData(); var user = ctx.Users.Where(u => string.Compare(u.Email, email, true) == 0).FirstOrDefault(); user.FirstName = firstname; user.LastName = lastname; if (password.Trim().Length > 0) SetPassword(user, password); user.DisplayName = displayname; user.Site = site; user.Organization = organization; user.City = city; user.Region = region; user.Country = country; user.Comments = comments; ctx.SubmitChanges(); }