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); }
public ActionResult Register(int eventId, RegisterModel model, FormCollection frm) { if (ModelState.IsValid) { ViewBag.TShirtSizes = repo.GetTShirtSizes(); if (IsDuplicateRegistration(model.Email)) { ModelState.AddModelError("Email", "The user at this email address is already registered."); return View(model); } if (!String.IsNullOrEmpty(model.Twitter)) { if (!model.Twitter.StartsWith("@")) { const string twitterPrefix = "@"; model.Twitter = string.Format("{0}{1}", twitterPrefix, model.Twitter); } } var newPerson = new CodeCampService.Person() { Email = model.Email, PasswordHash = UserNamePasswordHashProvider.ComputePasswordHash(model.Password), Twitter = model.Twitter, FirstName = model.FirstName, LastName = model.LastName, Location = model.Location, TShirtSize = model.TShirtSizeId }; bool useTwitter = frm["cbTwitter"] == "on"; if (model.Avatar != null) { newPerson.ImageUrl = GetImageInfo(model.Avatar, "/Content/avatar"); } else if (useTwitter) { newPerson.ImageUrl = GetImageInfo(model.Twitter, LocalImageUrl); } else { newPerson.ImageUrl = LocalImageUrl; } // service.RegisterPerson(newPerson); newPerson.ID = service.RegisterPerson(newPerson); // service.FindPersonByEmail(newPerson.Email).ID; service.Rsvp(eventId, newPerson.ID, "YES"); HttpContext.User = this.CurrentUser = newPerson.Map(); HttpContext.Session.Add("auth", true); //this.CurrentUser = newPerson.Map(); FormsAuthentication.SetAuthCookie(CurrentUser.Email, false); // ??? return RedirectToAction("Index", "Home"); } // If we got this far, something failed, redisplay form return View(model); }