/// <summary> /// Save Comment /// </summary> /// <param name="comment">Comment</param> /// <returns>Comment</returns> public Comment Save(Comment comment) { if (null == comment) { throw new ArgumentNullException("search"); } var proc = new SocialSaveConversation() { Comment = comment.Body, Read = comment.Read, ParentConversationIdentifier = comment.ParentConversationIdentifier == Guid.Empty ? (Guid?)null : comment.ParentConversationIdentifier, ToUserIdentifier = comment.ToUserIdentifier == Guid.Empty ? (Guid?)null : comment.ToUserIdentifier, UserIdentifier = comment.FromUserIdentifier, Identifier = comment.Identifier == Guid.Empty ? (Guid?)null : comment.Identifier, }; var data = proc.CallObject <Comment>(); if (!comment.Read && null != data && Guid.Empty != data.ToUserIdentifier) { var user = new ProfileFull() { Identifier = data.ToUserIdentifier, }; user = profileCore.Search <ProfileFull>(user, null, true); email.Conversation(data, user); } return(data); }
/// <summary> /// This should be broken into a set of Async Actions /// </summary> /// <param name="profile">Profile Full</param> public async Task Register(ProfileFull profile) { try { if (null != profile) { var emailCore = new EmailCore(); emailCore.NewUserGreeting(profile); if (!string.IsNullOrWhiteSpace(profile.IpAddress)) { var geoCore = new GeoCore(); var location = await geoCore.GetGeoFromIp(profile.IpAddress); if (null != location) { var p = new Profile() { Identifier = profile.Identifier, Latitude = location.Latitude, Longitude = location.Longitude, Location = location.Location, IpAddress = location.IPAddress.TrimIfNotNull(), }; this.Save(p, false); profile.Location = p.Location.TrimIfNotNull(); // So we don't get FB's if it is valid } } activityCore.Joined(profile.Identifier, profile.Location); if (!string.IsNullOrWhiteSpace(profile.FacebookAccessToken)) { var facebookCore = new FacebookCore(); var emails = facebookCore.ImportFriends(profile); foreach (var email in emails) { emailCore.FriendSignedUp(email); } } //this.converstationCore.NewUserGreeting(profile.Identifier, profile.Name); } } catch { // Logging } }
/// <summary> /// Converstation /// </summary> /// <param name="latest">Comments</param> public void Conversation(Comment latest, ProfileFull toUser) { var template = new ConversationTemplate() { Latest = latest, }; try { var subject = string.Format("[Borentra] Your friend {0} has sent you a message!", latest.FromDisplayName); this.SendGeneric(toUser.Email, latest.FromDisplayName, subject, "New Message", template.TransformText()); } catch { } }
/// <summary> /// New User Greeting /// </summary> /// <param name="profile">Profile</param> public void NewUserGreeting(ProfileFull profile) { if (null == profile) { throw new ArgumentNullException("profile"); } try { var template = new NewUser() { User = profile, }; this.SendGeneric(profile.Email, fromName, "Welcome to Borentra!", "Welcome to Borentra!", template.TransformText()); } catch { } }
/// <summary> /// Import Friends /// </summary> /// <param name="profile">Profile</param> public IList <FriendEmail> ImportFriends(ProfileFull profile) { if (null == profile) { throw new ArgumentNullException("profile"); } if (string.IsNullOrWhiteSpace(profile.FacebookAccessToken)) { throw new ArgumentException("facebook access token"); } if (Guid.Empty == profile.Identifier) { throw new ArgumentException("profile identifier"); } var emails = new List <FriendEmail>(); var friends = this.Friends(profile.FacebookAccessToken); foreach (var friend in friends) { var connection = new Connection() { FacebookId = friend.Identifier, OwnerIdentifier = profile.Identifier, }; var email = this.Save(connection); if (null != email) { activityCore.GotAFriend(email); emails.Add(email); } } return(emails); }