public PartialViewResult UnSubscribeFromCourse(int?courseId)
        {
            _courseService.DeleteSubscriber(courseId);
            var userId          = User.Identity.GetUserId();
            var journalToDelete = _journalService.GetJournalForAUser(userId, courseId.Value);

            _journalService.DeleteJournal(journalToDelete.Id);

            var courseDto = _courseService.GetCourse(courseId);

            ViewBag.Teacher = UserManager.FindById(courseDto.TutorId).UserName;
            var resultModel = Convert(courseDto);

            resultModel.Subscribed = false;
            return(PartialView("_SubscribeButton", resultModel));
        }
Exemple #2
0
        public PartialViewResult DeleteCourse(int?id)
        {
            CourseDto course = _courseService.GetCourse(id);
            IEnumerable <JournalDto> journals = _journalService.GetJournals().Where(c => c.CourseId.Equals(id));

            _courseService.DeleteCourse(course.Id);
            foreach (JournalDto journal in journals)
            {
                _journalService.DeleteJournal(journal.Id);
            }

            List <CourseDto> coursesDto = _courseService.GetCourses();
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <SpecializationDto, SpecializationViewModel>();
                cfg.CreateMap <CourseDto, CourseViewModel>();
            });
            IMapper mapper = config.CreateMapper();

            return(PartialView("_ListTable", mapper.Map <List <CourseDto>, List <CourseViewModel> >(coursesDto)));
        }
 public object DeleteJournal(Guid source)
 {
     return(controller.DeleteJournal(source));
 }
 public async Task DeleteJournal(string itemID)
 {
     await _journalService.DeleteJournal(itemID);
 }