public ActionResult PostJob() { if (!Navigator.IsUserLoggedIn(Session)) { @ViewBag.Message = "Sorry! You need to login to view this page."; return View("Message"); //return RedirectToAction("Login", "Account"); } else if (!Navigator.UserRoleValidation(Session, "staff")) { @ViewBag.Message = "Access Denied ! You are not allowed to visit this page."; return View("Message"); //return RedirectToAction("Login", "Account"); } else if (!Navigator.IsStaffAllowed(Session, "RightToPost")) { @ViewBag.Layout = "~/Views/Shared/_LayoutPageStaff.cshtml"; @ViewBag.Message = "User Rights Denied! You don't have permission for this."; return View("Message"); //return RedirectToAction("Login", "Account"); } @ViewBag.Layout = "~/Views/Shared/_LayoutPageStaff.cshtml"; Job model = new Job(); //model.JobRoles = new List<JobRole>{ // new JobRole {Id = 0, Name = "Cho"}, // new JobRole {Id = 1, Name = "Chio"}, // new JobRole {Id = 2, Name = "Choo"}, // new JobRole {Id = 3, Name = "Chyo"} // }; model.JobRoles = ASCommonDAL.GetJobRoles(); model.Skills = ASCommonDAL.GetListOfSkills(); return View(model); }
public static void PostJobInDB(Job model, User poster) { SqlConnection con = DBUtils.getDBConnection(); con.Open(); List<Skill> selectedSkills = new List<Skill>(); foreach (var item in model.Skills) { if(item.Checked){ selectedSkills.Add(item); } } string skillSet = String.Join(",", selectedSkills.Select(x => x.Id.ToString()).ToArray()); SqlCommand command = new SqlCommand("insert into Job (job_description, job_role_id, skill_set, vacancies, min_experience, max_experience, age_limit, posted_by, posted_on, status) values ('" + model.JobDesc + "', " + model.JobRole + ", '" + skillSet + "'," + model.Vacancies + ", " + model.MinExperience + ", " + model.MaxExperience + ", " + model.AgeLimit + ", " + poster.user_id + ", '" + DateTime.Now.ToShortDateString() + "', 'P' );", con); command.ExecuteNonQuery(); con.Close(); }
public ActionResult PostJob(Job model) { if (!Navigator.IsUserLoggedIn(Session)) { @ViewBag.Message = "Sorry! You need to login to view this page."; return View("Message"); //return RedirectToAction("Login", "Account"); } else if (!Navigator.UserRoleValidation(Session, "manager")) { @ViewBag.Message = "Access Denied ! You are not allowed to visit this page."; return View("Message"); //return RedirectToAction("Login", "Account"); } Job mo = model; User user = ((User)Session["user"]); ASCommonDAL.PostJobInDB(model, user); //string desc = model.JobDesc; //string role = model.JobRole; @ViewBag.Message = "Job Posted !"; @ViewBag.Layout = "~/Views/Shared/_LayoutPageManager.cshtml"; return View("Message"); //return RedirectToAction("Index","Home"); }
public ActionResult PostJob() { if (!Navigator.IsUserLoggedIn(Session)) { @ViewBag.Message = "Sorry! You need to login to view this page."; return View("Message"); //return RedirectToAction("Login", "Account"); } else if (!Navigator.UserRoleValidation(Session, "manager")) { @ViewBag.Message = "Access Denied ! You are not allowed to visit this page."; return View("Message"); //return RedirectToAction("Login", "Account"); } @ViewBag.Layout = "~/Views/Shared/_LayoutPageManager.cshtml"; Job model = new Job(); model.JobRoles = ASCommonDAL.GetJobRoles(); model.Skills = ASCommonDAL.GetListOfSkills(); return View("../Staff/PostJob",model); }