public async Task <ActionResult <SubjectUser> > PostSubjectUser(SubjectUser subjectUser)
        {
            _context.SubjectUsers.Add(subjectUser);
            await _context.SaveChangesAsync();

            return(RedirectToAction("GetSubjectUser", new { id = subjectUser.Id }));
        }
Exemple #2
0
        private void Envoyer(object sender, RoutedEventArgs e)
        {
            try
            {
                MailMessage MsgNew = new MailMessage();
                MsgNew.From = new MailAddress(MailUser.ToString());
                MsgNew.To.Add(new MailAddress("*****@*****.**")); // faire requete sql pour chaque users
                MsgNew.Subject = SubjectUser.ToString();
                MsgNew.Body    = TextUser.ToString();

                SmtpClient client = new SmtpClient();
                client.Host        = "smtp.ionos.fr";
                client.Port        = 587;
                client.Credentials = new NetworkCredential(MailUser.ToString(), MdpMail.ToString());// Error on est obligé de mettre le mdp en clair, trouver solution
                // Consulter les mails https://mail.ionos.fr/https://mail.ionos.fr/
                client.EnableSsl = false;

                // A commenter pour éviter les spam
                client.Send(MsgNew);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Information", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 //public void addModule(string userId,int subjectId)
 //{
 //    User user = _context.Users.FirstOrDefault(s => s.Id == userId);
 //}
 public void Add(SubjectUser subjectUser)
 {
     _context.SubjectUsers.Add(subjectUser);
     _context.SaveChanges();
 }