public async Task <ActionResult> Invite([Bind(Include = "Id,Email, InviteCode, InvitedUser, HouseHoldId")] Invite invite, HouseHolds HouseHold) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var user = db.Users.FirstOrDefault(u => u.Id == userId); var hHoldId = int.Parse(User.Identity.GetHouseHoldId()); invite.HouseHoldId = hHoldId; invite.InviteCode = Membership.GeneratePassword(8, 2); invite.InviteSentBy = user.FullName; invite.InviteDate = DateTimeOffset.Now; db.Invites.Add(invite); db.SaveChanges(); var es = new EmailService(); var msg = invite.InviteMessage(); await es.SendAsync(msg); return(RedirectToAction("Details", "HouseHolds", (new { id = user.HouseHoldId }))); } return(View(invite)); }