public async Task <IActionResult> Create([Bind("Email, FirstName, LastName, CompanyName, CompanyDescription, ProjectName, ProjectDescription")] InviteViewModel inviteViewModel) { if (ModelState.IsValid) { var userId = await _inviteService.InviteWizardAsync(inviteViewModel); var companyId = _context.Companies.FirstOrDefault(c => c.Name == inviteViewModel.CompanyName).Id; var invite = new Invite { Email = inviteViewModel.Email, CompanyId = companyId, InviteDate = DateTime.Now, IsValid = true, InvitorId = _userManager.GetUserId(User), InviteeId = userId, CompanyToken = Guid.NewGuid() }; _context.Add(invite); await _context.SaveChangesAsync(); var code = invite.CompanyToken; var callbackUrl = Url.Action( "AcceptInvite", "Tickets", values: new { userId, code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(invite.Email, "Join my Bug Tracker", $"Create a ticket in my bug tracker by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); return(RedirectToAction(nameof(Index))); } return(View(inviteViewModel)); }