Пример #1
0
        public ActionResult Send(string receivermail, string subject, string message, string cCMail)
        {
            SessionKontrol();
            if (_users != null)
            {
                var emailsettings = _EmailSettingsServices.Get(1);

                bool isItSended = _MailHelper.Send(receivermail, subject, message, cCMail, emailsettings.Username, emailsettings.Password, emailsettings.Host, emailsettings.Port, emailsettings.Mail);

                if (isItSended)
                {
                    EmailHistoryViewModel ehvm = new EmailHistoryViewModel();
                    ehvm.ReceiverMail = receivermail;
                    ehvm.Subject      = subject;
                    ehvm.Message      = message;

                    _EmailHistoryServices.Add(ehvm);
                    _unitOfWork.SaveChanges();
                }


                return(RedirectToAction("Index", "Email"));
            }
            else
            {
                return(RedirectToAction("Index", "Login"));
            }
        }
        public void Add(EmailHistoryViewModel viewModel)
        {
            _repository.Add(new EmailHistory
            {
                CreationDate = DateTime.Now,
                IsItDeleted  = false,
                Status       = true,
                SiteLanguage = viewModel.SiteLanguage,

                Subject      = viewModel.Subject,
                ReceiverMail = viewModel.ReceiverMail,
                Message      = viewModel.Message
            });
        }