예제 #1
0
        public Occasion UpdateOccasion(MeetUpEvent meetupEvent, Occasion occasion)
        {
            var eventDateTime = meetupEvent.Time.FromUnixTime();

            if (occasion.IsDeleted)
            {
                return(null);                    // if it deleted no point updating it
            }
            if (eventDateTime == occasion.OccasionDateTime && occasion.Title == meetupEvent.Name &&
                occasion.Description == meetupEvent.Description && meetupEvent.Venue.Name == occasion.Venue.Name &&
                meetupEvent.event_hosts.First().member_id == occasion.Host.MeetupMemberId)
            {
                return(occasion);
            }

            // we do not have enough data from api call to create a user so get the members if we don't have the host
            var host = _userAccountRepository.FindByMeetUpId(meetupEvent.event_hosts.First().member_id);

            if (host == null)
            {
                // get members
                _memberService.GetMembersFromMeetUp(true);  // force update we know there are new ones
                host = _userAccountRepository.FindByMeetUpId(meetupEvent.event_hosts.First().member_id);

                if (host == null)
                {
                    // this rrings alarm bells as the host can not be found anywhere and the event can not be scheduled
                    Log.Error("unable to create event as host can not be found");
                    return(null);   // if we still don't have the host don't update the event.
                }
            }

            occasion.Title       = meetupEvent.Name;
            occasion.Date        = eventDateTime.Date;
            occasion.Description = meetupEvent.Description;
            //occasion.MeetupLastUpdated = DateTime.Now;  is just for rsvps and not the event itself. comment so it won't be misused in future
            occasion.Hour    = eventDateTime.Hour;
            occasion.Min     = eventDateTime.Minute;
            occasion.Created = meetupEvent.created.FromUnixTime();
            if (occasion.Venue.MeetUpId != meetupEvent.Venue.Id)
            {
                occasion.VenueId = _venueFactory.MapVenue(meetupEvent.Venue).Id;
            }
            occasion.HostId = host.Id;
            return(occasion);
        }
예제 #2
0
        public UserAccount GetUser(long memberId)
        {
            var user = _userAccountRepository.FindByMeetUpId(memberId);

            if (user == null)
            {
                // need to update members to include this one
                _memberService.GetMembersFromMeetUp(true);  // we know there are new members so force update.
                user = _userAccountRepository.FindByMeetUpId(memberId);
            }
            return(user);
        }