Exemplo n.º 1
0
 //creating an instance of JobPost table (Model) as a parameter
 public bool commitInsert(JobPost jpos)
 {
     //to ensure all data will be disposed of when finished
     using (objJob)
     {
         //using our model to set table columns to new values being passed and providing it to the insert command
         objJob.JobPosts.InsertOnSubmit(jpos);
         objJob.SubmitChanges();
         return true;
     }
 }
 partial void DeleteJobPost(JobPost instance);
 partial void UpdateJobPost(JobPost instance);
 partial void InsertJobPost(JobPost instance);
		private void detach_JobPosts(JobPost entity)
		{
			this.SendPropertyChanging();
			entity.JobCategory = null;
		}
 public ActionResult JobPostUpdate(int id, JobPost jpos)
 {
     //If all the input were valid , then database will be updated
     if (ModelState.IsValid)
     {
         try
         {
             objJobPost.CommitUpdate(id, jpos.JobCategory_id, jpos.title, jpos.description, jpos.date, jpos.email, jpos.status);
             return RedirectToAction("Index");
         }
         catch
         {
             return View();
         }
     }
     return View();
 }
 public ActionResult JobPostInsert(JobPost jpos)
 {
     if (ModelState.IsValid)
     {
         try
         {
             objJobPost.commitInsert(jpos);
             return RedirectToAction("Index"); //On sucessful insert, redirect to the index view
         }
         catch
         {
             //Error handling, return to Donation view if something goes wrong
             return View();
         }
     }
     return View();
 }
 public ActionResult JobPostDelete(int id, JobPost jpos)
 {
     try
     {
         objJobPost.commitDelete(id);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }