Beispiel #1
0
        // GET: Households/LeaveHousehold
        public ActionResult LeaveHousehold()
        {
            LeaveHouseholdViewModel leaveHouseholdVM = new LeaveHouseholdViewModel();

            leaveHouseholdVM.ConfirmLeave = false;
            return(View(leaveHouseholdVM));
        }
        public async Task <ActionResult> Leave([Bind(Include = "UserId,HasAgreedToLeave")] LeaveHouseholdViewModel model)
        {
            //if checkbox is checked, showing user has agreed to leave, assign their HouseholdId to null
            if (model.HasAgreedToLeave == true)
            {
                await AssignUserToHousehold(model.UserId, null);

                //Refresh the cookie holding the user identity so the user can't access the household anymore
                await RefreshCookie(model.UserId);

                return(RedirectToAction("Index", "Household"));
            }
            else
            {
                return(RedirectToAction("Index", "Household"));
            }
        }