static CourseITAcademyStorage()
        {
            ParserITAcademy parserITAcademy = new ParserITAcademy();

            _course.AddRange((List <CoursesITAcademy>)parserITAcademy
                             .GetAllCourses(new CourseCategory()
            {
                Name  = CommonValues.programmirovanieCategoryItAcademy,
                Title = "Programs"
            }));
        }
Example #2
0
        public async Task <Result <IEnumerable <Course> > > AddRangeAsync()
        {
            var           listCategories = _parserITAcademy.GetCategories().Distinct();
            List <Course> listCourses    = new List <Course>();

            foreach (var el in listCategories)
            {
                listCourses.AddRange(_parserITAcademy.GetAllCourses(el));
            }
            var listCoursesDb = _mapper.Map <IEnumerable <CourseDb> >(listCourses);
            var result        = await _courseServiceDb.AddRangeAsync(listCoursesDb);

            return(result.IsSuccess ? Result <IEnumerable <Course> > .Ok(_mapper.Map <IEnumerable <Course> >(result.Data))
                : Result <IEnumerable <Course> > .Fail <IEnumerable <Course> >(result.Message));
        }