public ProfileEditModel(Profile profile)
 {
     Username = profile.Username;
     FirstName = profile.FirstName;
     LastName = profile.LastName;
     Email = profile.Email;
 }
        public ActionResult LogOn(LogOnModel model, bool rememberMe, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (MembershipService.ValidateUser(model.UserName, model.Password))
                {
                    var profile = _profileRepository.Find(model.UserName);

                    if (profile == null)
                    {
                        profile = new Profile(model.UserName);
                        _profileRepository.Add(profile);
                    }

                    Session[SessionValueProvider.CurrentUserKey] = profile;

                    FormsService.SignIn(model.UserName, rememberMe);
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public void Add(Profile profile)
 {
     _profiles.Add(profile);
 }