public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(EmailModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmailModelExists(EmailModel.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            Users = await _context.User.ToListAsync();

            if (!ModelState.IsValid)
            {
                return(Page());
            }
            if (Users != null)
            {
                foreach (var item in Users)
                {
                    if (!(User1.Email == item.Email || User1.Login == item.Login))
                    {
                        _context.User.Add(User1);
                        await _context.SaveChangesAsync();

                        return(RedirectToPage("../Index"));
                    }
                }
            }


            return(RedirectToPage("../Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.TemplateEmail.Add(TemplatesEmail);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Beispiel #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.EmailModel.Add(EmailModel);
            await _context.SaveChangesAsync();

            EmailService emailService = new EmailService();
            await emailService.SendEmailAsync(EmailModel.To, EmailModel.Subject, EmailModel.Body);

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            EmailModel = await _context.EmailModel.FindAsync(id);

            if (EmailModel != null)
            {
                _context.EmailModel.Remove(EmailModel);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Client = await _context.Client.FindAsync(id);

            if (Client != null)
            {
                _context.Client.Remove(Client);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #7
0
        public async Task <IActionResult> OnPostAsync()
        {
            Client = await _context.Client.ToListAsync();

            templatesEmail = await _context.TemplateEmail.ToListAsync();

            if (!ModelState.IsValid)
            {
                return(Page());
            }
            int i = 0;

            if (Client != null)
            {
                foreach (var item in Client)
                {
                    EmailService emailService = new EmailService();
                    foreach (var temp in templatesEmail)
                    {
                        if (item.ID_template == temp.ID)
                        {
                            EmailModel.Add(new Models.EmailModel());
                            EmailModel[i].Subject  = temp.Subject;
                            EmailModel[i].From     = "*****@*****.**";
                            EmailModel[i].To       = item.Email;
                            EmailModel[i].Body     = temp.Body;
                            EmailModel[i].SendDate = DateTime.Now;
                            _context.EmailModel.Add(EmailModel[i]);
                            await _context.SaveChangesAsync();

                            await emailService.SendEmailAsync(item.Email, item.Theme, temp.Body);

                            i++;
                        }
                    }
                }
            }
            EmailModel = null;
            return(RedirectToPage("./Index"));
        }