public async Task UpdateLastDonated(string pesel, DateTime dateTimeOfDonation) { var donor = await donorRepository.GetAsync(pesel); donor.UpdateTimeOfLastDonation(dateTimeOfDonation); await donorRepository.UpdateAsync(donor); }
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); }