/// <summary> /// This method gets a teamsId, finds the nearest participant that isn't /// team leader and that participant's Id is returned /// </summary> /// <param name="id">TeamsId</param> /// <returns>ParticipantsId</returns> private void sendMail(ComMails comEmails) { //var team = _context.Teams.Where(opt => opt.TeamsId == part.TeamsId).SingleOrDefault(); var body = string.Empty; //using streamreader for reading the htmltemplate using (StreamReader reader = new StreamReader("wwwroot/CredentialTemplate.html")) { body = reader.ReadToEnd(); } //body = body.Replace("{Name}", part.FirstName + " " + part.LastName); //replacing the required things body = body.Replace("{Subject}", comEmails.Subject); body = body.Replace("{Signature}", "NRP - HR"); body = body.Replace("{Message}", comEmails.Message); for (var i = 0; i < comEmails.Email.Count; i++) { _mail.SendMail(comEmails.Email[i], body, comEmails.Subject); } }
public bool add(Employee employee) { var tmp = new ComMails(); var rnd = new Random(); var pwd = _passwordTools.passwordGen(10); employee.Username = employee.FirstName[0] + employee.LastName + rnd.Next(employee.LastName.Length * 1000).ToString(); employee.Password = _passwordTools.passwordHash(pwd); tmp.Email = new List <string>(); tmp.Email.Add(employee.Email); tmp.Message = "Please find below, your credentials to NRP Portal:<br/>Sign in as Employee<br/>"; tmp.Message += "Username " + employee.Username + "<br/>Password: " + pwd; _comMail.SendMailToPar(tmp); try { _context.Employees.Add(employee); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } return(true); }
public bool add(ClientContactInfo clientContact) { var tmp = new ComMails(); var rnd = new Random(); var pwd = _passwordTools.passwordGen(10); clientContact.Username = clientContact.FirstName[0] + clientContact.LastName + rnd.Next(clientContact.LastName.Length * 1000).ToString(); clientContact.Password = _passwordTools.passwordHash(pwd); tmp.Email = new List <string>(); tmp.Email.Add(clientContact.Email); tmp.Message = "Please find below, your credentials to NRP Portal:<br/>Sign in as Client<br/>"; tmp.Message += "Username " + clientContact.Username + "<br/>Password: " + pwd; _comMail.SendMailToPar(tmp); try { clientContact.Date = DateTime.Now; _context.ClientContactInfos.Add(clientContact); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } return(true); }
private void resetClientPassword(string id) { var tmp = _crepo.getByUsername(id); var pwd = _tools.passwordGen(10); tmp.Password = _tools.passwordHash(pwd); var email = new ComMails(); email.Email = new List <string>(); email.Email.Add(tmp.Email); email.Message = "Please find below, your credentials to NRP Portal:<br/>Sign in as Client<br/>"; email.Message += "Username " + tmp.Username + "<br/>Password: " + pwd; _comMail.SendMailToPar(email); _crepo.update(tmp.ClientContactInfoId, tmp); }
public void SendMailToPar(ComMails data) { this.sendMail(data); }