public JsonResult GetJobTitles() { List <TJobTitle> all = null; using (Entities1 dc = new Entities1()) { dc.Configuration.ProxyCreationEnabled = false; var jobTitle = from a in dc.TJobTitles select new { a }; if (jobTitle != null) { all = new List <TJobTitle>(); foreach (var i in jobTitle) { TJobTitle con = i.a; all.Add(con); } } } return(new JsonResult { Data = all, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
//Get Service Type by ID public TJobTitle GetJobTitle(int intJobTitleID) { TJobTitle jobTitle = null; using (Entities1 dc = new Entities1()) { var v = (from a in dc.TJobTitles where a.intJobTitleID.Equals(intJobTitleID) select new { a }).FirstOrDefault(); if (v != null) { jobTitle = v.a; } return(jobTitle); } }
public ActionResult Save(TJobTitle c) { string message = ""; bool status = false; if (ModelState.IsValid) { using (Entities1 dc = new Entities1()) { if (c.intJobTitleID > 0) { var v = dc.TJobTitles.Where(a => a.intJobTitleID.Equals(c.intJobTitleID)).FirstOrDefault(); if (v != null) { v.strJobTitleDesc = c.strJobTitleDesc; } else { return(HttpNotFound()); } } else { dc.TJobTitles.Add(c); } dc.SaveChanges(); status = true; message = "Data Is Successfully Saved."; } } else { message = "Error! Please try again."; } return(new JsonResult { Data = new { status = status, message = message } }); }