Esempio n. 1
0
        public async Task <ActionResult> AdminReplyRequest(CreateSupportRequestReplyModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("AdminReplyRequestModal", model));
            }

            var result = await SupportWriter.AdminCreateSupportRequestReply(User.Id(), model);

            if (!ModelState.IsWriterResultValid(result))
            {
                return(View("AdminReplyRequestModal", model));
            }

            return(CloseModalRedirect(Url.Action("Index", "Admin") + "#Support"));
        }
Esempio n. 2
0
        public async Task <IWriterResult <bool> > AdminCreateSupportRequestReply(string userId, CreateSupportRequestReplyModel model)
        {
            using (var context = DataContextFactory.CreateContext())
            {
                var ticket = await context.SupportRequest.FirstOrDefaultNoLockAsync(x => x.Id == model.RequestId);

                if (ticket == null)
                {
                    return(WriterResult <bool> .ErrorResult("Support request #{0} not found", model.RequestId));
                }

                var sentEmail = await EmailService.SendRaw($"RE: Support request #{model.RequestId}", model.Message, model.Email);

                if (!sentEmail)
                {
                    return(WriterResult <bool> .ErrorResult($"Failed to send email to {model.Email}"));
                }

                ticket.Replied = true;
                await context.SaveChangesAsync();

                return(WriterResult <bool> .SuccessResult());
            }
        }