Example #1
0
        public async Task <IActionResult> Create(CourseCategoryVM vm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //Create
                    if (vm.ID == 0)
                    {
                        var model = _mapper.Map <CourseCategories>(vm);
                        await _courseCategoryService.CreateAsync(model);

                        ViewBag.IsSuccess = true;
                        return(RedirectToAction(nameof(Index)));
                    }
                    else
                    {
                        var model = _mapper.Map <CourseCategories>(vm);
                        await _courseCategoryService.UpdateAsync(model);

                        ViewBag.IsSuccess = true;
                        return(RedirectToAction(nameof(Index)));
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.IsSuccess = false;
                    return(View(vm));
                }
            }
            return(View(vm));
        }
Example #2
0
        public IActionResult EgitimciGoruntule(int id)
        {
            CourseCategoryVM courseCategoryVM = new CourseCategoryVM()
            {
                Educator = rEducator.GetBy(r => r.ID == id),
                Courses  = rCourse.GetAll(x => x.EducatorID == id).ToList()
            };

            return(View(courseCategoryVM));
        }
Example #3
0
        public IActionResult Index()
        {
            string uyeid = User.Claims.FirstOrDefault(f => f.Type == ClaimTypes.Sid).Value;
            IEnumerable <CourseMember> courseMembers    = rCourseMember.GetAllLazy(x => x.MemberId == Convert.ToInt32(uyeid), includeProperties: "Course");
            CourseCategoryVM           courseCategoryVM = new CourseCategoryVM
            {
                courseMember = courseMembers,
                Courses      = rCourse.GetAll().OrderByDescending(s => s.Score).ToList()
            };

            return(View(courseCategoryVM));
        }
Example #4
0
        public IActionResult Index(string search = null)
        {
            if (!string.IsNullOrEmpty(search))
            {
                return(RedirectToAction("SearchPage", new { search }));
            }
            var user = User;
            CourseCategoryVM courseCategoryVM = new CourseCategoryVM
            {
                Courses    = rCourse.GetAll().OrderByDescending(s => s.Score).ToList(),
                Categories = rCategory.GetAll().ToList(),
                //Educators = rEducator.GetAll().ToList(),
                //Members = rMember.GetAll().ToList(),
            };

            ViewBag.Toplamuye     = myContext.Member.Count();
            ViewBag.Toplamegitmen = myContext.Educator.Count();
            return(View(courseCategoryVM));
        }
Example #5
0
        public IActionResult Create(int ID)
        {
            var vm = new CourseCategoryVM();

            if (ID == 0)
            {
                vm.listCourseCategory = _courseCategoryService.GetAll();
            }
            else
            {
                var modelcourse = _courseCategoryService.GetById(ID);
                if (modelcourse == null)
                {
                    return(NotFound());
                }
                vm = _mapper.Map <CourseCategoryVM>(modelcourse);
                vm.listCourseCategory = _courseCategoryService.GetAll();
            }

            return(View(vm));
        }
Example #6
0
        public IActionResult Courses(int id)
        {
            Category        category      = rCategory.GetBy(x => x.Id == id);
            List <Category> Subcategories = null;

            if (category.ParentID == null)
            {
                Subcategories = myContext.Category.Include(x => x.SubCategories).Include(x => x.Courses).ToList();
            }
            List <Course>   courses    = rCourse.GetAll(x => x.CategoryID == id).ToList();
            List <Category> categories = myContext.Category.Include(x => x.SubCategories).ToList();

            CourseCategoryVM courcatVM = new CourseCategoryVM
            {
                Courses     = courses,
                Categories  = categories,
                Scategories = Subcategories
            };

            return(View(courcatVM));
        }
Example #7
0
        public IActionResult Index()
        {
            var courses = new CourseCategoryVM();

            return(View(courses));
        }
