/// <summary> /// Registers the attended for the specific event. /// </summary> /// <param name="occurence">The event occurence.</param> /// <param name="registration">The event registration.</param> /// <param name="attendee">The attendee.</param> /// <param name="amountPaid">The amount paid.</param> /// <param name="userProfile">The user profile.</param> /// <param name="sessionId">The session id.</param> /// <param name="context">The Object Context</param> /// <param name="discountCode">The Discount Code used</param> /// <param name="forcePayLater">Flag weather or not to force the PaymentRequired to true</param> public static void Add(EventOccurrence occurence, EventRegistration registration, EventAttendee attendee, decimal amountPaid, UserProfile userProfile, string sessionId, ObjectContext context, string discountCode, bool forcePayLater) { if (!string.IsNullOrEmpty(discountCode)) attendee.DiscountCodeId = FindDiscountCodeId(discountCode, occurence.Id, context); var paymentRequired = (forcePayLater || occurence.AllowPayOnSite && amountPaid == 0 && occurence.Cost > 0) ? true : false; occurence.RegisterAttendee(registration, attendee, amountPaid, paymentRequired); AddActivity(userProfile, attendee.Name, occurence, sessionId); UpdateProfileEventCart(userProfile); var notificationSubscriber = occurence.EventOccurrenceNotifications.SingleOrDefault(n => string.Equals(n.Email, attendee.Email.Value, System.StringComparison.OrdinalIgnoreCase)); if (notificationSubscriber != null) context.DeleteObject(notificationSubscriber); }
/// <summary> /// Adds an activity to the profile. /// </summary> /// <param name="userProfile">The user profile.</param> /// <param name="registrantName">Name of the registrant.</param> /// <param name="eventOccurrence">The event occurrence.</param> /// <param name="sessionId">The session id.</param> private static void AddActivity(UserProfile userProfile, PersonName registrantName, EventOccurrence eventOccurrence, string sessionId) { if (userProfile != null) { var location = eventOccurrence.OrgUnit != null ? eventOccurrence.OrgUnit.Name : string.Empty; var eventTitle = eventOccurrence.Event != null ? eventOccurrence.Event.Title : string.Empty; var activityDescription = string.Format(CultureInfo.InvariantCulture, ProfileActivityConstants.ActivityEventRegistration, registrantName, eventTitle, location); userProfile.Profile.AddActivity(userProfile.UserId, activityDescription, sessionId); } }
private static void UpdateProfileEventCart(UserProfile userProfile) { if (userProfile != null && userProfile.Profile != null) { userProfile.Profile.EventCart = null; userProfile.Profile.EventCartNotificationSent = null; userProfile.Profile.EventCartUpdated = null; } }
/// <summary> /// Determines whether the user is authorized to view the specified user profile. /// </summary> /// <param name="userProfile">The user profile.</param> /// <returns> /// <c>true</c> if the user is authorized to view the specified user profile; otherwise, <c>false</c>. /// </returns> public bool IsAuthorizedToView(UserProfile userProfile) { return Id == userProfile.User.Id; }