public async Task Create_UserIdIsNotSet_SetsCorrectResourceAndMethod()
        {
            var sut = new EmailRepository(_requestFactory);

            await sut.Create("email");

            _requestFactory.Received().Create("user/emails", Method.Post);
        }
        public async Task Create_ValidParameters_AddsEmailParameter()
        {
            const string expected = "email";
            var          sut      = new EmailRepository(_requestFactory);

            await sut.Create(expected);

            _request.Received().AddParameter("email", expected);
        }
        public async Task Create_UserIdIsSet_SetsCorrectResourceAndMethod()
        {
            const uint expected = 0;
            var        sut      = new EmailRepository(_requestFactory);

            await sut.Create("email", expected);

            _requestFactory.Received().Create("users/{userId}/emails", Method.Post);
        }
        public async Task Create_UserIdIsSet_AddsUserIdUrlSegment()
        {
            const uint expected = 0;
            var        sut      = new EmailRepository(_requestFactory);

            await sut.Create("email", expected);

            _request.Received().AddUrlSegmentIfNotNull("userId", expected);
        }
Esempio n. 5
0
        public void Create(PessoaDto Pessoa)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                IRepository <NomeModel> nomeRepository = new NomeRepository();
                nomeRepository.Create(Pessoa.Nome);

                IRepository <SobrenomeModel> sobrenomeRepository = new SobrenomeRepository();
                sobrenomeRepository.Create(Pessoa.Sobrenome);

                IRepository <EmailModel> emailRepository = new EmailRepository();
                emailRepository.Create(Pessoa.Email);

                scope.Complete();
            }
        }
Esempio n. 6
0
        //public string CreateTemplate(string subject, int typeEmail, string content)
        //{
        //    var res = string.Empty;
        //    EmailRepository.Create(subject,typeEmail,content);
        //    return res;
        //}

        public string CreateTemplate(FormDataCollection form)
        {
            var res       = string.Empty;
            var subject   = form.Get("Subject");
            int typeEmail = Int32.Parse(form.Get("TypeEmail"));
            var content   = form.Get("Content");

            var entity = new EmailInfo
            {
                Content   = content,
                Subject   = subject,
                EmailType = typeEmail,
            };

            EmailRepository.Create(entity);
            return(res);
        }
Esempio n. 7
0
        public void InsertSaveBooking(Schedule m, int d)
        {
            string nat = new PatientRepository().GetById(d).NationalId;

            using (var bookpro = new BookingRepository())
            {
                Booking _b = bookpro.GetAll().Last(x => x.PatientID.Equals(nat));

                _b.Time_start    = m.start_date;
                _b.Time_end      = m.end_date;
                _b.bookingStatus = "Booked";
                bookpro.Update(_b);
            }
            var p = new PatientRepository().GetAll().Find(x => x.PatientId == d);

            using (var emailrepo = new EmailRepository())
            {
                List <MailAddress> l    = new List <MailAddress>();
                MailMessage        mail = new MailMessage();

                mail.To.Add(new MailAddress(p.Email));
                mail.From = new MailAddress("*****@*****.**");
                mail.CC.Add(new MailAddress("*****@*****.**"));
                mail.Bcc.Add(new MailAddress("*****@*****.**"));
                mail.Subject = "Appointment with the Doctor";
                string Body = "Dear " + p.FullName + " we are glad to inform you that your appointment to see the doctor has been schedule on the "
                              + m.start_date.Substring(0, 10) + " from " + m.start_date.Substring(10) + " to " + m.end_date.Substring(10);
                mail.Body       = Body;
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                #region configurations is in the web.config
                // smtp.Host = "localhost";//"smtp.live.com";
                //// smtp.Host = "smtp.live.com";

                // smtp.Port = 25; //587;
                // // smtp.Port=587;

                #endregion


                smtp.Host = "smtp.sendgrid.net";
                smtp.Port = 2525;
                smtp.UseDefaultCredentials = false;
                smtp.EnableSsl             = true;
                smtp.Credentials           = new System.Net.NetworkCredential("bigiayomide", "123adenike");// enter seders user name and password



                smtp.Send(mail);

                Email_services _email = new Email_services
                {
                    emailID = 0,
                    To      = p.Email,
                    //Cc = "*****@*****.**",
                    //Bcc = "*****@*****.**",
                    Subject   = "Appointment with the Doctor",
                    StaffName = "sam",
                    Body      = Body
                };

                emailrepo.Create(_email);
            }
        }
        public async Task Create_EmailIsNull_ThrowsArgumentNullException()
        {
            var sut = new EmailRepository(_requestFactory);

            await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Create(null));
        }
