public ActionResult Leave(int id) { var user = User.Identity.GetUserId(); HouseholdUsersHelper helper = new HouseholdUsersHelper(db); helper.RemoveUserFromHousehold(id, user); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult UnAssign(AssignUsersViewModel model, int householdId, string userId) { if (ModelState.IsValid) { var household = db.Households.Find(householdId); var user = db.Users.Find(userId); HouseholdUsersHelper helper = new HouseholdUsersHelper(db); helper.RemoveUserFromHousehold(household.Id, user.Id); return(RedirectToAction("Assign", "Households", new { id = household.Id })); } return(View(model)); }
public ActionResult Assign(AssignUsersViewModel model) { var household = db.Households.Find(model.Household.Id); HouseholdUsersHelper helper = new HouseholdUsersHelper(db); foreach (var user in db.Users.Select(r => r.Id).ToList()) { if (model.SelectedUsers != null) { foreach (var item in model.SelectedUsers) { helper.RemoveUserFromHousehold(household.Id, item.Id); } } return(RedirectToAction("Index", "Home")); } return(View(model)); }