public static void Split(int ClassId, int By)
        {
            string moduleSettings = ModuleConfig.GetSettings();
            Data.DogClasses dc = new Data.DogClasses(moduleSettings);
            List<DogClasses> dclist = new List<DogClasses>();

            DataSet ds = dc.getDogsInClass(ClassId);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                dclist.Add(new DogClasses(row));
            }

            dclist = dclist.OrderBy(t => t.RO).ToList();
            int split = (int)Math.Truncate( (double)dclist.Count() / By);
            var remainder = dclist.Count() - (split * By );

            int splitLength = (int)split;
            ShowClasses showClass = new ShowClasses(ClassId);
            showClass.Part = 1;
            showClass.Update();
            var spt = splitLength;

            var j = Judge.getJudgeForClass(ClassId);
            var splitCnt = 2;
            for (var i = 1; i< By; i++)
            {
                if (i + 1 == By) { splitLength += remainder; }

                var copyid = showClass.copy(true);
                var splitClass = new ShowClasses(copyid);
                splitClass.ClassNo = showClass.ClassNo;
                splitClass.Position = showClass.Position;
                splitClass.RingID = showClass.RingID;
                splitClass.Part = splitCnt;
                splitClass.Update();
                ShowClasses.updateJudgeClasses(copyid, j.ID);

                for (int dogCnt = 0; dogCnt < splitLength; dogCnt++)
                {
                    var dogclass = dclist.ElementAt(  dogCnt + (int)spt);
                    dc.UpdateClassId(dogclass.ID, copyid);
                }
                spt += splitLength;
                splitCnt++;
            }
        }
        public static void CreateChampClasses(IEnumerable<ShowClasses> champClasses)
        {
            foreach (var champ in champClasses.ToList())
            {
                ShowClasses showClass = new ShowClasses(champ.ID);
                var baseName = (string.IsNullOrEmpty( showClass.ClassName ) ? "" :  showClass.ClassName.Replace(" Agility",""));
                showClass.ClassName = baseName + " Agility";
                showClass.Update();
                var newClsId = showClass.copy(true);

                ShowClasses newCls = new ShowClasses(newClsId);
                newCls.Part = showClass.Part + 1;
                newCls.ClassName = baseName + " Jumping";
                newCls.Update();
                DogClasses.CopyDogs(showClass.ID, newClsId);

                newClsId = newCls.copy(true);
                ShowClasses final = new ShowClasses(newClsId);
                final.Part = newCls.Part + 1;
                final.ClassName = baseName + " Final";
                final.Update();
                DogClasses.CopyDogs(showClass.ID, newClsId, 20, true);
            }
        }
        public JsonResult CopyClass(int clsId, int position, bool inserted = true)
        {
            ShowClasses showClass = new ShowClasses(clsId);
            showClass.Position = position;

            User u = new User();
            return Json(new
            {
                Status = 0,
                ClsID = showClass.copy(inserted),
                ClassNo = showClass.ClassNo
            });
        }