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); }
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)); }