예제 #1
0
        public void Remove(Major major)
        {
            if (major == null)
            {
                throw new ArgumentNullException("major");
            }

            if (major.Students.Count > 0)
            {
                throw new ForeignKeyEntityException("This major could not be removed. It has one or more students associated with it.");
            }

            _majorRepository.Remove(major);
        }
예제 #2
0
        public async Task <IActionResult> DeleteMajor(int id)
        {
            var major = await repository.GetMajor(id, includeRelated : false);

            if (major == null)
            {
                return(NotFound());
            }

            repository.Remove(major);
            await unitOfWork.CompleteAsync();

            return(Ok(id));
        }