コード例 #1
0
 public void InsertOrUpdate(Competency cpt)
 {
     if (cpt.CompetencyId == 0) //new
     {
         context.Competencies.Add(cpt);
     }
     else //edit
     {
         context.Entry(cpt).State = EntityState.Modified;
     }
     this.Save();
 }
コード例 #2
0
        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");
        }
コード例 #3
0
 public void Delete(Competency cpt)
 {
     context.Competencies.Remove(cpt);
     this.Save();
 }
コード例 #4
0
 public ActionResult DeleteConfirmed(Competency cpt)
 {
     db.Delete(cpt);
     return RedirectToAction("Index");
 }