예제 #1
0
        public IActionResult Invitation([FromBody] InvitationDto invitationDto)
        {
            try
            {
                if (invitationDto == null)
                {
                    return(NotFound());
                }

                // Retrieving the mail body along with the invitation link.
                var mailBody = _surveyManager.GenerateInvitationMailBody(invitationDto);

                List <string> emailList = invitationDto.Email.Split(';').ToList <string>();
                emailList.Reverse();
                // Sending Invitation to the specific resource mail
                foreach (var email in emailList)
                {
                    // Initiating the mail address
                    _emailManager.To.Add(email);
                }

                // Sending Invitation to the specific resource mail
                _emailManager.Subject = "Talent_Survey_Form";
                _emailManager.Body    = mailBody.ToString();
                var info = _emailManager.Send();
                if (info != "success")
                {
                    var result = new
                    {
                        error      = "error",
                        error_type = "",
                        message    = info
                    };
                    return(BadRequest(result));
                }

                // Storing data regarding Survey invitation
                //Database tables aren't ready yet.

                return(Ok());
            }
            catch (Exception x)
            {
                var result = new
                {
                    error      = x.StackTrace,
                    error_type = x.InnerException,
                    message    = x.Message
                };
                return(BadRequest(result));
            }
        }