Exemple #1
0
        public ActionResult CreateMenu([FromBody] MenuDto menu)
        {
            if (menu == null)
            {
                return(BadRequest());
            }
            var menuEntity = _mapper.Map <Menu>(menu);

            _menurepository.AddMenu(menuEntity);
            _menurepository.Save();
            var menutoReturn = _mapper.Map <MenuDto>(menuEntity);

            return(CreatedAtRoute("getMenu",
                                  new { menuId = menutoReturn.Id }, menutoReturn));
        }
        public ActionResult CreateCourse([FromBody] CourseDto course)
        {
            if (course == null)
            {
                return(BadRequest());
            }
            var courseEntity = _mapper.Map <Courses>(course);

            _menurepository.AddCourse(courseEntity);
            _menurepository.Save();
            var courseToReturn = _mapper.Map <CourseDto>(courseEntity);

            return(CreatedAtRoute("getCourse",
                                  new { courseId = courseToReturn.Id }, courseToReturn));
        }