public async Task <ActionResult> SendInvitesTousers(InviteUsersEditModel model)
        {
            try
            {
                //var baseurl = "www.elfbuddies.com/";
                //var url = Url.Action("GroupHome", "Groups", new {id = model.GroupId});
                //var resulturl = baseurl + url;
                var groupurlprefix = $"http://elfbuddies.com/Groups/GroupHome/{model.GroupId}?";
                //var groupurlsuffix = model.GroupId + "?";
                //var url = groupurlprefix + groupurlsuffix;
                model.GroupUrl = groupurlprefix;
                var m = await _secretSantaBl.SendInviteToUsersAsync(model).ConfigureAwait(false);

                m.Saved = true;
                return(PartialView("_InviteUsers", m));
            }
            catch (AppException ax)
            {
                ModelState.AddModelError("", ax.AppMessage);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                _log.LogError("", ex);
            }
            return(PartialView("_InviteUsers", model));
        }
        public InviteUsersEditModel SendInviteToUsers(InviteUsersEditModel model)
        {
            var result = new InviteUsersEditModel();

            foreach (var i in model.InviteUsersCollection.UsersToInvite)
            {
                //only send it if the name has been filled out
                if (i.Name != null)
                {
                    Email.DefaultRenderer = new RazorRenderer();

                    //var emailmodel = new EmailMessageModel();
                    //emailmodel.FirstName = "Ben";
                    //emailmodel.LastName = "ONeill";
                    //emailmodel.Message = "Sup yo";
                    var recipient = i.Email;


                    var emailtwo = Email
                                   .From("*****@*****.**")
                                   .To(recipient)
                                   .Subject("Invite To Play")
                                   .UsingTemplateFromFile("Views/Shared/_InviteUsersEmailTemplate.cshtml", i, true);

                    emailtwo.Send();
                }
            }

            return(result);
        }
Exemple #3
0
				public InviteUsersEditModel InviteUsersEditModelByGroupId (int groupid)
				{
					var result = new InviteUsersEditModel ();

					//Assuming that at least 4 people will want to be invited.
					result.InviteUsersCollection = InviteUsersCollectionModelByAmountToGet (4, groupid);

					return result;
				}
Exemple #4
0
				public async Task<InviteUsersEditModel> SendInviteToUsersAsync (InviteUsersEditModel model)
				{
					var result = new InviteUsersEditModel ();

					if (model.InviteUsersCollection.UsersToInvite.All (x => x.Name == null))
						throw new AppException ("You must at least invite 1 person");
					// var email = "*****@*****.**";

					// var please = SendAsync();

					// SendEmailAsync(email, "invite", "do you wanna play");
					//SendSimpleMessge();

					//var message = new MimeMessage();
					//message.From.Add(new MailboxAddress("Santa", "[email protected]  "));
					//message.To.Add(new MailboxAddress("Ben", "*****@*****.**"));
					//message.Subject = "Invite to Elf Buddies!";
					//message.Body = new TextPart("plain")
					//{
					//    Text = "Hello Ben. Want to join elf buddies?"
					//};

					//using (var client = new SmtpClient())
					//{
					//    client.Connect("smtp.example.com", 587, false);
					//    client.AuthenticationMechanisms.Remove("XOAUTH2");
					//    // Note: since we don't have an OAuth2 token, disable 	// the XOAUTH2 authentication mechanism.     client.Authenticate("*****@*****.**", "password");
					//    client.Send(message);
					//    client.Disconnect(true);
					//}

					foreach (var i in model.InviteUsersCollection.UsersToInvite)
						//only send it if the name has been filled out
						if (i.Name != null)
						{
							//This is how it works. keep experimenting 
							i.GroupUrl = model.GroupUrl;
							await SendInviteEmailAsync (i).ConfigureAwait (false);
							////Email.DefaultRenderer = new RazorRenderer();

							////var recipient = i.Email;

							////var emailtwo = Email
							////    .From("*****@*****.**")
							////    .To(recipient)
							////    .Subject("Invite To Play")
							////    .UsingTemplateFromFile("Views/Shared/_InviteUsersEmailTemplate.cshtml", i, true);

							////emailtwo.Send();
						}

					return result;
				}
 public ActionResult SendInvitesTousers(InviteUsersEditModel model)
 {
     try
     {
         var url = Url.Action("GroupHome", "Groups", new { id = model.GroupId });
         model.GroupUrl = url;
         var m = _secretSantaBl.SendInviteToUsers(model);
         m.Saved = true;
         return(PartialView("_InviteUsers", m));
     }
     catch (AppException ax)
     {
         ModelState.AddModelError("", ax.AppMessage);
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         _log.LogError("", ex);
     }
     return(PartialView("_InviteUsers", model));
 }