public void Consume(UserUnfollowedGroupAction message) { try { using (FsoContext db = new FsoContext()) { UserActivity activity = db.Set <UserActivity>() .Where(p => p.AppUserId == message.UserId && p.FeedType == UserActivityType.Follow_Group && p.ParentEntityType == ParentEntityType.Group && p.ParentEntityId == message.GroupId) .FirstOrDefault(); db.Set <UserActivity>().Remove(activity); int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("User Unfollow Group Activity Handled For User {0} and Group {1}", message.UserId, message.GroupId); } else { Console.WriteLine("User Unfollow Group Activity CANNOT Handled For User {0} and Group {1}", message.UserId, message.GroupId); } } } catch (Exception ex) { Console.WriteLine("User Unfollow Group Activity CANNOT Handled For User {0} and Group {1}", message.UserId, message.GroupId); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } }
public void Consume(GroupProfileImageUpdatedAction message) { try { using (FsoContext db = new FsoContext()) { Group updatedGroup = db.Set <Group>().FirstOrDefault(p => p.Id == message.GroupId); if (updatedGroup == null) { Console.WriteLine("Group Update Profile Image Activity Handled For Group {0} and Image {1}", message.GroupId, message.ThumbImageUrl); return; } AppMediaFile appFile = db.Set <AppMediaFile>().FirstOrDefault(f => f.ProfileGroupId == message.GroupId); if (appFile == null) { appFile = new AppMediaFile() { FileExtension = message.FileExtension, ImageDimension = message.Dimension, SmallPath = message.SmallImageUrl, ThumbPath = message.ThumbImageUrl, ProfileGroup = updatedGroup, DateUtcAdd = DateTime.UtcNow, DateUtcModified = DateTime.UtcNow }; db.Set <AppMediaFile>().Add(appFile); } else { appFile.FileExtension = message.FileExtension; appFile.ImageDimension = message.Dimension; appFile.SmallPath = message.SmallImageUrl; appFile.ThumbPath = message.ThumbImageUrl; appFile.ProfileGroup = updatedGroup; appFile.DateUtcModified = DateTime.UtcNow; db.Set <AppMediaFile>().Update(appFile); } int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("Group Update Profile Image Activity Handled For Group {0} and Image {1}", message.GroupId, message.ThumbImageUrl); } else { Console.WriteLine("Group Update Profile Image Activity CANNOT Handled For Group {0} and Image {1}", message.GroupId, message.ThumbImageUrl); } } } catch (Exception ex) { Console.WriteLine("Group Update Profile Image Activity CANNOT Handled For Group {0} and Image {1}", message.GroupId, message.ThumbImageUrl); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } }
public void Consume(UserPostFavouritedAction message) { //try //{ using (FsoContext db = new FsoContext()) { Post favouritedPost = db.Set <Post>().Include(p => p.ReputationGains).FirstOrDefault(p => p.Id == message.PostId); double previousRating = favouritedPost.Rating ?? 0; IQueryable <ReputationGain> userReputations = db.SetChild <ReputationGain>().Where(p => p.UserInfoId == message.UserId); if (userReputations != null) { double total = userReputations.Sum(p => p.GainedReputationValue); favouritedPost.Rating = previousRating + 10; } if (favouritedPost.ReputationGains == null) { favouritedPost.ReputationGains = new List <ReputationGain>(); } ReputationGain rpG = db.Set <ReputationGain>().FirstOrDefault(p => p.PostId == message.PostId && p.UserInfoId == message.PostAuthorId); if (rpG == null) { favouritedPost.ReputationGains.Add(new ReputationGain() { Post = favouritedPost, DateUtcAdd = message.DateUtcAction, DateUtcModified = message.DateUtcAction, GainedReputationValue = 10, UserInfoId = message.PostAuthorId }); db.Update(favouritedPost); } else { rpG.GainedReputationValue += 10; db.Update(rpG); } int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("User Favourited Post Activity Handled For User {0} and Post {1}", message.UserId, message.PostId); } else { Console.WriteLine("User Favourited Post Activity CANNOT Handled For User {0} and Post {1}", message.UserId, message.PostId); } } //} //catch (Exception ex) //{ // Console.WriteLine("User Favourited Post Activity CANNOT Handled For User {0} and Post {1}", message.UserId, message.PostId); // Console.WriteLine(ex.Message); // if (ex.InnerException != null) // { // Console.WriteLine(ex.InnerException.Message); // } //} }
public void Consume(PostPartImageUpdatedAction message) { try { using (FsoContext db = new FsoContext()) { PostPart postPart = db.Set <PostPart>().FirstOrDefault(f => f.Id == message.PostPartId); AppMediaFile appFile = db.Set <AppMediaFile>().FirstOrDefault(f => f.PostPartId == message.PostPartId); if (appFile == null) { appFile = new AppMediaFile() { FileExtension = message.FileExtension, ImageDimension = message.Dimension, SmallPath = message.SmallImageUrl, ThumbPath = message.ThumbImageUrl, ResizedPath = message.LargeImageUrl, BlurLazyPath = message.LazyImageUrl, PostPart = postPart, DateUtcAdd = DateTime.UtcNow, DateUtcModified = DateTime.UtcNow }; db.Set <AppMediaFile>().Add(appFile); } else { appFile.FileExtension = message.FileExtension; appFile.BlurLazyPath = message.LazyImageUrl; appFile.ImageDimension = message.Dimension; appFile.SmallPath = message.SmallImageUrl; appFile.ThumbPath = message.ThumbImageUrl; appFile.ResizedPath = message.LargeImageUrl; appFile.PostPart = postPart; appFile.DateUtcModified = DateTime.UtcNow; db.Set <AppMediaFile>().Update(appFile); } int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("PostPart Update Image Activity Handled For PostPart {0} and Image {1}", message.PostPartId, message.ThumbImageUrl); } else { Console.WriteLine("PostPart Update Image Activity CANNOT Handled For PostPart {0} and Image {1}", message.PostPartId, message.ThumbImageUrl); } } } catch (Exception ex) { Console.WriteLine("PostPart Update Image Activity CANNOT Handled For PostPart {0} and Image {1}", message.PostPartId, message.ThumbImageUrl); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } }
public void Consume(UserUpdatedProfileImageAction message) { try { using (FsoContext db = new FsoContext()) { var dbSet = db.Set <AppMediaFile>(); AppMediaFile fileDom = dbSet.FirstOrDefault(p => p.UserInfoId == message.UserId); fileDom.SmallPath = message.ImagePath; dbSet.Update(fileDom); int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("User Update profile Image Activity Handled For User {0} and Path {1}", message.UserId, message.ImagePath); } else { Console.WriteLine("User Unfollow Group Activity CANNOT Handled For User {0} and Path {1}", message.UserId, message.ImagePath); } } } catch (Exception ex) { Console.WriteLine("User Unfollow Group Activity CANNOT Handled For User {0} and Path {1}", message.UserId, message.ImagePath); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } }
public void Consume(UserRegisteredAction message) { try { using (FsoContext db = new FsoContext()) { var registeredUserInfo = new UserInfo() { AppUserId = message.UserId, DateUtcAdd = DateTime.UtcNow, DateUtcModified = DateTime.UtcNow, IsSoftDeleted = false, Name = message.Name, FollowSetting = UserFollowSetting.Confirm_All, Surname = message.Surname, UName = message.UName, ProfilePicture = new AppMediaFile() { DateUtcAdd = DateTime.UtcNow, DateUtcModified = DateTime.UtcNow, ImageDimension = "1", IsSoftDeleted = false, FileExtension = "jpeg", }, AlphaColor = "#3d3d3d", ReputationGains = new List <ReputationGain>() { new ReputationGain() { DateUtcAdd = DateTime.UtcNow, DateUtcModified = DateTime.UtcNow, GainedReputationValue = 10, } }, Status = "", }; db.Set <UserInfo>().Add(registeredUserInfo); int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("UserInfo Created for User {0}", message.UserId); } else { Console.WriteLine("UserInfo CANNOT Created for User {0}", message.UserId); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public bool IsUserOwnerPostCollection(string currUserId, int postCollectionId) { using (FsoContext db = new FsoContext()) { var pp = db.Set <PostCollection>().FirstOrDefault(p => p.Id == postCollectionId).UserInfoId; if (pp == null) { return(false); } return(pp == currUserId); } }
public bool IsUserOwnerPostpart(string currUserId, int postpartId) { using (FsoContext db = new FsoContext()) { var pp = db.Set <PostPart>().Select(p => new { Post = p.Post, p.Id }).FirstOrDefault(p => p.Id == postpartId); if (pp == null) { return(false); } return(pp.Post.UserInfoId == currUserId); } }
public void Consume(UserPostUnfavouritedAction message) { try { using (FsoContext db = new FsoContext()) { Post favouritedPost = db.Set <Post>().Include(p => p.ReputationGains).FirstOrDefault(p => p.Id == message.PostId); double previousRating = favouritedPost.Rating.Value; favouritedPost.Rating = previousRating - 10; ReputationGain rg = db.Set <ReputationGain>().FirstOrDefault(p => p.PostId == message.PostId && p.UserInfoId == message.PostAuthorId); if (rg != null) { db.Update(favouritedPost); rg.GainedReputationValue -= 10; db.Update(rg); } int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("User UnFavourited Post Activity Handled For User {0} and Post {1}", message.UserId, message.PostId); } else { Console.WriteLine("User UnFavourited Post Activity CANNOT Handled For User {0} and Post {1}", message.UserId, message.PostId); } } } catch (Exception ex) { Console.WriteLine("User Favourited Post Activity CANNOT Handled For User {0} and Post {1}", message.UserId, message.PostId); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } }
public void Consume(UserPublishedPostAction message) { try { using (FsoContext db = new FsoContext()) { UserActivity activity = new UserActivity() { AppUserId = message.UserId, DateUtcAdd = message.DateUtcAction, DateUtcModified = message.DateUtcAction, SourceEntityId = message.PostId, FeedType = UserActivityType.Add_New_Post, IsSoftDeleted = false }; db.Set <UserActivity>().Add(activity); int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("User Published Post Activity Handled For User {0} and Post {1}", message.UserId, message.PostId); } else { Console.WriteLine("User Published Post Activity CANNOT Handled For User {0} and Post {1}", message.UserId, message.PostId); } } } catch (Exception ex) { Console.WriteLine("User Published Post CANNOT Handled For User {0} and Post {1}", message.UserId, message.PostId); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } }
public void Consume(UserFollowedGroupAction message) { try { using (FsoContext db = new FsoContext()) { UserActivity activity = new UserActivity() { DateUtcAdd = message.DateUtcAction, DateUtcModified = message.DateUtcAction, IsSoftDeleted = false, AppUserId = message.UserId, FeedType = UserActivityType.Follow_Group, ParentEntityType = ParentEntityType.Group, ParentEntityId = message.GroupId }; db.Set <UserActivity>().Add(activity); int z = db.SaveChanges(); if (z > 0) { Console.WriteLine("User Follow Group Activity Handled For User {0} and Group {1}", message.UserId, message.GroupId); } else { Console.WriteLine("User Follow Group Activity CANNOT Handled For User {0} and Group {1}", message.UserId, message.GroupId); } } } catch (Exception ex) { Console.WriteLine("User Follow Group Activity CANNOT Handled For User {0} and Group {1}", message.UserId, message.GroupId); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } }