Exemplo n.º 1
0
        public ActionResult Create(Subject subject)
        {
            if (ModelState.IsValid)
            {
                _subjectDbContext.dbSet.Add(subject);
                _subjectDbContext.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(subject);
        }
Exemplo n.º 2
0
 public ActionResult AddNewSubject(Subject subject)
 {
     if (ModelState.IsValid)
     {
         _subjectDbContext.dbSet.Add(subject);
         _subjectDbContext.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag["errorMessage"] = "Error with model.";  //This message isn't used. Verify data client.
     return View( GetSubjectViewList());
 }
Exemplo n.º 3
0
        //
        //constructor
        //
        public SubjectView(Subject subject, string splitStr)
        {
            //get Father id from string to List
            this.ancestorIdList = Helper.SeparateByString(subject.ancestorIdSplitStr, splitStr);
            this.title          = subject.title;
            this.id             = subject.id;

            //the next generation ancestorsIds
            if (subject.ancestorIdSplitStr != null)
            {
                this.childrenId = subject.ancestorIdSplitStr + splitStr;
            }
            this.childrenId += subject.id;
        }
Exemplo n.º 4
0
 public ActionResult Edit(Subject subject)
 {
     if (ModelState.IsValid)
     {
         _subjectDbContext.Entry(subject).State = EntityState.Modified;
         _subjectDbContext.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(subject);
 }