public void AddCompanyaccount(RecrutmentSignupView rsv) { using (RecrutmentsysEntities db = new RecrutmentsysEntities()) { COMPANY_REGISTER CR = new COMPANY_REGISTER(); CR.ComapanyName = rsv.ComapanyName; CR.CompanyEmail = rsv.CompanyEmail; CR.CompanyContect = rsv.CompanyContect; CR.CompanyAddress = rsv.CompanyAddress; db.COMPANY_REGISTER.Add(CR); db.SaveChanges(); //string password = RandomString(8); COMPANY_REGISTER_REFRENCES CRF = new COMPANY_REGISTER_REFRENCES(); CRF.CompanyId = CR.CompanyId; CRF.CompanyEmailRef = rsv.CompanyEmail; CRF.CompanyPassword = rsv.CompanyPassword; CRF.CompanyType = "Admin"; CRF.ConfirmedEmail = false; db.COMPANY_REGISTER_REFRENCES.Add(CRF); db.SaveChanges(); rsv.ComapnyrefId = CRF.ComapanyRefId; //using (MailMessage mm = new MailMessage()) //{ // mm.To.Add(new MailAddress(rsv.CompanyEmail)); // mm.From = new MailAddress("*****@*****.**"); // mm.Subject = "Email confirmation !"; // // mm.Body = "This email create is company use of term and condition <br/> Your Email:- " + rsv.CompanyEmail + " <br/> you Password:-" + password + " "; // mm.Body = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to complete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", CR.ComapanyName, Url.Action("ConfirmEmail", "Account", new { Token = CRF.ComapanyRefId, Email = CRF.CompanyEmailRef }, Request.Url.Scheme)); // mm.IsBodyHtml = true; // using (SmtpClient smtp = new SmtpClient()) // { // smtp.Host = "smtp.gmail.com"; // smtp.EnableSsl = true; // NetworkCredential networkcred = new NetworkCredential("*****@*****.**", "connectists@57confuse"); // smtp.UseDefaultCredentials = true; // smtp.Credentials = networkcred; // smtp.Port = 587; // smtp.Send(mm); // } //} } }
public ActionResult companySignup(RecrutmentSignupView rsv) { if (ModelState.IsValid) { UserManager UM = new UserManager(); if (!UM.IsLoginEmailExits(rsv.CompanyEmail)) { UM.AddCompanyaccount(rsv); if (rsv.ComapnyrefId != null) { using (MailMessage mm = new MailMessage()) { //string code = Guid.NewGuid().ToString(); mm.To.Add(new MailAddress(rsv.CompanyEmail)); mm.From = new MailAddress("*****@*****.**"); mm.Subject = "Email confirmation !"; // mm.Body = "This email create is company use of term and condition <br/> Your Email:- " + rsv.CompanyEmail + " <br/> you Password:-" + password + " "; mm.Body = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to complete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", rsv.ComapanyName, Url.Action("ConfirmEmail", "Account", new { Token = rsv.ComapnyrefId, Email = rsv.CompanyEmail }, Request.Url.Scheme)); mm.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential networkcred = new NetworkCredential("*****@*****.**", "connectists@57confuse"); smtp.UseDefaultCredentials = true; smtp.Credentials = networkcred; smtp.Port = 587; smtp.Send(mm); ViewBag.message = "Check inbox on your mail !"; return(RedirectToAction("Confirm", "Account")); } } } //FormsAuthentication.SetAuthCookie(rsv.ComapanyName, false); //TempData["msg"] = "Account Created ! Check Mail get Password."; //return RedirectToAction("Login", "Account"); } else { ModelState.AddModelError("", "Email is already taken"); } } return(View()); }