示例#1
0
        public async Task <IActionResult> Reply(MailReplyViewModel model)
        {
            if (model == null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            if (model.InReplyToId == null)
            {
                return(RedirectToAction("Index"));
            }
            if (ModelState.IsValid)
            {
                var mail = new Mail
                {
                    Subject     = model.Subject,
                    Body        = model.Body,
                    InReplyToId = model.InReplyToId
                };
                await _mailService.MCSendReplyAsync(mail);

                AlertSuccess = $"Reply \"<strong>{mail.Subject}</strong>\" sent";
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
示例#2
0
        public async Task <IActionResult> Reply(int id)
        {
            try
            {
                var mail = await _mailService.GetDetails(id);

                if (mail.ToUserId == null)
                {
                    var participant = await _userService.GetDetailsByPermission(mail.FromUserId);

                    string participantLink =
                        Url.Action("Detail", "Participants", new { id = participant.Id });
                    string participantName = participant.FullName;
                    if (!string.IsNullOrEmpty(participant.Username))
                    {
                        participantName += $" ({participant.Username})";
                    }

                    var viewModel = new MailReplyViewModel
                    {
                        Subject          = $"Re: {mail.Subject}",
                        InReplyToId      = mail.Id,
                        InReplyToSubject = mail.Subject,
                        InReplyToBody    = mail.Body,
                        ParticipantLink  = participantLink,
                        ParticipantName  = participantName
                    };

                    return(View(viewModel));
                }
                else
                {
                    return(RedirectToAction("Detail", new { id }));
                }
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to view mail: ", gex);
                return(RedirectToAction("Index"));
            }
        }