public async Task AddBloodDonationAsync(DateTime dateOfDonation, int volume, string donorPesel,
                                                string personnelPesel)
        {
            var guid  = Guid.NewGuid();
            var donor = await donorRepository.GetAsync(donorPesel);

            if (donor == null)
            {
                throw new UserNotFoundException($"{nameof(donor)} not found.");
            }

            var personnel = await personnelRepository.GetAsync(personnelPesel);

            if (personnel == null)
            {
                throw new UserNotFoundException($"{nameof(personnel)} not found.");
            }

            var bloodType = donor.BloodType;

            donor.UpdateTimeOfLastDonation(dateOfDonation);
            await donorRepository.UpdateAsync(donor);

            var bloodDonation = new BloodDonation(guid, dateOfDonation, volume, bloodType, donor, personnel);
            await bloodDonationRepository.AddAsync(bloodDonation);
        }
Ejemplo n.º 2
0
        public async Task <DonorDTO> GetAsync(string pesel)
        {
            var donor = await donorRepository.GetAsync(pesel);

            return(mapper.Map <Donor, DonorDTO>(donor));
        }
Ejemplo n.º 3
0
        public async Task <DonorDto.Response> Get([FromQuery] int cityId, [FromQuery] int bloodGroupId)
        {
            var donor = await _donorRepository.GetAsync(cityId, bloodGroupId);

            return(_mapper.Map <DonorDto.Response>(donor));
        }