Exemplo n.º 1
0
        public ResultViewModel <DataDetails> GetByID(int ID, int Level, int PageSize, int PageIndex)
        {
            ResultViewModel <DataDetails> result
                = new ResultViewModel <DataDetails>();
            DataDetails details = new DataDetails();
            int         count   = 0;

            try
            {
                switch (Level)
                {
                case 1:
                    details.LevelDetails = mainCategoryService.GetByID(ID);
                    details.Childs       = subCategoryService.GetByParentID(out count, ID, PageIndex, PageSize).Select(i => i.ToHomeViewmodel()).ToList();
                    break;

                case 2:
                    details.LevelDetails = subCategoryService.GetByID(ID);
                    details.Childs       = trackService.GetByParentID(out count, ID, PageIndex, PageSize).Select(i => i.ToHomeViewmodel()).ToList();
                    break;

                case 3:
                    details.LevelDetails = trackService.GetByID(ID).ToViewModel();
                    details.Childs       = courseService.GetByParentID(out count, ID, PageIndex, PageSize).Select(i => i.ToHomeViewmodel()).ToList();
                    //details.Childs = trackService.GetByID(ID).Courses.Select(i => i.Course.ToViewModel().ToHomeViewmodel()).ToList();
                    break;
                }
                result.Data      = details;
                result.Successed = true;
                result.Count     = count;
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "Something Went Wrong !!";
            }
            return(result);
        }