public ActionResult Edit(int id = 0)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ElectiveOrgStudent.Edit();

                if (id != 0)
                {
                    var tb = (from p in db.Table <Entity.tbElectiveOrgStudent>()
                              where p.Id == id
                              select new Dto.ElectiveOrgStudent.Edit
                    {
                        Id = p.Id,
                        ElectiveOrgId = p.tbElectiveOrg.Id,
                        ClassId = p.tbStudent.Id
                    }).FirstOrDefault();
                    if (tb != null)
                    {
                        vm.ElectiveOrgStudentEdit = tb;
                    }
                }

                return(View(vm));
            }
        }
        public ActionResult Edit(Models.ElectiveOrgStudent.Edit vm)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var error = new List <string>();
                if (error.Count == decimal.Zero)
                {
                    if (vm.ElectiveOrgStudentEdit.Id == 0)
                    {
                        var tb = new Entity.tbElectiveOrgStudent();
                        tb.tbElectiveOrg = db.Set <Entity.tbElectiveOrg>().Find(vm.ElectiveOrgStudentEdit.ElectiveOrgId);
                        //tb.tbStudent = db.Set<Basis.Entity.tbClass>().Find(vm.ElectiveOrgStudentEdit.ClassId);
                        db.Set <Entity.tbElectiveOrgStudent>().Add(tb);
                        if (db.SaveChanges() > 0)
                        {
                            XkSystem.Areas.Sys.Controllers.SysUserLogController.Insert("添加了选课班级");
                        }
                    }
                    else
                    {
                        var tb = (from p in db.Table <Entity.tbElectiveOrgStudent>()
                                  where p.Id == vm.ElectiveOrgStudentEdit.Id
                                  select p).FirstOrDefault();
                        if (tb != null)
                        {
                            if (db.SaveChanges() > 0)
                            {
                                XkSystem.Areas.Sys.Controllers.SysUserLogController.Insert("修改了选课班级");
                            }
                        }
                        else
                        {
                            error.AddError(Resources.LocalizedText.MsgNotFound);
                        }
                    }
                }

                return(Code.MvcHelper.Post(error));
            }
        }