Example #8
0
        public IActionResult Courses(int id, string sortOrder, int?page)
        {
            //List<Course> lastCourse = new List<Course>();
            List <Course>   courses    = new List <Course>();
            List <Category> categories = myContext.Category.Include(x => x.SubCategories).ToList();

            if (User.Identity.IsAuthenticated && User.Claims.FirstOrDefault(f => f.Type == ClaimTypes.Role).Value == "uye")
            {
                string uyeid = User.Claims.FirstOrDefault(f => f.Type == ClaimTypes.Sid).Value;
                List <CourseMember> courseMembers = rCourseMember.GetAll(x => x.MemberId == Convert.ToInt32(uyeid)).ToList();
                List <int>          courseInt     = new List <int>();

                foreach (Course item in rCourse.GetAll(x => x.CategoryID == id).ToList())
                {
                    courseInt.Add(item.Id);
                }

                List <int> courseMemberInt = new List <int>();
                foreach (CourseMember item in courseMembers)
                {
                    courseMemberInt.Add((int)item.CourseId);
                }
                IEnumerable <int> fark = new List <int>();
                fark = courseInt.Except(courseMemberInt);


                foreach (var item in fark)
                {
                    Course c = rCourse.GetBy(x => x.Id == item && x.State == true);
                    if (c != null)
                    {
                        courses.Add(c);
                    }
                }
            }
            else
            {
                courses = rCourse.GetAll(x => x.CategoryID == id && x.State == true).ToList();
            }

            Category        category      = rCategory.GetBy(x => x.Id == id);
            List <Category> Subcategories = null;

            if (category.ParentID == null)
            {
                Subcategories = myContext.Category.Include(x => x.SubCategories).Include(x => x.Courses).ToList();
            }
            //pagination
            var pageNumber = page ?? 1;
            int pageSize   = 2;

            ViewBag.dgr = pageNumber;
            IEnumerable <Course> onePage = courses.ToPagedList(pageNumber, pageSize);

            pageSize = (int)Math.Ceiling(courses.Count / (double)pageSize);


            CourseCategoryVM courcatVM = new CourseCategoryVM
            {
                CoursesPage = onePage,
                PageSize    = pageSize,
                Pagenumber  = pageNumber,
                Courses     = courses,
                Category    = category,
                Categories  = categories,
                Scategories = Subcategories
            };

            return(View(courcatVM));
        }
Example #9
0
        public IActionResult CoursesSort(int id, string sortOrder, string currentFilter, string searchString, int?pageNumber)
        {
            ViewData["CurrentSort"]  = sortOrder;
            ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "Score" : "";
            ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date";
            ViewBag.catid            = id;
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            List <Course> courses = new List <Course>();

            if (User.Identity.IsAuthenticated && User.Claims.FirstOrDefault(f => f.Type == ClaimTypes.Role).Value == "uye")
            {
                string uyeid = User.Claims.FirstOrDefault(f => f.Type == ClaimTypes.Sid).Value;
                List <CourseMember> courseMembers = rCourseMember.GetAll(x => x.MemberId == Convert.ToInt32(uyeid)).ToList();
                List <int>          courseInt     = new List <int>();
                foreach (Course item in rCourse.GetAll(x => x.CategoryID == id).ToList())
                {
                    courseInt.Add(item.Id);
                }

                List <int> courseMemberInt = new List <int>();
                foreach (CourseMember item in courseMembers)
                {
                    courseMemberInt.Add((int)item.CourseId);
                }
                IEnumerable <int> fark = new List <int>();
                fark = courseInt.Except(courseMemberInt);


                foreach (var item in fark)
                {
                    Course c = myContext.Course.FirstOrDefault(x => x.Id == item && x.State == true);
                    if (c != null)
                    {
                        courses.Add(c);
                    }
                }
            }
            else
            {
                courses = rCourse.GetAll(x => x.CategoryID == id).ToList();
            }
            if (!String.IsNullOrEmpty(searchString))
            {
                courses = courses.Where(s => s.Name.ToUpper().Contains(searchString.ToUpper()) ||
                                        s.Title.ToUpper().Contains(searchString.ToUpper()) || s.Description.ToUpper().Contains(searchString.ToUpper())).ToList();
            }
            switch (sortOrder)
            {
            case "Score":
                courses = courses.OrderByDescending(s => s.Score).ToList();    //En çok Puan
                break;

            case "Student":
                courses = courses.OrderByDescending(s => s.NumberOfStudent).ToList();    //En çok öğrenci
                break;

            case "Date":
                courses = courses.OrderBy(s => s.Duration).ToList();     // En yeni
                break;

            case "date_desc":
                courses = courses.OrderByDescending(s => s.Duration).ToList();    // En eski
                break;

            default:
                courses = courses.OrderBy(s => s.Name).ToList();    //İsim
                break;
            }
            int pageSize = 2;

            ViewBag.dgr = pageNumber;

            CourseCategoryVM courcat = new CourseCategoryVM()
            {
                CourseList = PaginatedList <Course> .Create(courses, pageNumber ?? 1, pageSize),
                Tags       = rTag.GetAll(x => x.CategoryId == id).ToList(),
                Categories = myContext.Category.Include(x => x.SubCategories).ToList()
            };

            return(View(courcat));
        }