예제 #1
0
 public UserUpdatedIntegrationEvent(Guid correlationId, Guid userId, bool serviceActive,
                                    AnnouncementSendingFrequency announcementSendingFrequency) : base(correlationId)
 {
     UserId        = userId;
     ServiceActive = serviceActive;
     AnnouncementSendingFrequency = announcementSendingFrequency;
 }
예제 #2
0
 public UserResponse(Guid id, string email, string picture, bool serviceActive,
                     int announcementPreferenceLimit, AnnouncementSendingFrequency announcementSendingFrequency,
                     IEnumerable <RoomForRentAnnouncementPreferenceResponse> roomForRentAnnouncementPreferences,
                     IEnumerable <FlatForRentAnnouncementPreferenceResponse> flatForRentAnnouncementPreferences)
     : base(id)
 {
     Email         = email;
     Picture       = picture;
     ServiceActive = serviceActive;
     AnnouncementPreferenceLimit        = announcementPreferenceLimit;
     AnnouncementSendingFrequency       = announcementSendingFrequency;
     RoomForRentAnnouncementPreferences = roomForRentAnnouncementPreferences.ToList().AsReadOnly();
     FlatForRentAnnouncementPreferences = flatForRentAnnouncementPreferences.ToList().AsReadOnly();
 }
예제 #3
0
 public UserRoomForRentAnnouncementPreferenceCreatedIntegrationEvent(Guid correlationId, DateTimeOffset creationDate,
                                                                     Guid userId, Guid roomForRentAnnouncementPreferenceId, string userEmail, Guid cityId, bool serviceActive,
                                                                     AnnouncementSendingFrequency announcementSendingFrequency, decimal?priceMin, decimal?priceMax,
                                                                     RoomType?roomType, IEnumerable <Guid> cityDistricts) : base(correlationId, creationDate)
 {
     UserId = userId;
     RoomForRentAnnouncementPreferenceId = roomForRentAnnouncementPreferenceId;
     UserEmail     = userEmail;
     CityId        = cityId;
     ServiceActive = serviceActive;
     AnnouncementSendingFrequency = announcementSendingFrequency;
     PriceMin      = priceMin;
     PriceMax      = priceMax;
     RoomType      = roomType;
     CityDistricts = cityDistricts.ToList().AsReadOnly();
 }
예제 #4
0
 public UserFlatForRentAnnouncementPreferenceCreatedIntegrationEvent(Guid correlationId, Guid userId,
                                                                     Guid flatForRentAnnouncementPreferenceId, string userEmail, Guid cityId, bool serviceActive,
                                                                     AnnouncementSendingFrequency announcementSendingFrequency, decimal?priceMin, decimal?priceMax,
                                                                     int?roomNumbersMin, int?roomNumbersMax, IEnumerable <Guid> cityDistricts) : base(correlationId)
 {
     UserId = userId;
     FlatForRentAnnouncementPreferenceId = flatForRentAnnouncementPreferenceId;
     UserEmail     = userEmail;
     CityId        = cityId;
     ServiceActive = serviceActive;
     AnnouncementSendingFrequency = announcementSendingFrequency;
     PriceMin       = priceMin;
     PriceMax       = priceMax;
     RoomNumbersMin = roomNumbersMin;
     RoomNumbersMax = roomNumbersMax;
     CityDistricts  = cityDistricts.ToList().AsReadOnly();
 }
예제 #5
0
        public async Task SendAnnouncementUrlsAsync(AnnouncementSendingFrequency announcementSendingFrequency)
        {
            var groupedAnnouncementPreferences = await GetGroupedAnnouncementPreferencesAsync(announcementSendingFrequency);

            var actionBlock = ConstructActionBlock();
            var tasks       = new List <Task>();

            foreach (var groupedAnnouncementPreference in groupedAnnouncementPreferences)
            {
                tasks.Add(actionBlock.SendAsync(groupedAnnouncementPreference));
            }

            await Task.WhenAll(tasks);

            actionBlock.Complete();
            await ClearSentAnnouncementUrlsAsync(groupedAnnouncementPreferences);
        }
예제 #6
0
 public static AnnouncementSendingFrequencyEnumeration ConvertToEnumeration(this AnnouncementSendingFrequency announcementSendingFrequency)
 {
     return(EnumerationBase.GetAll <AnnouncementSendingFrequencyEnumeration>()
            .SingleOrDefault(x => x.DisplayName.ToLower().Equals(announcementSendingFrequency.ToString().ToLower())));
 }
예제 #7
0
        private async Task <List <GroupedAnnouncementPreferences> > GetGroupedAnnouncementPreferencesAsync(AnnouncementSendingFrequency announcementSendingFrequency)
        {
            var groupedFlatFoRentAnnouncementPreferencesTask = _flatForRentAnnouncementPreferenceCosmosStore.Query()
                                                               .Where(x => x.ServiceActive && x.AnnouncementSendingFrequency == announcementSendingFrequency)
                                                               .GroupBy(x => x.UserId)
                                                               .Select(x => new GroupedFlatForRentAnnouncementPreferences(x.Key, x.ToList()))
                                                               .ToListAsync();
            var groupedRoomFoRentAnnouncementPreferencesTask = _roomForRentAnnouncementPreferenceCosmosStore.Query()
                                                               .Where(x => x.ServiceActive && x.AnnouncementSendingFrequency == announcementSendingFrequency)
                                                               .GroupBy(x => x.UserId)
                                                               .Select(x => new GroupedRoomForRentAnnouncementPreferences(x.Key, x.ToList()))
                                                               .ToListAsync();
            await Task.WhenAll(groupedFlatFoRentAnnouncementPreferencesTask, groupedRoomFoRentAnnouncementPreferencesTask);

            var groupedFlatFoRentAnnouncementPreferences = groupedFlatFoRentAnnouncementPreferencesTask.Result;
            var groupedRoomFoRentAnnouncementPreferences = groupedRoomFoRentAnnouncementPreferencesTask.Result;

            return
                ((from groupedFlatFoRentAnnouncementPreference in groupedFlatFoRentAnnouncementPreferences
                  join groupedRoomForRentAnnouncementPreference in groupedRoomFoRentAnnouncementPreferences on
                  groupedFlatFoRentAnnouncementPreference.UserId equals
                  groupedRoomForRentAnnouncementPreference.UserId into groupedAnnouncementPreferences
                  from sub in groupedAnnouncementPreferences
                  select new GroupedAnnouncementPreferences(
                      groupedFlatFoRentAnnouncementPreference.FlatForRentAnnouncementPreferences.First().UserEmail,
                      groupedFlatFoRentAnnouncementPreference.FlatForRentAnnouncementPreferences,
                      sub.RoomForRentAnnouncementPreferences)) as List <GroupedAnnouncementPreferences>);
        }