Ejemplo n.º 1
0
        /// <summary>
        /// Maps a CodeCampService.Speaker to a Model.Speaker
        /// </summary>
        /// <param name="speaker">CodeCampService.Speaker</param>
        /// <returns>Model.Speaker</returns>
        public static Model.Speaker Map(Services.Speaker speaker)
        {
            var modelSpeaker = new Model.Speaker()
                                   {
                                       ImageUrl = speaker.ImageUrl,
                                       Website = speaker.Website,
                                       Email = speaker.Email,
                                       Bio = speaker.Bio,
                                       Twitter = speaker.Twitter,
                                       Blog = speaker.Blog,
                                       Title = speaker.Title,
                                       FirstName = speaker.FirstName,
                                       LastName = speaker.LastName,
                                       IsAdmin = speaker.IsAdmin,
                                       LoginProvider = speaker.LoginProvider
                                   };

            modelSpeaker.Sessions = (List<Model.Session>)speaker.Sessions.Map();
            return modelSpeaker;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Maps a CodeCampService.Person to a Model.Person
 /// </summary>
 /// <param name="person"></param>
 /// <returns></returns>
 public static Model.Person Map(Services.Person person)
 {
     var p = new Model.Person
     {
         ID = person.ID,
         ImageUrl = person.ImageUrl,
         Website = person.Website,
         Email = person.Email,
         Bio = person.Bio,
         Twitter = person.Twitter,
         Blog = person.Blog,
         Title = person.Title,
         FirstName = person.FirstName,
         LastName = person.LastName,
         IsAdmin = person.IsAdmin,
         Location = person.Location,
         TShirtSizeId = person.TShirtSize,
         LoginProvider = person.LoginProvider,
     };
     return p;
 }
Ejemplo n.º 3
0
        private void SetFormsAuth(Services.Person authenticatedPerson, bool rememberMe)
        {
            this.CurrentUser = new uiModel.Person
            {
                ID = authenticatedPerson.ID,
                ImageUrl = authenticatedPerson.ImageUrl,
                Website = authenticatedPerson.Website,
                Email = authenticatedPerson.Email,
                Bio = authenticatedPerson.Bio,
                Twitter = authenticatedPerson.Twitter,
                Blog = authenticatedPerson.Blog,
                Title = authenticatedPerson.Title,
                FirstName = authenticatedPerson.FirstName,
                LastName = authenticatedPerson.LastName,
                IsAdmin = authenticatedPerson.IsAdmin,
                Location = authenticatedPerson.Location,
                LoginProvider = authenticatedPerson.LoginProvider
            };

            HttpContext.Session.Add("auth", true);
            HttpContext.User = CurrentUser;

            SetPersonRoles(this.CurrentUser);

            CreateAuthTicket(rememberMe);

            // FormsAuthentication.SetAuthCookie(CurrentUser.Email, false);
            // ???
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Maps the roles for a Person based on the existence 
        /// of certain properties and flags
        /// </summary>
        /// <param name="p">Model.Person</param>
        /// <param name="speaker">Model.Speaker</param>
        public static void SetRolesForPerson(this Model.Person p, Services.Speaker speaker = null)
        {
            if (p != null)
            {
                if (p.IsAdmin)
                {
                    p.Roles.Add("Admin");
                }
            }

            if (speaker != null)
            {
                if (speaker.Sessions != null)
                {
                    if (speaker.Sessions.Any())
                    {
                        p.Roles.Add("Speaker");
                    }
                }
            }
        }