public ActionResult Index(Job newjob) { context.Jobs.Add(newjob); context.SaveChanges(); viewmodel.Companies = context.Companies.Include("Jobs").ToList(); return View(viewmodel); }
public ActionResult Delete(Job id) { Job JobToRemove = context.Jobs.Find(id); context.Jobs.Remove(JobToRemove); context.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Update( int id, Job Jobtoupdate) { Job JobUpdating = new Job(); JobUpdating = context.Jobs.Find(id); JobUpdating.Id = Jobtoupdate.Id; JobUpdating.Salary = Jobtoupdate.Salary; JobUpdating.Title = Jobtoupdate.Title; context.SaveChanges(); return RedirectToAction("Index"); }
public IHttpActionResult Delete(int id) { try { Job JobToRemove = new Job(); JobToRemove = context.Jobs.Find(id); context.Jobs.Remove(JobToRemove); return Ok(); } catch(Exception ex) { return InternalServerError(ex); } }
public IHttpActionResult Put(int id, [FromBody]Job JObupdated) { try { Job Jobupdating = new Job(); Jobupdating.Id = JObupdated.Id; Jobupdating.Salary = Jobupdating.Salary; Jobupdating.Title = Jobupdating.Title; context.SaveChanges(); return Ok(JObupdated); } catch (Exception ex) { return InternalServerError(ex); } }
public ActionResult Update(int id) { Job JobUpdating = new Job(); JobUpdating = context.Jobs.Find(id); return View(JobUpdating); }