public ActionResult Delete(int id) { JobListing job = db.JobListings.SqlQuery("select * from JobListings where JobID = @id", new SqlParameter("@id", id)).FirstOrDefault(); List <Department> department = db.Departments.SqlQuery("select * from Departments inner join JobListings on JobListings.DepartmentID = Departments.DepartmentID where JobID = @id", new SqlParameter("@id", id)).ToList(); ShowJobListing ShowJobListingViewModel = new ShowJobListing(); ShowJobListingViewModel.JobListing = job; ShowJobListingViewModel.Departments = department; return(View(ShowJobListingViewModel)); }
public ActionResult Show(int?id) { JobListing jobListing = db.JobListings.SqlQuery("select * from JobListings where JobID=@JobID", new SqlParameter("@JobID", id)).FirstOrDefault(); List <Department> department = db.Departments.SqlQuery("select * from Departments inner join JobListings on JobListings.DepartmentID = Departments.DepartmentID where JobID = @id", new SqlParameter("@id", id)).ToList(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (jobListing == null) { return(HttpNotFound()); } ShowJobListing ShowJobListingViewModel = new ShowJobListing(); ShowJobListingViewModel.JobListing = jobListing; ShowJobListingViewModel.Departments = department; return(View(ShowJobListingViewModel)); }