Exemplo n.º 1
0
        public async Task <EmailRequest> SendAccountChange(AccountTypeChangeRequestDTO changeRequest)
        {
            var user = await this._userRepo.Get(GetCurrentUserId());

            if (user == null)
            {
                throw new ArgumentException("Invalid User");
            }

            var builder = _emailBuilderFactory.GetBuilder(
                EmailTypes.ACCOUNT_CHANGE,
                _emailConfig.Value.PassAndId,
                string.Format("{0} {1}", user.Name.FirstName, user.Name.LastName),
                user.DodId,
                changeRequest.EmailAddress,
                changeRequest.AccountTypeName,
                changeRequest.Justification,
                changeRequest.Attachment);

            var emailDirector = _emailBuilderFactory.GetDirector(builder);

            emailDirector.BuildEmailRequest();
            var emailRequest = emailDirector.GetEmailRequest();

            await this._appEmailService.SendAsync(emailRequest);

            return(emailRequest);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AccountTypeChangeRequest([FromForm] AccountTypeChangeRequestDTO changeRequest)
        {
            try {
                var emailRequest = await _emailAppService.SendAccountChange(changeRequest);

                await _logRepo.LogAsync(LogTypes.Email, new LogEntry(GetCurrentUserId(), GetIpAddress(), (int)LogTypes.Email, emailRequest.Subject));

                await _logRepo.SaveAsync();

                return(Ok());
            } catch (Exception e) {
                await _logRepo.LogAsync(LogTypes.Error, new LogEntry(GetCurrentUserId(), GetIpAddress(), (int)LogTypes.Error, e.Message, 0, e.StackTrace));

                await _logRepo.SaveAsync();

                ModelState.AddModelError("Error", e.Message);
                return(BadRequest(ModelState));
            }
        }