Esempio n. 1
0
        public async Task <ActionResult> DeleteRange([FromForm] List <int> courseIds, [FromForm] List <int> studentIds)
        {
            if (courseIds.Count() != studentIds.Count())
            {
                return(BadRequest());
            }
            for (int i = 0; i < courseIds.Count(); i++)
            {
                var sc = await _studentCourseRepository.LoadEntitiesAsIQueryable(x => x.CourseId == courseIds[i] && x.StudentId == studentIds[i])
                         .FirstOrDefaultAsync();

                if (sc == null)
                {
                    return(NotFound());
                }
                await _studentCourseRepository.DeleteEntityAsync(sc);
            }
            return(NoContent());
        }