public ActionResult partialEmployerReg() { empRegistration oempRegistration = new empRegistration(); ViewBag.employerTypeID = new SelectList(db.employerTypes, "employerTypeID", "employerType1"); return(View("_partialEmploerReg", oempRegistration)); }
public async Task <ActionResult> partialEmployerReg(empRegistration empRegistartion) { companyDetail cmpdetails = new companyDetail(); EmployerDetail empdetails = new EmployerDetail(); cmpdetails.companyName = empRegistartion.companyName; cmpdetails.city = " Not specified "; cmpdetails.state = " Not specified "; cmpdetails.country = " Not specified "; empdetails.Email = empRegistartion.Email; cmpdetails.website = empRegistartion.website; cmpdetails.employerTypeID = empRegistartion.employerTypeID; cmpdetails.address = " Not specified "; cmpdetails.companyDescription = " Not specified "; cmpdetails.dataIsCreated = BaseUtil.GetCurrentDateTime(); cmpdetails.dataIsUpdated = BaseUtil.GetCurrentDateTime(); cmpdetails.zipCode = "------"; cmpdetails.companyIndustry = 0; db.companyDetails.Add(cmpdetails); try { await db.SaveChangesAsync(); empdetails.companyID = cmpdetails.companyID; empdetails.dataIsCreated = BaseUtil.GetCurrentDateTime(); empdetails.dataIsUpdated = BaseUtil.GetCurrentDateTime(); empRegistartion.password = baseClass.GetRandomPasswordString(10); empdetails.Name = empRegistartion.companyName; empdetails.Mobile = empRegistartion.mobile; empdetails.isActive = false; empdetails.isDelete = false; empdetails.roleID = 2; empdetails.password = empRegistartion.password; db.EmployerDetails.Add(empdetails); await db.SaveChangesAsync(); empRegistartion.employerID = empdetails.EmployerID; var emailresult = db.EmployerDetails.Where(ex => ex.EmployerID == empRegistartion.employerID).FirstOrDefault(); var encryptedID = BaseUtil.encrypt(emailresult.EmployerID.ToString()); StreamReader sr = new StreamReader(Server.MapPath("/Emailer/toEmployerRegistrationSuccess.html")); string HTML_Body = sr.ReadToEnd(); string newString = HTML_Body.Replace("#name", emailresult.Name).Replace("#EMPID", encryptedID).Replace("#password", emailresult.EmployerDetail1.password); sr.Close(); string To = emailresult.Email.ToString(); string mail_Subject = "Employer Registration Confirmation "; profileController objprofileController = new profileController(); BaseUtil.sendEmailer(To, mail_Subject, newString, ""); TempData["result"] = "Registred"; } catch (Exception ex) { BaseUtil.CaptureErrorValues(ex); TempData["result"] = "Registration failed."; } ViewBag.employerTypeID = new SelectList(db.employerTypes, "employerTypeID", "employerType1"); ViewBag.companyIndustry = new SelectList(db.industries, "industryID", "industryName"); return(RedirectToAction("Employerlogin")); }