示例#1
0
        public ActionResult CreateQuiz(int id)
        {
            Quiz pe = new Quiz();

            pe.FormationId = id;
            pe.Score       = 0;
            pe.Type        = "En cours";
            Ps.Add(pe);
            Ps.Commit();
            var message1 = new MimeMessage();

            message1.From.Add(new MailboxAddress("*****@*****.**"));
            message1.To.Add(new MailboxAddress("*****@*****.**"));
            message1.Subject = "Application";
            message1.Body    = new TextPart("plain")
            {
                Text = "Dear Employe, \nYour Quiz has been successfully registered on " + DateTime.Now + ". We will come back to you to indicate the date of the interview and the quiz. \n Best regards."
            };
            using (var client = new SmtpClient())
            {
                client.Connect("smtp.gmail.com", 465, true);
                client.AuthenticationMechanisms.Remove("XOAUTH");
                client.Authenticate("*****@*****.**", "At066bn1!");
                client.Send(message1);
                client.Disconnect(true);
            }
            // Use your account SID and authentication token instead
            // of the placeholders shown here.
            const string accountSID = "ACcb5274125fc2ebcbc47aef71d5738ac4";
            const string authToken  = "429ff7a2f0c90a0800d964bfbd1830e4";

            // Initialize the TwilioClient.
            TwilioClient.Init(accountSID, authToken);

            // Use the Twilio-provided site for the TwiML response.
            var url = "https://twimlets.com/message";

            url = $"{url}?Message%5B0%5D=Hello%20World";


            try
            {
                // Send an SMS message.
                var message = MessageResource.Create(
                    to: new PhoneNumber("+21621646533"),
                    from: new PhoneNumber("+15628884113"),
                    body: "Your application has been validated successfully \nThe " + DateTime.Now + "\n We will come back to you in order to pass your quiz \n Best regards.");
            }
            catch (TwilioException ex)
            {
                // An exception occurred making the REST call
                Console.WriteLine(ex.Message);
            }
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult Create(quizModel qzv)
        {
            try
            {
                //  if (ModelState.IsValid)
                //  {
                quiz q = new quiz();
                q.QuizName = qzv.QuizName;
                //   q.formation = (System.Collections.Generic.ICollection<Data.formation>)qzv.formation;
                q.id_Quiz          = qzv.id_Quiz;
                q.formation_id_for = qzv.formation_id_for;

                qz.Add(q);
                qz.Commit();
                // return RedirectToAction("Create", "Question", new { id = "id_Quiz", otherParam = "foo" });
                //  }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult <QuizQuery> Adicionar([FromBody] AddQuizCommand command)
 {
     return(Created("quizzes", _quizService.Add(command)));
 }