Beispiel #1
0
        private async Task SendInvitation(int invitationId, InviteBody bodyType)
        {
            var invitation  = db.Invitations.Find(invitationId);
            var userId      = User.Identity.GetUserId();
            var household   = db.Households.Where(h => h.OwnerId == userId).FirstOrDefault();
            var callbackUrl = Url.Action("Register", "Account", null, protocol: Request.Url.Scheme);

            if (InviteBody.CurrentUser == bodyType)
            {
                //must implement a join to household for current users:
                callbackUrl = Url.Action("Login", "Account", null, protocol: Request.Url.Scheme); //, new { email = invitation.RecipientEmail, code = invitation.Code }, protocol: Request.Url.Scheme);
            }
            else if (InviteBody.NonRegisteredEmail == bodyType)
            {
                callbackUrl = Url.Action("ConfirmInvitation", "Account", new { email = invitation.RecipientEmail, code = invitation.Code }, protocol: Request.Url.Scheme);
            }

            //MailGun API EmailSender
            var message = $"<p>{ household.Owner.FullName } has invited you to their Money Portal Household. </p>" +
                          $"<p>\"{ invitation.PersonalMessage }\"</p>";
            var sender = new EmailSender();
            await sender.Execute("You've been invited!", "mp-invitation", invitation.RecipientEmail, new InvitationTemplate(callbackUrl, message, invitation.Code.ToString()));
        }
 /// <summary>
 /// Invite a user to a lab.
 /// </summary>
 /// <remarks>
 /// Operation to invite a user to a lab.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// The request body.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='labName'>
 /// The name of the lab that uniquely identifies it within containing lab
 /// account. Used in resource URIs.
 /// </param>
 /// <param name='userName'>
 /// The name of the user that uniquely identifies it within containing lab.
 /// Used in resource URIs.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task BeginInviteAsync(this IUsersOperations operations, InviteBody body, string resourceGroupName, string labName, string userName, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.BeginInviteWithHttpMessagesAsync(body, resourceGroupName, labName, userName, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Invite a user to a lab.
 /// </summary>
 /// <remarks>
 /// Operation to invite a user to a lab.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// The request body.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='labName'>
 /// The name of the lab that uniquely identifies it within containing lab
 /// account. Used in resource URIs.
 /// </param>
 /// <param name='userName'>
 /// The name of the user that uniquely identifies it within containing lab.
 /// Used in resource URIs.
 /// </param>
 public static void BeginInvite(this IUsersOperations operations, InviteBody body, string resourceGroupName, string labName, string userName)
 {
     operations.BeginInviteAsync(body, resourceGroupName, labName, userName).GetAwaiter().GetResult();
 }