public void InsertOrUpdate(Competency cpt) { if (cpt.CompetencyId == 0) //new { context.Competencies.Add(cpt); } else //edit { context.Entry(cpt).State = EntityState.Modified; } this.Save(); }
public JsonResult Create(string competencyName, string competencyHeaderName) { CompetencyHeader header = (from c in headersDb.All where c.Name == competencyHeaderName select c).SingleOrDefault(); if (header != null) { Competency newComp = new Competency { Name = competencyName, CompetencyHeader = header }; competencyDb.InsertOrUpdate((newComp)); } //if (ModelState.IsValid) //{ // competencyDb.InsertOrUpdate(competency); // return RedirectToAction("Index"); //} //ViewBag.CompetencyHeaderId = new SelectList(headersDb.All, "CompetencyHeaderId", "Name", competency.CompetencyHeaderId); //return View(competency); return Json("ok"); }
public void Delete(Competency cpt) { context.Competencies.Remove(cpt); this.Save(); }
public ActionResult DeleteConfirmed(Competency cpt) { db.Delete(cpt); return RedirectToAction("Index"); }