public async Task <int> AddAsync(MissedClass missedClass) { if (missedClass == null) { throw new BusinessLogicException(nameof(missedClass)); } var student = await _students.GetByIdAsync(missedClass.StudentId); if (student == null) { throw new BusinessLogicException("Student not found"); } var lesson = await _classes.GetByIdAsync(missedClass.ClassId); if (lesson == null) { throw new BusinessLogicException("Class not found"); } var dto = _mapper.Map <MissedLecturesDto>(missedClass); await _missedClasses.AddAsync(dto); return(dto.Id); }
public async Task <int> AddAsync(Class item) { if (item == null) { throw new BusinessLogicException(nameof(item)); } var sameTimeClasses = await _classes.GetAll() .Where(lesson => lesson.StartDate < item.EndDate || item.StartDate < lesson.EndDate) .ToListAsync(); var isCabinetTaken = sameTimeClasses .Any(lesson => lesson.CabinetId == item.CabinetId); if (isCabinetTaken) { throw new BusinessLogicException("Cabinet is already taken"); } var isLecturerBusy = sameTimeClasses .Any(lesson => lesson.LecturerId == item.LecturerId); if (isLecturerBusy) { throw new BusinessLogicException("Lecturer has other class at that time"); } var dto = _mapper.Map <ClassDto>(item); await _classes.AddAsync(dto); return(dto.Id); }
public async Task <int> AddAsync(Group item) { if (item == null) { throw new BusinessLogicException(nameof(item)); } if (string.IsNullOrEmpty(item.Name)) { throw new BusinessLogicException("Group name can't be empty"); } var dto = _mapper.Map <GroupDto>(item); await _groups.AddAsync(dto); return(dto.Id); }
public async Task <int> AddAsync(Subject subject) { if (subject == null) { throw new BusinessLogicException(nameof(subject)); } if (string.IsNullOrEmpty(subject.Name)) { throw new BusinessLogicException(nameof(subject.Name)); } var dto = _mapper.Map <SubjectDto>(subject); await _subjects.AddAsync(dto); return(dto.Id); }
public async Task <int> AddAsync(Lecturer lecturer) { if (lecturer == null) { throw new BusinessLogicException(nameof(lecturer)); } if (string.IsNullOrEmpty(lecturer.FirstName)) { throw new BusinessLogicException(nameof(lecturer.FirstName)); } if (string.IsNullOrEmpty(lecturer.LastName)) { throw new BusinessLogicException(nameof(lecturer.LastName)); } var dto = _mapper.Map <LecturerDto>(lecturer); await _persons.AddAsync(dto); return(dto.Id); }
public async Task <int> AddAsync(Student student) { if (student == null) { throw new BusinessLogicException(nameof(student)); } if (string.IsNullOrEmpty(student.FirstName)) { throw new BusinessLogicException(nameof(student.FirstName)); } if (string.IsNullOrEmpty(student.LastName)) { throw new BusinessLogicException(nameof(student.LastName)); } var dto = _mapper.Map <StudentDto>(student); await _students.AddAsync(dto); return(dto.Id); }
public async Task AddAsync(IFingerprint model) { await _store.AddAsync((TFingerprint)model); }
public async Task AddAsync(T entity, CancellationToken cancellationToken = default) { entity = Initialize(entity); await _store.AddAsync(entity, cancellationToken); }