Beispiel #1
0
        public async Task <IActionResult> SendConfirmation([FromBody] LoginModel signup)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var id              = PasswordSecurity.HashEmail(signup.Email);
                    var code            = PasswordSecurity.HashEmail(signup.Password);
                    var callbackUrl     = Url.Action(nameof(Confirm), "Email", new { userId = id, code = code }, protocol: HttpContext.Request.Scheme);
                    var applicationUser = new ApplicationUser {
                        UserId = id, Email = signup.Email, Code = code
                    };
                    await _context.AddAsync(applicationUser);

                    await _context.SaveChangesAsync();

                    _emailManager.Send(signup.Email, "Confirm your account", $"Please confirm your account by clicking <a href='{callbackUrl}'>here</a>");
                    return(Ok());
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("Errors", "There was a problem with the email client");
                    throw(e);
                }
            }
            return(BadRequest());
        }
Beispiel #2
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));
            }
        }
Beispiel #3
0
        public async Task <IActionResult> EmailContatti([FromBody] MailContattiDto mailContattiDto)
        {
            try
            {
                if (mailContattiDto == null)
                {
                    return(NotFound());
                }
                // Sending email to the specific resource mail
                _emailManager.To.Add(mailContattiDto.Email);
                _emailManager.Subject = "Talent_Contatti";
                _emailManager.Body    = mailContattiDto.Body;
                _emailManager.Send();

                // creating the azioni object passing the related details and description.
                var azioniDto = _utilityManager.GetAzioniDtoObject(User, "email", "contatti");
                // logging the activity record by the user.
                await _azioniManager.AzioniInsert(azioniDto);

                return(Ok());
            }
            catch (Exception x)
            {
                // Code block of Exception handling and logging into log_operazione table.
                var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Send Email Contatti");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public async Task <bool> SendPasswordResetEmail(string email)
        {
            var user = await Context.Users.FirstOrDefaultAsync(u => u.Email == email && !u.IsVerified);

            if (user == null)
            {
                return(false);
            }

            var token = await InsertOneTimeTokenAsync(email, OneTimeTokenType.ForgotPassword);

            emailManager.Send(email, "Reset your password", "Here is your token: " + token);

            LogManager.AddLog(LogCategory.Email, "Password reset email sent: {email}", LogEventLevel.Information, email);

            return(true);
        }
        public async Task <IActionResult> EmailContatti(int contId, int risId, [FromForm] MailContattiDto mailContattiDto)
        {
            try
            {
                if (string.IsNullOrEmpty(mailContattiDto.Body))
                {
                    return(BadRequest("Mail body can't be empty"));
                }

                var contatti = await _contattiManager.FindByContattiAsync(contId);

                var risorse = await _risorseManager.GetCvInfoAsync(risId);

                if (contatti == null || string.IsNullOrEmpty(contatti.ContEmail1))
                {
                    return(BadRequest("Email address not found"));
                }

                // Sending email to the specific resource mail
                _emailManager.To.Add(contatti.ContEmail1);
                _emailManager.Subject = "CV";
                _emailManager.Body    = mailContattiDto.Body;


                var stream = new MemoryStream();
                if (mailContattiDto.Attachment != null && mailContattiDto.Attachment.Length > 0)
                {
                    await mailContattiDto.Attachment.CopyToAsync(stream);

                    _emailManager.Attachments.Add(stream, mailContattiDto.Attachment.FileName);
                }
                else if (risorse.RisCvAllegato != null && !string.IsNullOrEmpty(risorse.RisCvNomeFile))
                {
                    stream = new MemoryStream(risorse.RisCvAllegato);
                    _emailManager.Attachments.Add(stream, risorse.RisCvNomeFile);
                }

                var response = _emailManager.Send();
                stream.Dispose();

                // creating the azioni object passing the related details and description.
                var azioniDto = _utilityManager.GetAzioniDtoObject(User, "email", "contatti");
                // logging the activity record by the user.
                // await _talentBllWrapper.AzuiniBll.AzioniInsert(azioniDto);
                return(Ok(new { status = response }));
            }
            catch (Exception x)
            {
                // Code block of Exception handling and logging into log_operazione table.
                var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Send Email Contatti");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Beispiel #6
0
        public ActionResult Send(string code, string from, string to, string subject, string body)
        {
            var res = false;
            var msg = "";

            res = mng.Send(code, out msg, to, from, subject, body);

            return(Json(new
            {
                result = res,
                msg
            }));
        }
Beispiel #7
0
 public IActionResult SendContactForm([FromBody] ContactFormModel contactFormModel)
 {
     if (contactFormModel != null)
     {
         _emailManager.SMTPSettings = _appSettings.SMTPSettings;
         _emailManager.To           = _appSettings.SMTPSettings.From;
         _emailManager.ReplyTo      = new MailAddress(contactFormModel.Email);
         _emailManager.Subject      = "New Enquiry Email";
         _emailManager.Body         = $@"Hi, <br>
                                 You got a new enquiry email. <br>
                                 <b>Name: </b> {contactFormModel.Name} <br>
                                 <b>Email: </b> {contactFormModel.Email} <br>
                                 <b>Subject: </b> {contactFormModel.Subject} <br>
                                 <b>Message: </b> {contactFormModel.Message} <br>";
         _emailManager.Send();
     }
     return(Ok(new { success = "success" }));
 }
        public async Task <IActionResult> SendHardSkillInvitation([FromBody] string[] titoloList, int risId, string clientId)
        {
            try
            {
                // Retrieving the dto object that contain the mail address and mail body
                // which is required to send the mail to the specific risorse.

                var categories = await _hardSkillManager.SendHardSkillInvitationAsync(titoloList, risId, clientId);

                if (categories == null)
                {
                    return(NotFound());
                }

                List <string> emailList = categories.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);
                }
                // Initiating the mail subject
                _emailManager.Subject = "Talent: Hard Skill";
                // Initiating the mail body
                _emailManager.Body = categories.EmailBody.ToString();
                // Sending the mail to the specific recipient
                _emailManager.Send();
                // creating the azioni object passing the related details and description.
                var azioniDto = _utilityManager.GetAzioniDtoObject(User, "email", "send hard skill invitation");
                // logging the activity record by the user.
                await _azioniManager.AzioniInsert(azioniDto);

                return(Ok(categories));
            }
            catch (Exception x)
            {
                // Code block of Exception handling and logging into log_operazione table.
                var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Send Hard skill invitation");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Beispiel #9
0
        private void SendIncompleteDetailsNotification(Candidate candidate, IEnumerable <string> unavailableDetails)
        {
            var messageBody = string.Format(ResumeFilterHelper.GetNotificationTemplate(),
                                            candidate.FirstName ?? "X",
                                            candidate.LastName ?? "X",
                                            candidate.Age > 0 ? candidate.Age.ToString() : "X",
                                            candidate.Email ?? "X",
                                            candidate.PhoneNumber ?? "X",
                                            candidate.StateOfOrigin ?? "X",
                                            unavailableDetails.Aggregate(string.Empty, (current, row) => current + (!string.IsNullOrEmpty(current) ? ", " : "") + row)
                                            );

            var admins = _dataRepositoryFactory.Create <IOperationsAdminRepository>().GetOperationsAdminEmails();

            if (admins.Count > 0)
            {
                _emailManager.Send("ATS Service", admins, "ATS Applicant Notification", messageBody, true, new List <string>());
            }
        }
Beispiel #10
0
 public string PostForgetPassword([FromBody] string email)
 {
     try
     {
         // Mail sending to client with a invitation link and newly generated OTP.
         var invitationLink = AppSettingsDto.BaseDomainName + "/Email/ResetPassword?email=" + email;
         var mailBody       =
             $"<br />Dear User,<br /><br />This is your OTP: <b>{_cm.GenerateRandomOtp()}</b><br />Click here to reset new password: {invitationLink}\n";
         //_emailManager.ReceiverEmail.Add(email);
         _emailManager.To.Add(email);
         _emailManager.Subject = "Talent_OTP";
         _emailManager.Body    = mailBody.ToString();
         _emailManager.Send();
         return("Success!");
     }
     catch (Exception ex)
     {
         string error = _cm.GenerateErrorMessage(ex) + "\n" + _cm.GenerateCustomErrorMessage(ex.HResult);
         return(error);
     }
 }
Beispiel #11
0
 public async Task <ApiResponse> Send(EmailDto parameters)
 => ModelState.IsValid ?
 await _emailManager.Send(parameters) :
 new ApiResponse(Status400BadRequest, L["InvalidData"]);
 public bool Put <T>(T data)
 {
     // How am I going to get the FROM and TO details?
     return(_manager.Send());
 }
Beispiel #13
0
        public async void sendFeedbackMail(SurveyData surveyData)
        {
            // Static Number of Questions
            var numberOfQuestion = 60;
            // Static Number of Options
            var numberOfOption = 4;
            // Static Number of Gender Data
            var numberOfGender = 2;
            // Static Number of Dropdown data
            var numberOfDropdown = 5;
            // Declaring the empty mail content
            var mailContent = "";

            var i = 0;
            var j = 0;

            // Loop in the question array to load all the question along with the answers
            for (int x = 0; x < numberOfQuestion; x++)
            {
                // Embedding the specific questions to the mail content based on language.
                mailContent += "Q " + (x + 1) + ": " + returnQuestion(x + (numberOfQuestion * surveyData.LangIndex)) + " : <b>";
                // Checking whether the question is about general info or radio options or select list options.
                if (x < 2)
                {
                    // Checking whether this is first question which related to gender.
                    if (x == 0)
                    {
                        // Embedding the answers provided by the surveyor following the selcted language.
                        mailContent += returnSelectedGender((numberOfGender * surveyData.LangIndex) +
                                                            (Int32.Parse(surveyData.FeedbackArray[j])) - 1) + "</b><br />";
                        j++;
                    }
                    else
                    {
                        mailContent += returnDropDown((numberOfDropdown * surveyData.LangIndex) +
                                                      (Int32.Parse(surveyData.FeedbackArray[j])) - 1) + "</b><br />";
                        j++;
                    }
                }
                else
                {
                    // Cheking the whether these questions are radio option type or select type.
                    if (x < 8)
                    {
                        mailContent += surveyData.FeedbackArray[j] + "</b><br />";
                        j++;
                    }
                    else
                    {
                        mailContent += returnSelectedAnswer((numberOfOption * surveyData.LangIndex) +
                                                            (Int32.Parse(surveyData.SelectListArray[i])) - 1) + "</b><br />";
                        i++;
                    }
                }
            }

            // Creating the mail body by concatanating the surveyor name and others info along with the provided answers
            var mailbody = "<br />Dear " + surveyData.FirstName + " " + surveyData.LastName + ",<br /><br /> <br/>" + "Here is your provided feedback : <br /> " + mailContent + "<br /><br /><b> N.B:  Please do not reply in this mail </b><br /><br /> Thanks, <br /> Talent Team";

            // Initiating the recipient mail address.
            _emailManager.To.Add(surveyData.Email);
            // Initiating the mail subject.
            _emailManager.Subject = "Talent_Survey_Form";
            // Initiating the mail body.
            _emailManager.Body = mailbody.ToString();
            // Sending the mail to specific recipient.
            _emailManager.Send();

            // creating the azioni object passing the related details and description.
            var azioniDto = _utilityManager.GetAzioniDtoObject(User, "email", "survey_feedback_mail");
            // logging the activity record by the user.
            await _azioniManager.AzioniInsert(azioniDto);
        }