Inheritance: System.Data.Linq.DataContext
        public static List<CurrentAttendee> WaitList()
        {
            var ctx = new ICCData();

            return ctx.CurrentAttendees.Where(a => a.EventID == NextEventId)
                .Skip(Config.MaxAttendees).ToList();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 5
0
        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();
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
0
        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;
        }
Esempio n. 11
0
        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();
        }
Esempio n. 12
0
        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();
        }
Esempio n. 13
0
    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[];
    }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
        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;
        }
Esempio n. 16
0
        public static List<CurrentSpeaker> List()
        {
            var ctx = new ICCData();

            return ctx.CurrentSpeakers.OrderBy(currentSpeaker => currentSpeaker.SpeakerName).ToList();
        }
Esempio n. 17
0
        public static int GetTotalCount()
        {
            var ctx = new ICCData();

            return ctx.CurrentAttendees.Where(a => a.EventID == NextEventId).Count();
        }
Esempio n. 18
0
        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;
        }
Esempio n. 19
0
 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();
 }
Esempio n. 20
0
        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;
        }
Esempio n. 21
0
        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;
        }
Esempio n. 22
0
        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();
        }