private void RegisterDonatorUserHairNotifications(ICollection <HairNotification> hairNotifications, NotifyDonatorUserEvent notifyDonatorUserEvent) { foreach (var hairNotification in hairNotifications) { var usersToHairNotification = _donatorUserRepository.GetToHairNotification(hairNotification.HairId, hairNotification.AmountHair); foreach (var userToNotification in usersToHairNotification) { var donatorUserHairNotification = new DonatorUserHairNotification(Guid.NewGuid(), userToNotification.DonatorUserId, hairNotification.Id); var donatorUserNotificationEvent = new DonatorUserNotificationEvent(userToNotification.Name, userToNotification.Email, NotificationsTypeConfiguration.TYPE_HAIR, $"{userToNotification.Color} - {userToNotification.Type}"); notifyDonatorUserEvent.AddDonatorUserNotificationEvent(donatorUserNotificationEvent); UpdateLastHairNotificationDonatorUser(userToNotification.DonatorUserId); _donatorUserHairNotificationRepository.Add(donatorUserHairNotification); } } }
private void RegisterDonatorUserBloodNotifications(ICollection <BloodNotification> bloodNotifications, NotifyDonatorUserEvent notifyDonatorUserEvent) { foreach (var bloodNotification in bloodNotifications) { var usersToBloodNotification = _donatorUserRepository.GetToBloodNotification(bloodNotification.BloodId, bloodNotification.AmountBlood); foreach (var userToNotification in usersToBloodNotification) { var donatorUserBloodNotification = new DonatorUserBloodNotification(Guid.NewGuid(), userToNotification.DonatorUserId, bloodNotification.Id); var donatorUserNotificationEvent = new DonatorUserNotificationEvent(userToNotification.Name, userToNotification.Email, NotificationsTypeConfiguration.TYPE_BLOOD, userToNotification.Type); notifyDonatorUserEvent.AddDonatorUserNotificationEvent(donatorUserNotificationEvent); UpdateLastBloodNotificationDonatorUser(userToNotification.DonatorUserId); _donatorUserBloodNotificationRepository.Add(donatorUserBloodNotification); } } }
private void AddHairNotifications(NotifyDonatorUserCommand command, Notification notification, NotifyDonatorUserEvent notifyDonatorUserEvent) { if (HasHairNotifications(command.HairNotifications)) { Guid?hairId = null; if (command.HairNotifications.Any(x => x.HairId == null)) { hairId = _hairRepository.GetAll().FirstOrDefault().Id; } foreach (var hairNotification in command.HairNotifications) { if (hairNotification.HairId == null) { hairNotification.HairId = hairId; } } RegisterHairNotifications(notification, command.HairNotifications); RegisterDonatorUserHairNotifications(notification.HairNotifications, notifyDonatorUserEvent); } }
private void AddBloodNotifications(NotifyDonatorUserCommand command, Notification notification, NotifyDonatorUserEvent notifyDonatorUserEvent) { if (HasBloodNotifications(command.BloodNotifications)) { RegisterBloodNotifications(notification, command.BloodNotifications); RegisterDonatorUserBloodNotifications(notification.BloodNotifications, notifyDonatorUserEvent); } }
private void AddBreastMilkNotifications(NotifyDonatorUserCommand command, Notification notification, NotifyDonatorUserEvent notifyDonatorUserEvent) { if (HasBreastMilkNotification(command.BreastMilkNotification)) { RegisterBreastMilkNotification(notification, command.BreastMilkNotification); RegisterDonatorUserBreastMilkNotification(notification.BreastMilkNotification, notifyDonatorUserEvent); } }
private void RegisterDonatorUserBreastMilkNotification(BreastMilkNotification breastMilkNotification, NotifyDonatorUserEvent notifyDonatorUserEvent) { var usersToBreastMilkNotification = _donatorUserRepository.GetToBreastMilkNotification(breastMilkNotification.AmountBreastMilk); foreach (var userDonatorToNotify in usersToBreastMilkNotification) { var donatorUserBreastMilkNotification = new DonatorUserBreastMilkNotification(Guid.NewGuid(), userDonatorToNotify.DonatorUserId, breastMilkNotification.Id); notifyDonatorUserEvent.AddDonatorUserNotificationEvent(new DonatorUserNotificationEvent(userDonatorToNotify.Name, userDonatorToNotify.Email, NotificationsTypeConfiguration.TYPE_BREASTMILK)); UpdateLastNotificationDonatorUser(userDonatorToNotify.DonatorUserId); _donatorUserBreastMilkNotificationRepository.Add(donatorUserBreastMilkNotification); } }
private NotifyDonatorUserEvent CreateInstanceToNotifyDonatorUserEvent(NotifyDonatorUserCommand command, out NotifyDonatorUserEvent notifyDonatorUserEvent) { var institutionUser = _institutionUserRepository.Get(command.InstitutionUserId); var institutionUserAddress = institutionUser.User.Address; if (institutionUserAddress != null) { notifyDonatorUserEvent = new NotifyDonatorUserEvent(institutionUser.FantasyName, institutionUserAddress.Street, institutionUserAddress.Number, institutionUserAddress.City, institutionUserAddress.State, institutionUserAddress.Country); } else { notifyDonatorUserEvent = new NotifyDonatorUserEvent(institutionUser.FantasyName); } return(notifyDonatorUserEvent); }