Esempio n. 1
0
        public async Task <ActionResult> CreateAsync([FromBody] CourseDto dto)
        {
            var course = await _courseRepository.LoadEntitiesAsIQueryable(x => x.CourseName == dto.CourseName).FirstOrDefaultAsync();

            if (course != null)
            {
                return(BadRequest());
            }
            course = _mapper.Map <Course>(dto);
            int couresId = Convert.ToInt32(DateTime.Now.ToString("MMddss"));

            course.CourseId = couresId;
            await _courseRepository.AddEntityAsync(course);

            return(NoContent());
        }