public IActionResult UpdateSectionForCourse(Guid courseId, Guid id, [FromBody] SectionForUpdateDto section)
        {
            if (section == null)
            {
                _logger.LogError("SectionForUpdateDto object sent from client is null.");
                return(BadRequest("SectionForUpdateDto object is null"));
            }

            var course = _repository.Course.GetCourses(courseId, trackChanges: false);

            if (course == null)
            {
                _logger.LogInfo($"Coursewith id: {courseId} doesn't exist in the database.");
                return(NotFound());
            }

            var sectionEntity = _repository.Section.GetSection(courseId, id, trackChanges: true);

            if (sectionEntity == null)
            {
                _logger.LogInfo($"Section with id: {id} doesn't exist in the database.");
                return(NotFound());
            }

            _mapper.Map(section, sectionEntity);
            _repository.Save();

            return(NoContent());
        }
        public async Task <IActionResult> UpdateSectionForCourse(Guid courseId, Guid id, [FromBody] SectionForUpdateDto section)
        {
            var sectionEntity = HttpContext.Items["section"] as Section;

            _mapper.Map(section, sectionEntity);
            await _repository.SaveAsync();

            return(NoContent());
        }
        public async Task <IActionResult> UpdateSectionForCourse(Guid courseId, Guid id, [FromBody] SectionForUpdateDto section)
        {
            /*  if (section== null)
             * {
             *    _logger.LogError("SectionForUpdateDto object sent from client is null.");
             *    return BadRequest("SectionForUpdateDto object is null");
             * }
             *
             * if (!ModelState.IsValid)
             * {
             *    _logger.LogError("Invalid model state for the EmployeeForUpdateDto object");
             *    return UnprocessableEntity(ModelState);
             * }
             *
             *
             * var course = await _repository.Course.GetCoursesAsync(courseId, trackChanges: false);
             * if (course == null)
             * {
             *    _logger.LogInfo($"Coursewith id: {courseId} doesn't exist in the database.");
             *    return NotFound();
             * }
             *
             * var sectionEntity =await _repository.Section.GetSectionAsync(courseId, id, trackChanges: true);
             * if (sectionEntity == null)
             * {
             *    _logger.LogInfo($"Section with id: {id} doesn't exist in the database.");
             *    return NotFound();
             * } */

            var sectionEntity = HttpContext.Items["section"] as Section;

            _mapper.Map(section, sectionEntity);
            await _repository.SaveAsync();

            return(NoContent());
        }