//GET: AcceptHouseInvite
        public ActionResult AcceptHouseInvite(int id, Guid code)
        {
            var invite = db.Invitations.FirstOrDefault(i => i.Code == code);

            if (DateTime.Now < invite.Expire)
            {
                var register = new InviteRegisterVM {
                    HouseholdId = id, Email = invite.EmailTo
                };
                return(View(register));
            }
            else
            {
                return(RedirectToAction("InviteExpire", "Households"));
            }
        }
        public async Task <ActionResult> AcceptHouseInvite(InviteRegisterVM model, HttpPostedFileBase AvatarPath)
        {
            var house = db.Households.FirstOrDefault(h => h.Id == model.HouseholdId);
            var image = imageHelper.StoreAvatar(AvatarPath);

            if (ModelState.IsValid)
            {
                //check to see if this email is already associated with a user in the application
                var email = db.Users.FirstOrDefault(user => user.Email == model.Email);
                if (email == null)
                {
                    var newUser = userHelper.AssignRegisterPropertiesToUser(model, image);
                    newUser.UserName = model.Email;
                    var result = await UserManager.CreateAsync(newUser, model.Password);

                    if (result.Succeeded)
                    {
                        UserManager.AddToRole(newUser.Id, "HouseholdMember");
                        await SignInManager.SignInAsync(newUser, isPersistent : false, rememberBrowser : false);

                        await houseHelper.AddToHouseAsync(newUser.Id, model.HouseholdId);

                        return(RedirectToAction("Details", "Households", new { id = model.HouseholdId }));
                    }
                    else
                    {
                        return(View(model));
                    };
                }
                else
                {
                    //redirect to a view that tells user their email is already associated with an account
                    return(RedirectToAction("AccountExists", "Households"));
                }
            }
            return(View(model));
        }