Esempio n. 9
0
        public void createemail(Email_serviceViewModel emails)//, HttpPostedFileBase fileUploader)
        {
            PatientBusiness dbl = new PatientBusiness();

            using (var emailrepo = new EmailRepository())
            {
                List <MailAddress> l    = new List <MailAddress>();
                MailMessage        mail = new MailMessage();


                if (emails.To == null)
                {
                    foreach (Patient f in dbl.GetPatients())//for each friend
                    {
                        //get the email address and convert to MailAddress
                        l.Add(new MailAddress(f.Email));//add to the list of receivers
                    }

                    to = l;

                    foreach (MailAddress ma in to) //get each MailAddress in the list
                    {
                        mail.To.Add(ma);           //use to set the to list
                        Email_services _email = new Email_services
                        {
                            emailID   = emails.emailID,
                            To        = ma.ToString(),
                            Cc        = emails.Cc,
                            Bcc       = emails.Bcc,
                            Subject   = emails.Subject,
                            StaffName = emails.StaffName,
                            Body      = emails.Body
                        };

                        emailrepo.Create(_email);
                    }



                    //mail.To.Add(l);
                }

                else
                {
                    string[] ToMuliId = emails.To.Split(',');
                    foreach (string ToEMailId in ToMuliId)
                    {
                        mail.To.Add(new MailAddress(ToEMailId)); //adding multiple TO Email Id
                    }
                }

                /*mail.To.Add(emails.To);*/

                mail.From = new MailAddress("*****@*****.**");
                if (!string.IsNullOrEmpty(emails.Cc))
                {
                    string[] CCId = emails.Cc.Split(',');
                    foreach (string CCEmail in CCId)
                    {
                        mail.CC.Add(new MailAddress(CCEmail)); //Adding Multiple CC email Id
                    }
                }
                if (!string.IsNullOrEmpty(emails.Bcc))
                {
                    string[] bccid = emails.Bcc.Split(',');
                    foreach (string bccEmailId in bccid)
                    {
                        mail.Bcc.Add(new MailAddress(bccEmailId)); //Adding Multiple BCC email Id
                    }
                }
                #region

                /* if (emails.Cc == null)
                 * {
                 *  mail.CC.Add("*****@*****.**");
                 * }
                 * else
                 * {
                 *  string[] CCId = emails.Cc.Split(',');
                 *  foreach (string CCEmail in CCId)
                 *  {
                 *
                 *      mail.CC.Add(new MailAddress(CCEmail)); //Adding Multiple CC email Id
                 *  }
                 * }*/

                /*  if (emails.Bcc == null)
                 * {
                 *    mail.Bcc.Add("*****@*****.**");
                 * }
                 * else
                 * {
                 *    string[] bccid = emails.Bcc.Split(',');
                 *    foreach (string bccEmailId in bccid)
                 *    {
                 *
                 *          mail.Bcc.Add(new MailAddress(bccEmailId)); //Adding Multiple BCC email Id
                 *    }
                 *
                 * }
                 */
                #endregion
                #region
                //else
                //{
                //    mail.CC.Add(emails.Cc);
                //}
                //if (emails.Bcc == null)
                //{
                //    mail.Bcc.Add("*****@*****.**");
                //}
                //else
                //{
                //    mail.Bcc.Add(emails.Bcc);
                //}
                #endregion

                if (!string.IsNullOrEmpty(emails.Subject))
                {
                    mail.Subject = emails.Subject;
                }

                /* if (emails.Subject == null)
                 * {
                 *   mail.Subject = "No subject";
                 * }
                 * else
                 * {
                 *   mail.Subject = emails.Subject;
                 * }
                 */
                string Body = emails.Body;
                mail.Body = Body;

                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                #region configurations is in the web.config

                /* smtp.Host = "localhost";//"smtp.live.com";
                 * //smtp.Host = "smtp.live.com";
                 *
                 * smtp.Port = 25; //587;
                 * // smtp.Port=587;
                 */
                #endregion


                smtp.Host = "smtp.sendgrid.net";
                smtp.Port = 2525;
                smtp.UseDefaultCredentials = false;
                smtp.EnableSsl             = true;
                smtp.Credentials           = new System.Net.NetworkCredential("bigiayomide", "123adenike");// enter seders user name and password



                smtp.Send(mail);

                if (emails.emailID == 0)
                {
                    Email_services _email = new Email_services
                    {
                        emailID   = emails.emailID,
                        To        = emails.To,
                        Cc        = emails.Cc,
                        Bcc       = emails.Bcc,
                        Subject   = emails.Subject,
                        StaffName = emails.StaffName,
                        Body      = emails.Body
                    };

                    emailrepo.Create(_email);
                }
            }
        }