Exemplo n.º 1
0
        public async Task <IActionResult> AnswerEmail(SendReplayViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.RedirectToAction(nameof(this.Index)));
            }

            var result = await this.contactFormService.MarkAsAnsweredAsync(input.Id);

            if (result)
            {
                await this.emailSender.SendEmailAsync(
                    GlobalConstants.SystemEmail,
                    GlobalConstants.AdministratorRoleName,
                    input.Email,
                    input.Subject,
                    input.Answer);
            }

            return(this.RedirectToAction(nameof(this.Index)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AnswerEmail(int emailId)
        {
            var notAnsweredEmail = await this.contactFormService.GetByIdAsync(emailId);

            if (notAnsweredEmail == null)
            {
                return(this.RedirectToAction(nameof(this.Index)));
            }

            var viewModel = new SendReplayViewModel
            {
                Id       = notAnsweredEmail.Id,
                Name     = notAnsweredEmail.Name,
                Email    = notAnsweredEmail.Email,
                Subject  = notAnsweredEmail.Subject,
                Content  = new HtmlSanitizer().Sanitize(notAnsweredEmail.Content),
                Answered = notAnsweredEmail.Answered,
                Answer   = string.Empty,
            };

            return(this.View(viewModel));
        }