Пример #1
0
        public string GenerateHTMLEmail(List <Record> records, DeleteEmailModel emailModel)
        {
            string url     = _appOptions.Value.WebsiteURL + "delete?email=" + emailModel.Email + "&cdate=" + emailModel.CreatedDate.ToString();
            string rawHtml = "";

            rawHtml += @"<!DOCTYPE html>";
            rawHtml += @"<html><head>";
            rawHtml += @"<title>Stundu Izmaiņas Email</title>";
            rawHtml += @"<meta charset='utf-8'>";
            rawHtml += @"<style>.card{max-width: 500px;min-width: 300px;border: #dfe8e1 1px solid;box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);border-radius: 5px;margin: 20px auto;}.section {padding-bottom: 0px;padding-top: 5x;padding-left: 10px;padding-right: 10px;}hr {height:1px;border-width:0;color:#dfe8e1;background-color:#dfe8e1;}.subt {font-weight: bold;color: gray;}p {max-width: 480px;}</style>";
            rawHtml += @"</head><body>";

            rawHtml += @"<div style='text-align:center'>";
            rawHtml += @"<h3 style='margin: 20px'>Jaunākie ieraksti</h3>";
            rawHtml += @"<p style='margin:20px auto 40px auto; font-weight:normal; max-width:500px;'>Šodienas datums - " + DateTime.Today.ToString("D") + "</p>";
            rawHtml += @"</div>";

            foreach (var r in records)
            {
                rawHtml += GenerateCard(r);
            }

            rawHtml += @"<div style='text-align:center'>";
            rawHtml += @"<p style='font-weight:normal; margin:40px auto 20px auto; max-width:500px;'>Plašāka informācija <a href='" + _appOptions.Value.WebsiteURL + "'>Stundu izmaiņu mājaslapā</a> vai mobīlajā aplikācijā.</p>"; //https://www.google.com
            rawHtml += @"<p style='font-weight:normal; margin:20px auto; max-width:500px;'>Lai atteiktos no e-pasta ziņojumiem, spiediet <a href='" + url + "'>šeit</a></p>";                                                       // Lai atteiktos no e-pasta ziņojumiem, dodieties uz <a href='" + _appOptions.Value.WebsiteURL + "'>Stundu izmaiņu mājaslapu</a> un sadaļā <b>Noderīgi</b> nospiediet <b>Atteikties no ziņojumiem</b>
            rawHtml += @"</div>";

            rawHtml += @"</body>";
            rawHtml += @"</html>";
            return(rawHtml);
        }
Пример #2
0
        public async Task <IActionResult> PublishTransfer()
        {
            var emails = await _emailDataService.GetEmailModels();

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

            var records = await _recordTempService.GetTempRecords();

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

            /*
             * var htmlEmailMessage = _emailSendingService.GenerateHTMLEmail(records);
             * _emailSendingService.SendMail(htmlEmailMessage, "Jaunas stundu izmaiņas", true, emails);
             */
            foreach (var e in emails)
            {
                var em = new DeleteEmailModel
                {
                    Email       = e.Email,
                    CreatedDate = e.CreatedDate
                };
                var htmlEmailMessage = _emailSendingService.GenerateHTMLEmail(records, em);
                _emailSendingService.SendMail(htmlEmailMessage, "Jaunas stundu izmaiņas", true, em.Email);
            }

            var transfered = await _recordTempService.TransferChanges();

            if (transfered == false)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Пример #3
0
        public async Task <bool> DeleteEmailModel(DeleteEmailModel emailModel) //string email
        {
            try
            {
                var email    = emailModel.Email;
                var existing = await _emailData.GetEmailByEmail(email);

                var item = existing.FirstOrDefault();
                if (item == null)
                {
                    return(false);
                }

                await _emailData.DeleteEmail(email);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public async Task <IActionResult> Delete([FromRoute] string email)
        {
            var toDelete = await _emailDataService.GetEmailModelByEmail(email);

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

            var emailModel = new DeleteEmailModel
            {
                Email       = email,
                CreatedDate = toDelete.CreatedDate
            };
            var deleted = await _emailDataService.DeleteEmailModel(emailModel);

            if (deleted)
            {
                return(NoContent());
            }

            return(NotFound());
        }