Ejemplo n.º 1
0
        /// <summary>
        /// this should be a method on the event class I think
        /// </summary>
        private EventModel EventModelFromEvent(Event ev, Person currentPerson = null)
        {
            var organiser = Session.Load<User>(ev.CreatedBy);
            var myInvitation = ev.Invitations.FirstOrDefault(invitation => invitation.PersonId == currentPerson.Id);

            return new EventModel
            {
                Id = ev.Id,
                CreatedByUserName = organiser.UserName,
                CreatedBy = organiser.Id,
                ReadOnly = organiser.Id != GetCurrentUserId(),
                Date = ev.Date,
                Time = ev.Time,
                Description = ev.Description,
                Latitude = ev.Latitude,
                Longitude = ev.Longitude,
                Venue = ev.Venue,
                Score = ev.PercentageScore(),
                Zoom = ev.Zoom,
                MyResponse = myInvitation == null ? InvitationResponse.No : myInvitation.Response,
                Invitations = (from i in ev.Invitations
                               let person = Session.Load<Person>(i.PersonId)
                               let friend = GetFriendFromPerson(currentPerson, i.PersonId)
                               select new InvitationModel
                               {
                                   IsCurrentUser = person.Id == currentPerson.Id,
                                   Email = person.EmailAddress,
                                   PersonId = person.Id,
                                   Rating = friend == null ? 0 : friend.Rating,
                                   EmailSent = i.EmailSent,
                                   Response = i.Response,
                                   EventId = ev.Id
                               }).ToList()
            };
        }
Ejemplo n.º 2
0
 private Friend GetFriendFromPerson(Person person, string friendPersonId)
 {
     if (person == null)
         return null;
     return person.Friends.SingleOrDefault(f => f.PersonId == friendPersonId);
 }