public ActionResult EditJob(Jobs job) { JobsRepository.UpdateJob(job.Jobid, job.Field, job.Skills, job.Experience, job.Salary, job.Location, job.Title, job.Description); return RedirectToAction("Index"); }
public ActionResult PostJob(Jobs job) { Database db = DatabaseFactory.CreateDatabase(); DbCommand command = db.GetStoredProcCommand("Jobs_InsertJob"); db.AddInParameter(command, "@Rid", System.Data.DbType.Int32, JobsRepository.GetRid(User.Identity.Name)); db.AddInParameter(command, "@Date", System.Data.DbType.DateTime, DateTime.Now); db.AddInParameter(command, "@Field", System.Data.DbType.String, job.Field); db.AddInParameter(command, "@Skills", System.Data.DbType.String, job.Skills); db.AddInParameter(command, "@Experience", System.Data.DbType.String, job.Experience); db.AddInParameter(command, "@Salary", System.Data.DbType.Int32, job.Salary); db.AddInParameter(command, "@Location", System.Data.DbType.String, job.Location); db.AddInParameter(command, "@Title", System.Data.DbType.String, job.Title); db.AddInParameter(command, "@Description", System.Data.DbType.String, job.Description); db.ExecuteScalar(command); return RedirectToAction("Index", "Jobs"); }
public List<Jobs> SearchResults(string SearchType, string SearchString) { var list = new List<Jobs>(); DbCommand command; if (SearchType.Equals("Location")) { command = db.GetStoredProcCommand("Jobs_SearchLocation"); db.AddInParameter(command, "@SearchString", System.Data.DbType.String, SearchString); db.ExecuteScalar(command); } else { command = db.GetStoredProcCommand("Jobs_SearchTitle"); db.AddInParameter(command, "@SearchString", System.Data.DbType.String, SearchString); db.ExecuteScalar(command); } using (var reader = db.ExecuteReader(command)) { while (reader.Read()) { var job = new Jobs(); if (!reader.IsDBNull(reader.GetOrdinal("Date"))) { job.Date = reader.GetDateTime(reader.GetOrdinal("Date")); } if (!reader.IsDBNull(reader.GetOrdinal("Field"))) { job.Field = reader.GetString(reader.GetOrdinal("Field")); } if (!reader.IsDBNull(reader.GetOrdinal("Title"))) { job.Title = reader.GetString(reader.GetOrdinal("Title")); } if (!reader.IsDBNull(reader.GetOrdinal("Location"))) { job.Location = reader.GetString(reader.GetOrdinal("Location")); } if (!reader.IsDBNull(reader.GetOrdinal("Jobid"))) { job.Jobid = reader.GetInt32(reader.GetOrdinal("Jobid")); } if (!reader.IsDBNull(reader.GetOrdinal("Description"))) { job.Description = reader.GetString(reader.GetOrdinal("Description")); } if (!reader.IsDBNull(reader.GetOrdinal("Experience"))) { job.Experience = reader.GetString(reader.GetOrdinal("Experience")); } if (!reader.IsDBNull(reader.GetOrdinal("Rid"))) { job.Rid = reader.GetInt32(reader.GetOrdinal("Rid")); } if (!reader.IsDBNull(reader.GetOrdinal("Salary"))) { job.Salary = reader.GetInt32(reader.GetOrdinal("Salary")); } if (!reader.IsDBNull(reader.GetOrdinal("Skills"))) { job.Skills = reader.GetString(reader.GetOrdinal("Skills")); } list.Add(job); } } return list; }
public Jobs ViewEditJob(int id) { DbCommand command = db.GetStoredProcCommand("Jobs_ViewEditJob"); db.AddInParameter(command, "@Jobid", System.Data.DbType.Int32, id); db.ExecuteScalar(command); var job = new Jobs(); using (var reader = db.ExecuteReader(command)) { while (reader.Read()) { if (!reader.IsDBNull(reader.GetOrdinal("Date"))) { job.Date = reader.GetDateTime(reader.GetOrdinal("Date")); } if (!reader.IsDBNull(reader.GetOrdinal("Field"))) { job.Field = reader.GetString(reader.GetOrdinal("Field")); } if (!reader.IsDBNull(reader.GetOrdinal("Title"))) { job.Title = reader.GetString(reader.GetOrdinal("Title")); } if (!reader.IsDBNull(reader.GetOrdinal("Location"))) { job.Location = reader.GetString(reader.GetOrdinal("Location")); } if (!reader.IsDBNull(reader.GetOrdinal("Jobid"))) { job.Jobid = reader.GetInt32(reader.GetOrdinal("Jobid")); } if (!reader.IsDBNull(reader.GetOrdinal("Description"))) { job.Description = reader.GetString(reader.GetOrdinal("Description")); } if (!reader.IsDBNull(reader.GetOrdinal("Experience"))) { job.Experience = reader.GetString(reader.GetOrdinal("Experience")); } if (!reader.IsDBNull(reader.GetOrdinal("Rid"))) { job.Rid = reader.GetInt32(reader.GetOrdinal("Rid")); } if (!reader.IsDBNull(reader.GetOrdinal("Salary"))) { job.Salary = reader.GetInt32(reader.GetOrdinal("Salary")); } if (!reader.IsDBNull(reader.GetOrdinal("Skills"))) { job.Skills = reader.GetString(reader.GetOrdinal("Skills")); } } } return job; }
public List<Jobs> BuildList() { var list = new List<Jobs>(); DbCommand command = db.GetStoredProcCommand("Jobs_BuildList"); using (var reader = db.ExecuteReader(command)) { while (reader.Read()) { var job = new Jobs(); if (!reader.IsDBNull(reader.GetOrdinal("Date"))) { job.Date = reader.GetDateTime(reader.GetOrdinal("Date")); } if (!reader.IsDBNull(reader.GetOrdinal("Field"))) { job.Field = reader.GetString(reader.GetOrdinal("Field")); } if (!reader.IsDBNull(reader.GetOrdinal("Title"))) { job.Title = reader.GetString(reader.GetOrdinal("Title")); } if (!reader.IsDBNull(reader.GetOrdinal("Location"))) { job.Location = reader.GetString(reader.GetOrdinal("Location")); } if (!reader.IsDBNull(reader.GetOrdinal("Jobid"))) { job.Jobid = reader.GetInt32(reader.GetOrdinal("Jobid")); } if (!reader.IsDBNull(reader.GetOrdinal("Description"))) { job.Description = reader.GetString(reader.GetOrdinal("Description")); } if (!reader.IsDBNull(reader.GetOrdinal("Experience"))) { job.Experience = reader.GetString(reader.GetOrdinal("Experience")); } if (!reader.IsDBNull(reader.GetOrdinal("Rid"))) { job.Rid = reader.GetInt32(reader.GetOrdinal("Rid")); } if (!reader.IsDBNull(reader.GetOrdinal("Salary"))) { job.Salary = reader.GetInt32(reader.GetOrdinal("Salary")); } if (!reader.IsDBNull(reader.GetOrdinal("Skills"))) { job.Skills = reader.GetString(reader.GetOrdinal("Skills")); } list.Add(job); } } return list; }