public bool createJob(string recordid, string jobtitle, string skills, int noofvacancies, string remarks, bool isActive) { bool flagSucess = false; //bool isActiveTest = true; int userId = 0; if (Session["adminuser"] != null) { string currentUser = Session["adminuser"].ToString(); if (currentUser != null) { userId = int.Parse(currentUser.Split('|')[0]); } } using (HREntities db = new HREntities()) { try { jobPost jobpost = new jobPost(); if (recordid == "") { jobpost.createDate = DateTime.Now; jobpost.jobTilte = jobtitle; jobpost.skills = skills; jobpost.noOfVacancies = noofvacancies; jobpost.remarks = remarks; jobpost.userId = userId; jobpost.isActive = isActive; db.jobPosts.Add(jobpost); } else { long id = long.Parse(recordid); jobpost = db.jobPosts.Where(x => x.jobId == id).SingleOrDefault(); jobpost.createDate = DateTime.Now; jobpost.jobTilte = jobtitle; jobpost.skills = skills; jobpost.noOfVacancies = noofvacancies; jobpost.remarks = remarks; jobpost.userId = userId; jobpost.isActive = isActive; } flagSucess = true; db.SaveChanges(); } catch (Exception) { throw; } } return(flagSucess); }
public string GetJobs() { try { using (HREntities db = new HREntities()) { var data = db.jobPosts.Where(x => x.isActive == true).ToList(); jobPost obj = new jobPost(); return(JsonConvert.SerializeObject(data)); } } catch (Exception) { throw; } }