/// <summary> /// Finds the by tag. /// </summary> /// <param name="hotelDTOs">The hotel data transfer objects.</param> /// <param name="equatable">The interface for equals.</param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// <paramref name="hotelDTOs"/> /// or /// <paramref name="equatable"/> /// </exception> public HotelDto FindByTag(HotelDto[] hotelDTOs, IHotelDTOEquatable equatable) { if (ReferenceEquals(hotelDTOs, null)) { throw new ArgumentNullException(nameof(hotelDTOs)); } if (ReferenceEquals(equatable, null)) { throw new ArgumentNullException(nameof(equatable)); } return(hotelDTOs.FirstOrDefault((hotelDto) => equatable.Equals(hotelDto))); }
/// <summary> /// Finds the specified hotel data transfer object. /// </summary> /// <param name="hotelDtoForEquals">The hotel data transfer object for equals.</param> /// <returns>Found hotel data transfer object.</returns> public HotelDto Find(IHotelDTOEquatable hotelDtoForEquals) { Guard.ArgumentNotNull(nameof(hotelDtoForEquals), hotelDtoForEquals); IEnumerable <HotelDto> hotelDTOs = Mapper.Map <IEnumerable <HotelEntity>, IEnumerable <HotelDto> >(hotelRepository.GetAll()); foreach (HotelDto hotelDTO in hotelDTOs) { if (hotelDtoForEquals.Equals(hotelDTO)) { return(hotelDTO); } } return(null); }