Esempio n. 1
0
 public IActionResult OnPost()
 {
     if (ModelState.IsValid)
     {
         if (CheckIn.Id > 0)
         {
             CheckIn = checkinRepository.Update(CheckIn);
         }
         else
         {
             CheckIn = checkinRepository.Add(CheckIn);
         }
         return(RedirectToPage("AddConfirmed"));
     }
     return(Page());
 }
Esempio n. 2
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                if (CheckIn.Id > 0)
                {
                    CheckIn = checkinRepository.Update(CheckIn);
                    if (CheckIn.Status == Status.OnSiteWait)
                    {
                        Task t = Task.Run(async() =>
                        {
                            //_mailSender.Send(email);
                            var body = $@"{CheckIn.Name}, please make your way to the Barber Shop.";

                            using (var smtp = new SmtpClient())
                            {
                                var credential = new NetworkCredential
                                {
                                    UserName = "******",
                                    Password = "******"
                                };
                                smtp.Credentials = credential;
                                smtp.Host        = "smtp.gmail.com";
                                smtp.Port        = 587;
                                smtp.EnableSsl   = true;
                                var msg          = new MailMessage();
                                msg.Body         = body;
                                msg.Subject      = "Please make your way to the baber shop";
                                msg.From         = new MailAddress("*****@*****.**");
                                msg.To.Add(CheckIn.PhoneNumber);
                                await smtp.SendMailAsync(msg);
                            }
                        });
                        t.Wait();
                        return(RedirectToPage("Index"));
                    }
                }
                else
                {
                    CheckIn = checkinRepository.Add(CheckIn);
                }

                return(RedirectToPage("Index"));
            }
            return(Page());
        }