Ejemplo n.º 1
0
        public async Task OnGet()
        {
            IEnumerable <MeetDetailsModel> meets = await _meetsService.RetrieveMeets();

            if (meets == null)
            {
                return;
            }

            if (Request.Query.ContainsKey("leader"))
            {
                html = FullScheduleEmailBuilder
                       .Build(
                    meets
                    .Where(m =>
                           m
                           .LeaderField()
                           .Value
                           .Equals(Request.Query["leader"], StringComparison.OrdinalIgnoreCase)),
                    $@"{_hostingEnvironment.WebRootPath}\templates");
            }
            else
            {
                html = FullScheduleEmailBuilder.Build(
                    meets,
                    $@"{_hostingEnvironment.WebRootPath}\templates");
            }
        }
Ejemplo n.º 2
0
        public async Task OnGet()
        {
            IEnumerable <MeetDetailsModel> meets = await _meetsService.RetrieveMeets(DateTime.Now.Date);

            if (meets == null)
            {
                return;
            }

            bool printerFriendly           = Request.Query.ContainsKey("printerFriendly");
            bool hideHeaderAndFooterImages = Request.Query.ContainsKey("hideHeaderAndFooter");

            if (printerFriendly)
            {
                Html = BuildPrinterFriendlyHtml(meets);
            }
            else
            {
                Html = FullScheduleEmailBuilder.Build(
                    meetsDetails: meets,
                    templatesPath: $@"{_hostingEnvironment.WebRootPath}\templates",
                    previewMode: false,
                    showHeaderAndFooterImages: !hideHeaderAndFooterImages);
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> SendFullScheduleToAddress(EmailContent emailContent)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(emailContent.Address))
                {
                    return(BadRequest("Address cannot be empty"));
                }

                if (string.IsNullOrWhiteSpace(emailContent.Subject))
                {
                    return(BadRequest("Subject cannot be empty"));
                }

                if (string.IsNullOrWhiteSpace(emailContent.Body))
                {
                    return(BadRequest("Email body cannot be empty"));
                }

                if (string.IsNullOrWhiteSpace(emailContent.SendMeetsUpUntilThisDate) ||
                    !DateTime.TryParse(
                        emailContent.SendMeetsUpUntilThisDate,
                        out DateTime latestDate))
                {
                    return(BadRequest($"Meets date range is invalid: \"{emailContent.SendMeetsUpUntilThisDate}\"."));
                }

                string[] emailAddresses = emailContent.Address.Split(';');

                IEnumerable <MeetDetailsModel> meets = await _meetsService.RetrieveMeets(
                    DateTime.Now,
                    latestDate);

                string emailBody = FullScheduleEmailBuilder.Build(
                    meets,
                    $@"{_hostingEnvironment.WebRootPath}\templates",
                    emailContent.Body,
                    _meetsPageUrl,
                    false);

                _logger.LogInfo($"Sending full schedule email to address \"{emailAddresses.Join(";")}\"...", ClassName);

                _emailSenderService.Send(
                    emailContent.Subject,
                    emailBody,
                    emailAddresses);
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception while sending full schedule email to address.", ClassName, ex);
                return(StatusCode(500, ex.Message));
            }

            return(new JsonResult(Ok()));
        }
Ejemplo n.º 4
0
        public async Task OnGet()
        {
            IEnumerable <MeetDetailsModel> meets;

            if (Request.Query.ContainsKey("leader"))
            {
                meets = await _meetsService.RetrieveMeets(Request.Query["leader"]);
            }
            else
            {
                meets = await _meetsService.RetrieveMeets(DateTime.Now);
            }

            if (meets == null)
            {
                return;
            }

            Html = FullScheduleEmailBuilder.Build(
                meets,
                $@"{_hostingEnvironment.WebRootPath}\templates");
        }
Ejemplo n.º 5
0
        public async Task OnGet()
        {
            IEnumerable <MeetDetailsModel> meets = await _meetsService.RetrieveMeets();

            PopulateLeaderNames(meets);
        }