public ActionResult InviteMember(InviteMemberForm form) { var targetUser = _users.Query().FirstOrDefault(u => u.EmailAddress == form.EmailAddress); if (targetUser == null) { return View().WithErrorMessage( "Sorry, that user does not have a Fail Tracker account. Ask them to create an account first!"); } var project = _projects.Query().Single(p => p.ID == form.ProjectID); //TODO: Should this require the current user? Is the domain rule "only owner of a project can add new members"? //TODO: We still want to prevent users who don't have access to an issue/project from even seeing it in the first place... project.AddMember(targetUser); //TODO: Move this out of the controller, it is horribly hacky. try { using (var client = new SmtpClient()) { client.Send("*****@*****.**", targetUser.EmailAddress, "You've been added to a project in Fail Tracker!", "Welcome to the " + project.Name + " project!"); } } //If mail sending fails, it doesn't really matter... catch { } return this.RedirectToAction(c => c.InviteMember(form.ProjectID)) .WithSuccessMessage("The user has been added to the project."); }
public ActionResult InviteMember(InviteMemberForm form) { var targetUser = _users.Query().FirstOrDefault(u => u.EmailAddress == form.EmailAddress); if (targetUser == null) { return View().WithErrorMessage( "Sorry, that user does not have a Fail Tracker account. Ask them to create an account first!"); } var project = _projects.Query().Single(p => p.ID == form.ProjectID); //TODO: Should this require the current user? Is the domain rule "only owner of a project can add new members"? //TODO: We still want to prevent users who don't have access to an issue/project from even seeing it in the first place... project.AddMember(targetUser); return this.RedirectToAction(c => c.InviteMember(form.ProjectID)) .WithSuccessMessage("The user has been added to the project."); }