Beispiel #1
0
        public async Task <Specialty> Create(Specialty speciality)
        {
            List <Task> tasks = new List <Task>();

            var facultyIdExists = _facultyRepository.GetById(speciality.FacultyId);

            tasks.Add(facultyIdExists);
            var uniqueId = _specialtyRepository.GetById(speciality.Id);

            tasks.Add(uniqueId);
            var uniqueName = _specialtyRepository.GetByName(speciality.Name);

            tasks.Add(uniqueName);

            await Task.WhenAll(tasks);

            var lectorIdExists = _lectorRepository.GetById(speciality.LectorId) != null;

            if (facultyIdExists.Result != null && lectorIdExists && uniqueId.Result == null && uniqueName.Result == null)
            {
                return(await _specialtyRepository.Create(speciality));
            }
            else
            {
                throw new Exception();
            }
        }
Beispiel #2
0
 public async Task <Lector> GetById(int lectorId)
 {
     return(await _lectorRepository.GetById(lectorId));
 }
Beispiel #3
0
 public Lector GetLectorId(int Id)
 {
     return(_lectorRepository.GetById(Id));
 }