예제 #1
0
        public IActionResult Create([FromBody] Course model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var record = _coursesRepository.GetByName(model.Name);

            if (record != null)
            {
                return(Conflict(ResponseMessage.CourseAlreadyExists));
            }

            record = _mapper.Map <Courses>(model);

            _coursesRepository.Add(record);

            return(Ok());
        }