public JsonResult changeProfile(HttpPostedFileBase photo) { string filename = null; if (photo != null) { string pic = Path.GetExtension(photo.FileName); filename = Guid.NewGuid().ToString() + pic; string path = Path.Combine(Server.MapPath("~/Content/images"), filename); photo.SaveAs(path); jobseeker_info emp = db.jobseeker_info.Find(Convert.ToInt16(Session["js_id"].ToString())); emp.profile = filename; if (db.SaveChanges() > 0) { Session["profileimage"] = filename; return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } } else { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public async Task <JsonResult> jobseekermessage(string name, string email, string phone, string message, int js_id) { if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(phone) && !string.IsNullOrEmpty(message)) { jobseeker_info js = db.jobseeker_info.Find(js_id); message mess = new Models.message(); mess.message1 = message; mess.created_at = DateTime.Now; mess.read_status = 0; mess.sender_address = email; mess.sender_contact = phone; mess.status = 1; db.messages.Add(mess); if (db.SaveChanges() > 0) { await SendEmail(name, js.email, phone, message, js.full_name); return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } } else { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public async Task <JsonResult> verifyEmail() { int js_id = Convert.ToInt32(Session["js_id"].ToString()); jobseeker_info js = db.jobseeker_info.Find(js_id); if (js.email_verified == "FALSE") { Random r = new Random(); int num = r.Next(1000, 9999); string temp = CalculateMD5Hash(num.ToString()); string link = "http://localhost:52920/home/verification/?token=" + temp; await SendEmail(js.email, link, js.full_name, js.js_id); email_verification email = new email_verification(); email.js_id = js_id; email.created_at = DateTime.Now; email.status = 1; email.token = temp; db.email_verification.Add(email); if (db.SaveChanges() > 0) { return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } } else { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult jobseeker_profile(int id = 0) { jobseeker_info js = db.jobseeker_info.Find(id); if (js != null) { JobseekerDetailedModel a = new JobseekerDetailedModel(); a.contact = js.contact; a.created_at = js.created_at; a.current_address = js.current_address; a.dateofbirth = js.dateofbirth; a.education = db.jobseeker_education.Where(p => p.js_id == id).ToList(); a.email = js.email; a.full_name = js.full_name; a.gender = js.gender; a.js_id = js.js_id; a.profile = js.profile; a.skills = js.skills; a.updated_at = js.updated_at; a.facebook_id = js.facebook_id; a.experience = db.js_experience.Where(l => l.js_id == id).ToList(); return(View(a)); } else { return(Json("Restricted Access", JsonRequestBehavior.AllowGet)); } }
public ActionResult logOn(string username = "", string password = "", string returnurl = "") { Md5Calculator Md5Calculator = new Md5Calculator(); password = Md5Calculator.CalculateMD5Hash(password); AccountModel accountModel = new AccountModel(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || accountModel.login(username, password) == null) { ViewBag.message = "<div class='alert alert-danger'>Wrong Credentials</div>"; return(View("login")); } else { SessionPersister.username = username; var userDetails = db.users.Where(a => a.user_name == username && a.password == password).FirstOrDefault(); Session["userid"] = userDetails.user_id; Session["username"] = userDetails.user_name; Session["role"] = userDetails.role; Session["is_logged_in"] = true; int userid = Convert.ToInt32(userDetails.user_id); if (userDetails.role.ToString() == "employer") { int emp_id = (from p in db.employer_info where p.login_info == userid select p.emp_id).FirstOrDefault(); employer_info em = db.employer_info.Find(emp_id); em.updated_at = DateTime.Now; db.SaveChanges(); string profileimage = (from p in db.employer_info where p.login_info == userid select p.logo).FirstOrDefault(); Session["emp_id"] = emp_id; Session["profileimage"] = profileimage; if (!string.IsNullOrEmpty(returnurl)) { return(Redirect(returnurl)); } else { return(RedirectToAction("managejobs", "Employer")); } } else { int js_id = (from p in db.jobseeker_info where p.login_info == userid select p.js_id).FirstOrDefault(); jobseeker_info js = db.jobseeker_info.Find(js_id); js.updated_at = DateTime.Now; db.SaveChanges(); string profileimage = (from p in db.jobseeker_info where p.login_info == userid select p.profile).FirstOrDefault(); Session["js_id"] = js_id; Session["profileimage"] = profileimage; if (!string.IsNullOrEmpty(returnurl)) { return(Redirect(returnurl)); } else { return(RedirectToAction("savedjobs", "jobseeker")); } } } }
public ActionResult loginVerify(string username = "", string password = "", string returnurl = "") { Md5Calculator Md5Calculator = new Md5Calculator(); password = Md5Calculator.CalculateMD5Hash(password); AccountModel accountModel = new AccountModel(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || accountModel.login(username, password) == null) { return(Json(new { success = false })); } else { SessionPersister.username = username; var userDetails = db.users.Where(a => a.user_name == username && a.password == password).FirstOrDefault(); Session["userid"] = userDetails.user_id; Session["username"] = userDetails.user_name; Session["role"] = userDetails.role; Session["is_logged_in"] = true; int userid = Convert.ToInt32(userDetails.user_id); if (userDetails.role.ToString() == "employer") { int emp_id = (from p in db.employer_info where p.login_info == userid select p.emp_id).FirstOrDefault(); string profileimage = (from p in db.employer_info where p.login_info == userid select p.logo).FirstOrDefault(); string name = (from p in db.employer_info where p.login_info == userid select p.company_name).FirstOrDefault(); employer_info em = db.employer_info.Find(emp_id); em.updated_at = DateTime.Now; db.SaveChanges(); Session["name"] = name; Session["emp_id"] = emp_id; Session["profileimage"] = profileimage; return(Json(new { success = true, username = username, role = "employer" })); } else { string sessid = Guid.NewGuid().ToString(); Session["sessid"] = sessid; int js_id = (from p in db.jobseeker_info where p.login_info == userid select p.js_id).FirstOrDefault(); jobseeker_info js = db.jobseeker_info.Find(js_id); js.updated_at = DateTime.Now; db.SaveChanges(); string profileimage = js.profile; string name = js.full_name; Session["name"] = name; Session["js_id"] = js_id; Session["profileimage"] = profileimage; Session["emailverified"] = js.email_verified; return(Json(new { success = true, username = username, role = "jobseeker" })); } } }
public JsonResult changeSkills(string val) { int sess = Convert.ToInt32(Session["js_id"].ToString()); jobseeker_info js = db.jobseeker_info.Where(a => a.js_id == sess).FirstOrDefault(); js.skills = val; if (db.SaveChanges() > 0) { return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult editDetails(jobseeker_info model) { if (ModelState.IsValid) { jobseeker_info final = db.jobseeker_info.Find(model.js_id); final.full_name = model.full_name; final.current_address = model.current_address; final.contact = model.contact; final.skills = model.skills; final.gender = model.gender; final.dateofbirth = Convert.ToDateTime(model.dateofbirth); db.SaveChanges(); return(RedirectToAction("jobseekerdashboard", "jobseeker")); } else { return(RedirectToAction("jobseekerdashboard", "jobseeker")); } }
public ActionResult verification(string token) { email_verification email = db.email_verification.Where(a => a.token.Equals(token) && a.status == 1).FirstOrDefault(); if (email != null) { DateTime now = DateTime.Now; TimeSpan t = (now - Convert.ToDateTime(email.created_at)); double min = t.TotalMinutes; if (min > 60) { return(Json("Token Expired", JsonRequestBehavior.AllowGet)); } else { email.status = 0; int js = email.js_id.HasValue ? Convert.ToInt32(email.js_id) : 0; jobseeker_info jsl = db.jobseeker_info.Find(js); if (jsl != null) { jsl.email_verified = "TRUE"; db.SaveChanges(); } else { return(Json("Invalid Token", JsonRequestBehavior.AllowGet)); } db.SaveChanges(); return(RedirectToAction("index", "Login")); } } else { return(Json("Invalid Token", JsonRequestBehavior.AllowGet)); } }
public ActionResult Register(HttpPostedFileBase profile, jobseekerView model) { if (ModelState.IsValid) { try { user tempuser = new user(); jobseeker_info jobseeker = new jobseeker_info(); tempuser.user_name = model.user_name; tempuser.password = CalculateMD5Hash(model.password); tempuser.role = "jobseeker"; tempuser.status = "ACTIVE"; db.users.Add(tempuser); if (db.SaveChanges() > 0) { string filename = null; if (profile != null) { string pic = Path.GetExtension(profile.FileName); filename = Guid.NewGuid().ToString() + pic; string path = Path.Combine(Server.MapPath("~/Content/images"), filename); profile.SaveAs(path); } int insertId = tempuser.user_id; jobseeker.full_name = model.full_name; jobseeker.current_address = model.current_address; jobseeker.email = model.email; jobseeker.contact = model.contact; jobseeker.created_at = DateTime.Now; jobseeker.updated_at = DateTime.Now; jobseeker.status = "ACTIVE"; jobseeker.facebooklogin_status = "FALSE"; jobseeker.email_verified = "FALSE"; jobseeker.login_info = insertId; jobseeker.profile = filename; jobseeker.gender = model.gender; jobseeker.dateofbirth = Convert.ToDateTime(model.dateofbirth); db.jobseeker_info.Add(jobseeker); db.SaveChanges(); string sessid = Guid.NewGuid().ToString(); Session["sessid"] = sessid; Session["profileimage"] = jobseeker.profile; Session["name"] = jobseeker.full_name; Session["userid"] = jobseeker.login_info; Session["username"] = tempuser.user_name; Session["role"] = tempuser.role; Session["is_logged_in"] = true; Session["js_id"] = jobseeker.js_id; Session["emailverified"] = jobseeker.email_verified; return(RedirectToAction("jobseekerDashboard", "Jobseeker")); } else { ViewBag.message = "Error"; return(View()); } } catch (Exception ex) { ViewBag.message = "exceptio " + ex.ToString(); return(View()); } } else { return(View()); } }
public ActionResult cvdownload(int js_id) { jobseeker_info js = db.jobseeker_info.Find(js_id); StringBuilder status = new StringBuilder(""); DateTime dTime = DateTime.Now; string strPDFFileName = string.Format("CvPdf" + dTime.ToString("yyyyMMdd") + "-" + ".pdf"); string strAttachment = Server.MapPath("~/Content/pdfs/" + strPDFFileName); status.Append("<!DOCTYPE html>"); status.Append("<html>"); status.Append("<head><title></title></head>"); status.Append("<body style='margin: 20px 100px;'><h2 style='text-align:center'>Curriculum Vitae</h2>"); status.Append("<b>" + js.full_name + "</b><br>"); status.Append("<b>(+977)" + js.contact + "</b><br>"); status.Append("<b>" + js.email + "</b><br>"); status.Append("<b>" + js.current_address + "</b><br><br>"); List <jobseeker_education> ed = db.jobseeker_education.Where(a => a.js_id == js_id).OrderByDescending(a => a.jsed_id).ToList(); if (ed.Count > 0) { status.Append("<h3><b>Education</b></h3>"); foreach (var item in ed) { status.Append("<b>" + item.education_level + "</b><br><ul>"); status.Append("<li>" + item.start_date + " - " + item.end_date + "</li>"); status.Append("<li>" + item.institution + "</li></ul>"); } } List <js_experience> ex = db.js_experience.Where(a => a.js_id == js_id).ToList(); if (ex.Count > 0) { status.Append("<h3><b>Experience</b></h3><br>"); foreach (var item in ex) { status.Append("<b>" + item.title + "</b><br><ul>"); status.Append("<li>" + item.start_date + " - " + item.end_date + "</li>"); status.Append("<li>" + item.institution + "</li></ul>"); } } List <string> skills = js.skills.Split(',').ToList(); if (skills.Count > 0) { status.Append("<h3><b>Skills</b></h3><br><ul>"); foreach (var item in ex) { status.Append("<b>" + item + "</b><br><br>"); } status.Append("</ul>"); } string cv = db.tbl_cv.Where(a => a.jobseeker_id == js.js_id).Select(a => a.cv).FirstOrDefault().ToString(); status.Append(cv); status.Append("</body>"); status.Append("</html>"); StringReader str = new StringReader(status.ToString()); MemoryStream ms = new MemoryStream(); iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4); PdfWriter pdfwriter = iTextSharp.text.pdf.PdfWriter.GetInstance(document, ms); document.Open(); using (TextReader sReader = new StringReader(status.ToString())) { List <IElement> list = HTMLWorker.ParseToList(sReader, new StyleSheet()); foreach (IElement elm in list) { document.Add(elm); } } document.Close(); document.Dispose(); Response.Buffer = true; Response.Clear(); Response.AppendHeader("Content-Type", "application/x-pdf"); Response.AppendHeader("Content-disposition", "attachment; filename=" + js.full_name + "cv.pdf"); Response.BinaryWrite(ms.GetBuffer()); Response.Flush(); Response.Close(); return(View()); }