public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    var user = new User
                    {
                        Address = new Address
                        {
                            StreetAddress1 = model.Street1,
                            StreetAddress2 = model.Street2,
                            City = model.City,
                            State = model.State,
                            Zip = model.Zip
                        },
                        Email = model.Email,
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        Nickname = model.UserName,
                        Phone = model.Phone,
                        DateRegistered = DateTime.Now,
                        OrganizationUser = false,
                        Rating = 0
                    };
                    db.Users.Add(user);
                    db.SaveChanges();
                    var profile = WebProfile.GetProfile(model.UserName);
                    profile.UserId = user.UserID;
                    profile.Save();
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public ActionResult Edit(User user)
 {
      if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.Entry(user.Address).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
      return View();
 }