Exemple #1
0
        /// <summary>
        /// Maps a CodeCampService.Person to a Model.Person
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        public static Model.Person Map(this Service.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
            };

            return(p);
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                string modifiedTwitterHandle = string.Empty;

                if (!model.Twitter.StartsWith("@"))
                {
                    const string twitterPrefix = "@";
                    model.Twitter = string.Format("{0}{1}", twitterPrefix, model.Twitter);
                }
                var hash =
                    UserNamePasswordHashProvider.GenerateUserNamePasswordHash(model.Email, model.Password);

                var newPerson = new OCC.UI.Webhost.CodeCampService.Person()
                                    {
                                        Email = model.Email,
                                        PasswordHash = hash,
                                        // Agenda = new OCC.UI.Webhost.CodeCampService.Session[0],
                                        Twitter = model.Twitter
                                    };

                service.RegisterPerson(newPerson);

                return RedirectToAction("Index", "Home");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }