Beispiel #1
0
        public int SaveBindingData(Base_DataBindViewModel dbModel)
        {
            var bdBindBll = new Base_DataBindBLL();
            List <Base_DataBind> dbList = new List <Base_DataBind>();

            if (dbModel.GenreId.Count() > 0)
            {
                foreach (string i in dbModel.GenreId)
                {
                    var mdl = new Base_DataBind
                    {
                        GenreId   = i,
                        GradeId   = dbModel.GradeId,
                        PeriodId  = dbModel.PeriodId,
                        SchoolId  = dbModel.SchoolId,
                        SubjectId = dbModel.SubjectId
                    };

                    //check if data exists
                    string whr   = bdBindBll.ArrayToWhere(mdl);
                    bool   exist = bdBindBll.GetBindingId("1=1 " + whr) != null;

                    if (!exist)   //not exists
                    {
                        dbList.Add(mdl);
                    }
                }
                if (dbList.Count > 0)
                {
                    return(SaveBindingModels(dbList));
                }
            }

            return(0);
        }
Beispiel #2
0
        /// <summary>
        /// get binded id that will be deleted.
        /// </summary>
        /// <param name="mdl"></param>
        /// <returns></returns>
        private int[] GetBindId(Base_DataBindViewModel mdl)
        {
            List <int> result = new List <int>();

            if (mdl.GenreId.Count == 0)
            {
                return(null);
            }

            var bind    = new Base_DataBind();
            var bindBLL = new Base_DataBindBLL();

            foreach (var i in mdl.GenreId)
            {
                bind = new Base_DataBind
                {
                    GenreId   = i,
                    GradeId   = mdl.GradeId,
                    PeriodId  = mdl.PeriodId,
                    SchoolId  = mdl.SchoolId,
                    SubjectId = mdl.SubjectId
                };

                string whr = bindBLL.ArrayToWhere(bind);

                var id = bindBLL.GetBindingId("1=1 " + whr);

                if (id != null)
                {
                    result.Add(int.Parse(id));
                }
            }

            return(result.ToArray());
        }
Beispiel #3
0
        public ActionResult lessonBindingData(string last_a, string[] upperids)
        {
            var bindBll = new  Base_DataBindBLL(BaseSchoolId);
            var jsn     = bindBll.GetDownLevels(last_a, upperids);

            return(Json(new { jsn }, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        /// <summary>
        /// get bindedid by 4 parameters.
        /// </summary>
        /// <param name="whr"></param>
        /// <returns></returns>
        public int GetBindId(string whr)
        {
            string bindid = new Base_DataBindBLL().GetBindingId(whr);

            if (bindid != null)
            {
                return(int.Parse(bindid));
            }

            return(-1);
        }
Beispiel #5
0
        /// <summary>
        ///  load lower data of one level--in data binding page.
        /// </summary>
        /// <param name="clickedId">last id of 'a' clicked: nj_942ce7a6dab347f8a24b4e3ff6003268</param>
        /// <param name="upperIds">upper a's ids:["abe98d00a0d04854902ac168e010da49"]</param>
        /// <returns></returns>
        public ActionResult loadBinding(string clickedId, string[] upperIds)
        {
            KeyValuePair <string, List <string> > result = new KeyValuePair <string, List <string> >("error", new List <string>());

            if (!string.IsNullOrEmpty(clickedId))
            {
                var dataBindBLL = new Base_DataBindBLL();
                result = dataBindBLL.GetDownLevel(clickedId, upperIds);
            }
            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        /// <summary>
        /// query lessons by clicked 'a'.
        /// </summary>
        /// <param name="bindId"></param>
        /// <param name="pg"></param>
        /// <param name="ttl"></param>
        /// <param name="pgsz"></param>
        /// <returns></returns>
        public BindingLessonViewModel QueryPagedLessons(Base_DataBind datas, int pg, int pgsz)
        {
            Base_DataBindBLL bindBll = new Base_DataBindBLL();
            string           whr     = " schoolid=1";
            int ttl = 0;

            whr += bindBll.ArrayToWhere(datas);
            var mdl = new BindingLessonViewModel()
            {
                TrainBaseLessons = _lessonBLL.Query(whr, pg, out ttl, 10),
                Pager            = Common.Utility.HtmlPager(10, pg, ttl, 5)
            };

            return(mdl);
        }
Beispiel #7
0
 public BasicDataSvc()
 {
     XueduanBLL = new BasePeriodBLL();
     BindingBLL = new Base_DataBindBLL("1");
 }