예제 #1
0
        public AdRequestModel RequestAds(AdRequestModel model)
        {
            AdRequestModel result = new AdRequestModel();

            result.Email        = model.Email;
            result.CanRequestAd = false;

            List <BaseAd> ads = _adRepository.GetAdsByEmail(model.Email).ToList();

            if (ads.Count == 0)
            {
                result.InfoMessage = "Cette adresse email ne correspond aucune annonce.";
                return(result);
            }

            IDictionary <String, String> data = new Dictionary <String, String>();

            data.Add("name", ads[0].CreatedBy.Firstname);
            data.Add("adCount", ads.Count.ToString());
            data.Add("websiteAddress", _settingsProvider.WebsiteAddress);
            data.Add("websiteName", _settingsProvider.WebsiteName);

            IDictionary <String, object[]> list = new Dictionary <String, object[]>();

            list.Add("ads", ads.ToArray());

            String subject = "BEA Vos Annonces";
            String body    = _templatingServices.GetTemplatedDocument("AdsRequestEmail.vm", data, list);

            _emailServices.SendEmail(subject, body, model.Email, "*****@*****.**");

            result.InfoMessage = "Un email vient de vous etre envoyé avec la liste de vos annonces";

            return(result);
        }
예제 #2
0
        public async Task <ActionResult> Update([Bind("Id,BuildingCode,Description,CurrentStatus,CreatedBy,CreatedDate,LastModifiedBy,LastModifiedDate")] ServiceModel _serviceModel)
        {
            var serviceModel = _context.Services.Where(m => m.Id == _serviceModel.Id).ToArray().FirstOrDefault();

            if (serviceModel == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(serviceModel.Copy(_serviceModel));
                    await _context.SaveChangesAsync();

                    if (_serviceModel.CurrentStatus == CurrentStatus.Canceled || _serviceModel.CurrentStatus == CurrentStatus.Complete)
                    {
                        _emailServices.SendEmail(serviceModel);
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }
            return(Ok());
        }
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            data = _Userservices.Getuserbyemail(User.Email);
            if (data != null)
            {
                if (data.ConfirmEmail == true)
                {
                    string emailUrl = "http://localhost:53951/Registration/ResetPass" + "?id=" + data.ActivationCode;

                    _emailServices.SendEmail(User.Email, CreateEmailMessage(emailUrl), "Registration");
                    return(RedirectToPage("./Login"));
                }
                else
                {
                    Msg = "You need to Activate Your Account";
                }
            }
            else
            {
                Msg = "Email id  is not exist ";
            }


            return(Page());
        }
예제 #4
0
        public void SendEmailToUser(ContactAdModel model)
        {
            String subject = String.Format("{0} - Notification : \"{1}\"", _appSettingsProvider.WebsiteName, model.AdTitle);
            String body    = String.Format("Bonjour,"
                                           + "un utilisateur du site {0}, {1}, vous envoie le message suivant. Vous pouvez lui repondre directement à partir de cet email ou par telephone: {2}.\n\n"
                                           + "---------------------------------------------------------------\n\n"
                                           + model.EmailBody + "\n\n"
                                           + "---------------------------------------------------------------\n\n"
                                           + "http://www.{0}/Post/Details/{3}", _appSettingsProvider.WebsiteAddress, model.Name, (String.IsNullOrEmpty(model.Telephone)) ? "non communiqué" : model.Telephone, model.AdId);

            _emailService.SendEmail(subject, body, model.EmailTo, model.Email);
        }
예제 #5
0
        public void SendActivationEmail(BaseAd ad)
        {
            IDictionary <String, String> data = new Dictionary <String, String>();

            data.Add("name", ad.CreatedBy.Firstname);
            data.Add("title", ad.Title);
            data.Add("id", ad.Id.ToString());
            data.Add("activationToken", ad.ActivationToken);
            data.Add("websiteAddress", _appSettingsProvider.WebsiteAddress);
            data.Add("websiteName", _appSettingsProvider.WebsiteName);

            String subject = String.Format("BEA Activez votre annonce \"{0}\"", ad.Title);
            String body    = _templatingService.GetTemplatedDocument("ActivationEmail.vm", data);

            _emailService.SendEmail(subject, body, ad.CreatedBy.Email, "*****@*****.**");
        }
예제 #6
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var keys = _encrypt.key;

            User.Password       = Utility.EncryptString(User.Password, keys);
            User.ActivationCode = System.Guid.NewGuid().ToString();
            string emailUrl = "http://localhost:53951/Registration/verify" + "?id=" + User.ActivationCode;

            _emailServices.SendEmail(User.Email, CreateEmailMessage(emailUrl), "Registration");
            _context.User.Add(User);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Login"));
        }
        public async Task <ActionResult> SendEmail(EmailModel m)
        {
            await _emailService.SendEmail("*****@*****.**", "*****@*****.**", "Email Api Development", "I will like to test my api");

            return(Ok());
        }
예제 #8
0
        public async Task <ActionResult> SendEmail([FromBody] EmailModel m)
        {
            await _emailService.SendEmail(m.To, m.Cc, m.Subject, m.Message);

            return(Ok());
        }
 async Task INotificationHandler <LoanEffetivatedEvent> .Handle(LoanEffetivatedEvent notification, CancellationToken cancellationToken)
 {
     await _emailServices.SendEmail(new List <string> {
         notification.Email
     }, "Book loan", $"Book {notification.BookName} lent, expected return date {notification.ReturnDate.ToShortDateString()}");
 }