Beispiel #1
0
        private IEnumerable <Course> GetCourses(string RelationObject_ID,
                                                string RelationObjectType)
        {
            IQueryable <Course> courseQuery = null;

            if (RelationObjectType == null)
            {
                courseQuery = new List <Course>().AsQueryable();//Repository.GetAll();
            }
            else
            {
                var relationObjectType = ContextProvider.GetTypeByTableName(
                    RelationObjectType);

                /* if (obj.RelationObject_ID is string[])
                 *   obj.RelationObject_ID = (obj.RelationObject_ID as string[]).First();*/
                var relationObjectID =
                    LinqToSqlUtils.CorrectPKType(RelationObject_ID, relationObjectType);
                courseQuery = SiteObjectService
                              .GetByRelationObject <Course>(relationObjectType, relationObjectID);
                ViewData["SiteObject"] = SORepository.GetAll().First(so =>
                                                                     so.ID.Equals(relationObjectID) &&
                                                                     so.Type == RelationObjectType);
            }

            return(courseQuery.Where(c => c.IsActive)
                   .OrderBy(c => c.WebSortOrder)
                   .Select(c => new { c.Course_TC, c.Name })
                   .ToList()
                   .Select(c => new Course
            {
                Course_TC = c.Course_TC,
                Name = c.Name
            }));
        }
        public ActionResult ReverseRelationSorting(string className, string RelationObject_ID,
                                                   string RelationObjectType)
        {
            var type  = SiteObjectType.GetAll().First(x => x.ClassName == className);
            var model = new ReverseRelationSortingVM();

            model.ObjectType = type.SysName;
            model.ClassName  = className;
            if (RelationObject_ID == null)
            {
                return(View(model));
            }


            var objId =
                LinqToSqlUtils.CorrectPKType(RelationObject_ID, ContextProvider.GetTypeByTableName(
                                                 RelationObjectType));
            var relationObjectType = ContextProvider.GetTypeByTableName(
                RelationObjectType);
            var relationObjectID =
                LinqToSqlUtils.CorrectPKType(RelationObject_ID, relationObjectType);

            model.SiteObject = SORepository.GetAll().First(so =>
                                                           so.ID.Equals(relationObjectID) &&
                                                           so.Type == RelationObjectType);

            model.Relations = GetCourseRelations(type.Type, RelationObjectType, (int)objId);



            return(View(model));
        }
        public ActionResult Objects(string q, int?limit)
        {
            if (q.EndsWith(" "))
            {
                q = q.RemoveLast();
            }
            else
            {
                q += "%";
            }
            var names = SORepository.GetAll().Where(so =>
                                                    SqlMethods.Like(so.Name, q)).Take(limit ?? 10)
                        .ToList().Select(so => new {
                id   = so.ID,
                type = so.Type,
                name = so.Name
            });

            return(Json(names, JsonRequestBehavior.AllowGet));
        }