Ejemplo n.º 1
0
        public IActionResult FormSubmit([FromBody] SurveyFormDto surveyFromDto)
        {
            try
            {
                if (surveyFromDto == null)
                {
                    return(NotFound());
                }
                // Retrieving the mail body along with the questions and provided feedback.
                var mailBody = _surveyManager.GenerateSurveyMailBody(surveyFromDto);

                List <string> emailList = surveyFromDto.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 mail to that specific person's mail by whom the survey feedback is provided.
                _emailManager.Subject = "Talent_Survey_Form";
                _emailManager.Body    = mailBody.ToString();
                _emailManager.Send();

                // Storing data regarding Survey feedback.
                //Database tables aren't ready yet!
                return(Ok());
            }
            catch (Exception x)
            {
                var result = new
                {
                    error      = x.StackTrace,
                    error_type = x.InnerException,
                    message    = x.Message
                };
                // Returning Exception object.
                return(BadRequest(result));
            }
        }