public ActionResult InviteUser(Peanut peanut, PeanutInvitationCreateCommand peanutInvitationCreateCommand, User currentUser) { Require.NotNull(peanut, "peanut"); Require.NotNull(peanutInvitationCreateCommand, "peanutInvitationCreateCommand"); Require.NotNull(currentUser, "currentUser"); if (peanut.IsFixed) { return(View("CanNotInvite", new PeanutParticipationRejectedViewModel(peanut))); } string peanutUrl = Url.Action("Show", "Peanut", new { peanut = peanut.BusinessId }, Request.Url.Scheme); string attendPeanutUrl = Url.Action("AttendForm", "Peanut", new { peanut = peanut.BusinessId }, Request.Url.Scheme); if (peanutInvitationCreateCommand.UserGroupMembership != null) { PeanutService.InviteUser(peanut, peanutInvitationCreateCommand.UserGroupMembership, new PeanutParticipationDto(peanutInvitationCreateCommand.PeanutParticipationType, PeanutParticipationState.Pending), new PeanutInvitationNotificationOptions(peanutUrl, attendPeanutUrl), currentUser); } else { PeanutService.InviteAllGroupMembers(peanut, peanut.UserGroup, peanutInvitationCreateCommand.PeanutParticipationType, new PeanutInvitationNotificationOptions(peanutUrl, attendPeanutUrl), currentUser); } return(RedirectToAction("Show", new { peanut = peanut.BusinessId })); }