예제 #1
0
        public IActionResult AddSet(SetsViewModel model)
        {
            var courseToCreate = new CourseDto()
            {
                IDuser   = _userManager.GetBy(User.Identity.Name, User.Identity.Name).ID,
                name     = model.Name,
                describe = model.Describe,
                link     = ""
            };

            _courseServices.CreateCourse(courseToCreate);

            for (int i = 0; i < model.Term.Count(); i++)
            {
                VocabularyDto vocabularyToCreate = new VocabularyDto()
                {
                    define  = model.Term.ElementAt(i),
                    explain = model.DescribeTerm.ElementAt(i),
                    image   = ""
                };
                _vocabularyServices.CreateVocabulary(vocabularyToCreate);
                _vocabularyServices.CreateListVocabulary(_courseServices.GetNewestID(), _vocabularyServices.GetNewestID());
            }
            return(RedirectToAction("Index", "Home"));
        }
예제 #2
0
 public IEnumerable <Course> CreateCourse(CourseSelectView data)
 {
     if (data.account == null || data.account == "")
     {
         data.account = User.Identity.Name;
     }
     return(_courseServices.CreateCourse(data));
 }
예제 #3
0
 public IActionResult Post([FromBody] CourseEntity course)
 {
     _courseServices.CreateCourse(course);
     return(Ok(course));
 }