Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        public static bool Add(CurrentAttendee attendee)
        {
            attendee.EventID = NextEventId;

            var ctx = new ICCData();
            ctx.CurrentAttendees.InsertOnSubmit(attendee);
            ctx.SubmitChanges();

            return true;
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
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();
        }