Esempio n. 1
0
        public IActionResult DeleteEmail(string e_mail_address)
        {
            try
            {
                if (e_mail_address != string.Empty)
                {
                    int res = _email_repo.Delete(e_mail_address);
                    if (res > 0)
                    {
                        // successfully deleted
                        return(RedirectToActionPermanent("Index", "Home"));
                    }
                    else
                    {
                        //e_mail not exist
                        return(RedirectToActionPermanent("Index", "Home"));
                    }
                }
                else
                {
                    return(RedirectToActionPermanent("Index", "Home"));
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(View());
        }
Esempio n. 2
0
        public ActionResult delete(int id)
        {
            var idbg = _emailRepository.GetById(id);

            _emailRepository.Delete(idbg);
            _unitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public void Update(Contact obj)
        {
            using (var session = _context.OpenSession())
            {
                var contact = session.Get <Contact>(obj.Id);

                if (contact != null)
                {
                    using (var transaction = session.BeginTransaction())
                    {
                        //Contact
                        contact.Name    = obj.Name;
                        contact.Company = obj.Company;
                        contact.Address = obj.Address;

                        session.Save(contact);

                        //Add Telephones
                        foreach (var item in obj.Telephones)
                        {
                            if (!contact.Telephones.Any(x => x.Number == item.Number))
                            {
                                _telephoneRepository.Save(item);
                            }
                        }

                        //Delete Telephones
                        foreach (var item in contact.Telephones)
                        {
                            if (!obj.Telephones.Any(x => x.Number == item.Number))
                            {
                                _telephoneRepository.Delete(item.Id);
                            }
                        }

                        //Add Emails
                        foreach (var item in obj.Emails)
                        {
                            if (!contact.Emails.Any(x => x.EmailAddress == item.EmailAddress))
                            {
                                _emailRepository.Save(item);
                            }
                        }

                        //Delete Emails
                        foreach (var item in contact.Emails)
                        {
                            if (!obj.Emails.Any(x => x.EmailAddress == item.EmailAddress))
                            {
                                _emailRepository.Delete(item.Id);
                            }
                        }

                        transaction.Commit();
                    }
                }
            }
        }
Esempio n. 4
0
 public IHttpActionResult Delete(Guid Id)
 {
     try
     {
         _emailRepository.Delete(Id);
         return(new CustomResponse(HttpStatusCode.OK, null));
     }
     catch (Exception ex)
     {
         return(new CustomResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
Esempio n. 5
0
        private void btn_baja_email_Click(object sender, EventArgs e)
        {
            var email = grillaEmail.SelectedRows[0].DataBoundItem as Email;

            if (email == null)
            {
                MessageBox.Show(this, "Error", "No se selecciono email a eliminar");
                return;
            }
            emailRepository.Delete(email);
            LimpiarCampos();
            RefrescarGrillaEmail();
        }
Esempio n. 6
0
        public bool Invoke(Guid emailId)
        {
            if (emailId == Guid.Empty)
            {
                return(false);
            }

            var emailToDelete = emailRepository.GetById(emailId);

            if (emailToDelete == null)
            {
                return(false);
            }

            emailRepository.Delete(emailToDelete);
            _unitOfWork.Save();

            return(true);
        }
Esempio n. 7
0
        public void ProcessMail(int amountToSend)
        {
            try
            {
                // Get the amount of emails to send in this batch
                var emails = _emailRepository.GetAll(amountToSend);

                // See if there are any
                if (emails != null && emails.Count > 0)
                {
                    // Get the mails settings
                    var settings      = _settingsService.GetSettings(false);
                    var smtp          = settings.SMTP;
                    var smtpUsername  = settings.SMTPUsername;
                    var smtpPassword  = settings.SMTPPassword;
                    var smtpPort      = settings.SMTPPort;
                    var smtpEnableSsl = settings.SMTPEnableSSL;
                    var fromEmail     = settings.NotificationReplyEmail;

                    // If no SMTP settings then log it
                    if (string.IsNullOrEmpty(smtp))
                    {
                        _loggingService.Error("There are no SMTP details in the settings, unable to send emails");
                        return;
                    }

                    // Set up the SMTP Client object and settings
                    var mySmtpClient = new SmtpClient(smtp);
                    if (!string.IsNullOrEmpty(smtpUsername) && !string.IsNullOrEmpty(smtpPassword))
                    {
                        mySmtpClient.Credentials = new NetworkCredential(smtpUsername, smtpPassword);
                    }

                    if (smtpEnableSsl != null)
                    {
                        mySmtpClient.EnableSsl = (bool)smtpEnableSsl;
                    }

                    if (!string.IsNullOrEmpty(smtpPort))
                    {
                        mySmtpClient.Port = Convert.ToInt32(smtpPort);
                    }

                    // List to store the emails to delete after they are sent
                    var emailsToDelete = new List <Email>();

                    // Loop through email email create a mailmessage and send it
                    foreach (var message in emails)
                    {
                        var msg = new MailMessage
                        {
                            IsBodyHtml = true,
                            Body       = message.Body,
                            From       = new MailAddress(fromEmail),
                            Subject    = message.Subject
                        };
                        msg.To.Add(message.EmailTo);
                        mySmtpClient.Send(msg);

                        emailsToDelete.Add(message);
                    }

                    // Loop through the sent emails and delete them
                    foreach (var sentEmail in emailsToDelete)
                    {
                        _emailRepository.Delete(sentEmail);
                    }
                }
            }
            catch (Exception ex)
            {
                _loggingService.Error(ex);
            }
        }
Esempio n. 8
0
 public void UnregisterEmail(string email)
 {
     _emailRepository.Delete(email);
 }
 public void Delete(int id)
 {
     repository.Delete(id);
 }
Esempio n. 10
0
 public async Task DeleteEmailAsync(Email item)
 {
     Repository.Delete(item);
     await Repository.SaveAsync();
 }