Beispiel #1
0
        public ActionResult Update(GrammarNihongo model)
        {
            try
            {
                var a = model.Grammar;

                a                     = a.Replace("<", "<ruby>");
                a                     = a.Replace(">", "</ruby>");
                a                     = a.Replace("{", "<rt>");
                a                     = a.Replace("}", "</rt>");
                model.Grammar         = a;
                db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                ModelState.Clear();
                ModelState.AddModelError("", "Update thành công!");
            }
            catch
            {
                ModelState.AddModelError("", "Update thất bại!");
            }
            ViewBag.第課List = new SelectList(db.第課_Table, "第課ID", "第課Name");

            return(View("Index"));
        }
Beispiel #2
0
        public ActionResult Insert(GrammarNihongo model)
        {
            try
            {
                var a = model.Grammar;

                a             = a.Replace("<", "<ruby>");
                a             = a.Replace(">", "</ruby>");
                a             = a.Replace("{", "<rt>");
                a             = a.Replace("}", "</rt>");
                model.Grammar = a;
                db.GrammarNihongoes.Add(model);
                db.SaveChanges();
                ModelState.Clear();
                ModelState.AddModelError("", "Thêm thành công!");
            }
            catch
            {
                ModelState.AddModelError("", "Thêm thất bại!");
            }
            ViewBag.第課List = new SelectList(db.第課_Table, "第課ID", "第課Name");

            return(View("Index"));
        }