Beispiel #1
0
 public ActionResult GetData2(ClazzCriteria c)
 {
     var m = new LigerGridModel();
     this.BeforeGetData(c);
     var r = this.Service.FindByCriteria2(c);
     this.AfterGetData(m, c, r);
     m.Total = r.RecordCount;
     r.Data.ForEach(o => {
         this.AddRowToGridModel(m, o);
     });
     this.AfterBuildGridModel(m, c, r);
     return this.Json(m, JsonRequestBehavior.AllowGet);
 }
Beispiel #2
0
partial         void BeforeGetData(ClazzCriteria c);
Beispiel #3
0
partial         void AfterGetData(LigerGridModel gm, ClazzCriteria c, PagedModel<Clazz> pm);
Beispiel #4
0
partial         void AfterBuildGridModel(LigerGridModel gm, ClazzCriteria c, PagedModel<Clazz> pm);
Beispiel #5
0
        public PagedModel<Clazz> FindByCriteria(ClazzCriteria c)
        {
            PagedModel<Clazz> m = new PagedModel<Clazz>();
            var r = this.Repository.FindByCriteria(c);
            if(!String.IsNullOrEmpty(c.sortname)){
            if(c.sortname.ToLower().Equals("id")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.Id);
                }else{
                    r = r.OrderByDescending(o=>o.Id);
                }
            }
            if(c.sortname.ToLower().Equals("name")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.Name);
                }else{
                    r = r.OrderByDescending(o=>o.Name);
                }
            }
            if(c.sortname.ToLower().Equals("semester")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.Semester);
                }else{
                    r = r.OrderByDescending(o=>o.Semester);
                }
            }
            if(c.sortname.ToLower().Equals("studentqty")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.StudentQty);
                }else{
                    r = r.OrderByDescending(o=>o.StudentQty);
                }
            }
            if(c.sortname.ToLower().Equals("limitedqty")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.LimitedQty);
                }else{
                    r = r.OrderByDescending(o=>o.LimitedQty);
                }
            }
            if(c.sortname.ToLower().Equals("teachera")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.TeacherA);
                }else{
                    r = r.OrderByDescending(o=>o.TeacherA);
                }
            }
            if(c.sortname.ToLower().Equals("teacherb")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.TeacherB);
                }else{
                    r = r.OrderByDescending(o=>o.TeacherB);
                }
            }
            if(c.sortname.ToLower().Equals("master")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.Master);
                }else{
                    r = r.OrderByDescending(o=>o.Master);
                }
            }
            if(c.sortname.ToLower().Equals("governor")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.Governor);
                }else{
                    r = r.OrderByDescending(o=>o.Governor);
                }
            }
            if(c.sortname.ToLower().Equals("opendate")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.OpenDate);
                }else{
                    r = r.OrderByDescending(o=>o.OpenDate);
                }
            }
            if(c.sortname.ToLower().Equals("closeddate")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.ClosedDate);
                }else{
                    r = r.OrderByDescending(o=>o.ClosedDate);
                }
            }
            if(c.sortname.ToLower().Equals("finisheddate")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.FinishedDate);
                }else{
                    r = r.OrderByDescending(o=>o.FinishedDate);
                }
            }
            if(c.sortname.ToLower().Equals("isopen")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.IsOpen);
                }else{
                    r = r.OrderByDescending(o=>o.IsOpen);
                }
            }
            if(c.sortname.ToLower().Equals("isclosed")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.IsClosed);
                }else{
                    r = r.OrderByDescending(o=>o.IsClosed);
                }
            }
            if(c.sortname.ToLower().Equals("isfinished")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.IsFinished);
                }else{
                    r = r.OrderByDescending(o=>o.IsFinished);
                }
            }
            if(c.sortname.ToLower().Equals("createtime")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.CreateTime);
                }else{
                    r = r.OrderByDescending(o=>o.CreateTime);
                }
            }
            if(c.sortname.ToLower().Equals("updatetime")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.UpdateTime);
                }else{
                    r = r.OrderByDescending(o=>o.UpdateTime);
                }
            }
            if(c.sortname.ToLower().Equals("kickoffdate")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.KickOffDate);
                }else{
                    r = r.OrderByDescending(o=>o.KickOffDate);
                }
            }

            }

            m.RecordCount = r.Count();
            if (c.pagesize.HasValue) {
                int page = c.page ?? 1;
                int pageCount = m.RecordCount / c.pagesize.Value;
                if (m.RecordCount % c.pagesize.Value > 0) {
                    pageCount++;
                }
                int skip = (page - 1) * c.pagesize.Value;
                if (skip > 0) {
                    r = r.Skip(skip);
                }
                r = r.Take(c.pagesize.Value);
            }

            m.Data = r.ToList();
            return m;
        }