public async Task <IActionResult> Followers([FromRoute] Guid userId) { try { var followers = (await _friendOperationRepo.Followers(userId)).Select(u => new UserInfoDTO() { UserId = u.FollowerUser.Id, FirstName = u.FollowerUser.FirstName, LastName = u.FollowerUser.LastName, PhotoUrl = u.FollowerUser.Photo }).ToList(); if (followers.IsNullOrEmpty()) { return(NotFound("Kayıt bulunamadı.")); } return(Ok(followers)); } catch (Exception ex) { _logHelper.Log("FriendOperationsController", 500, "GetFollowers", ex.Message); return(null); } }
public async Task <IActionResult> UserTimeline([FromRoute] Guid userId) { try { var timeline = new List <TimelineDTO>(); var userSetting = await _userSettingRepo.First(us => us.UserId == userId); if (userSetting == null) { return(NotFound("Kullanıcı ayarı bulunamadı.")); } //User Events if (userSetting.IsCreateEventVisibleTimeline) { var eventsTimeline = (await _eventRepo.UserEvents(userId)).Select(e => new TimelineDTO() { Header = e.Title, Body = TimelineHelper.GenerateUserCreateEventBody(e), Image = e.Photo, CreateAt = e.CreatedAt, CustomId = e.Id, Type = "create-event", LineColor = "#a6714e" }).ToList(); if (!eventsTimeline.IsNullOrEmpty()) { timeline.AddRange(eventsTimeline); } } //Event Operations if (userSetting.IsJoinEventVisibleTimeline) { var eventOperationsTimeline = (await _eventOperationRepo.UserEventOperations(userId)).Select(eo => new TimelineDTO() { Header = eo.Event.Title, Body = TimelineHelper.GenerateUserJoinEventBody(eo.Event), Image = eo.Event.Photo, CreateAt = eo.CreatedAt, CustomId = eo.EventId, Type = "join-event", LineColor = "#f78f8f" }).ToList(); if (!eventOperationsTimeline.IsNullOrEmpty()) { timeline.AddRange(eventOperationsTimeline); } } //Following Friend Operations if (userSetting.IsFollowingVisibleTimeline) { var followFriendOperationsTimeline = (await _friendOperationRepo.Followings(userId)).Select(fo => new TimelineDTO() { Header = fo.FollowingUser.FirstName + " " + fo.FollowingUser.LastName, Body = TimelineHelper.GenerateUserFollowingBody(), Image = null, CreateAt = fo.CreatedAt, CustomId = fo.FollowingUserId, Type = "following", LineColor = "#ffeea3" }).ToList(); if (!followFriendOperationsTimeline.IsNullOrEmpty()) { timeline.AddRange(followFriendOperationsTimeline); } } //Follow Friend Operations if (userSetting.IsFollowerVisibleTimeline) { var followingFriendOperationsTimeline = (await _friendOperationRepo.Followers(userId)).Select(fo => new TimelineDTO() { Header = fo.FollowerUser.FirstName + " " + fo.FollowerUser.LastName, Body = TimelineHelper.GenerateUserFollowerBody(), Image = null, CreateAt = fo.CreatedAt, CustomId = fo.FollowerUserId, Type = "follower", LineColor = "#ffeea3" }).ToList(); if (!followingFriendOperationsTimeline.IsNullOrEmpty()) { timeline.AddRange(followingFriendOperationsTimeline); } } //Comments if (userSetting.IsCommentVisibleTimeline) { var commentsTimeline = (await _commentRepo.UserComments(userId)).Select(c => new TimelineDTO() { Header = c.Event.Title, Body = TimelineHelper.GenerateUserCommentBody(userId, c), Image = null, CreateAt = c.CreatedAt, CustomId = c.EventId, Type = "comment-event", LineColor = "#dcd5f2" }).ToList(); if (!commentsTimeline.IsNullOrEmpty()) { timeline.AddRange(commentsTimeline); } } if (timeline.IsNullOrEmpty()) { return(NotFound("Kayıt bulunamadı.")); } return(Ok(timeline.OrderByDescending(t => t.CreateAt))); } catch (Exception ex) { _logHelper.Log("UsersController", 500, "UserTimeline", ex.Message); return(null); } }
public async Task <IActionResult> Timeline() { try { Guid userId = User.GetUserId(); List <TimelineDTO> timeline = new List <TimelineDTO>(); //User Events var eventsTimeline = (await _eventRepo.UserEvents(userId)).Select(e => new TimelineDTO() { Header = e.Title, Body = TimelineHelper.GenerateMyCreateEventBody(e), Image = e.Photo, CreateAt = e.CreatedAt, CustomId = e.Id, Type = "create-event", LineColor = "#a6714e" }).ToList(); if (!eventsTimeline.IsNullOrEmpty()) { timeline.AddRange(eventsTimeline); } //Event Operations var eventOperationsTimeline = (await _eventOperationRepo.UserEventOperations(userId)).Select(eo => new TimelineDTO() { Header = eo.Event.Title, Body = TimelineHelper.GenerateMyJoinEventBody(eo.Event), Image = eo.Event.Photo, CreateAt = eo.CreatedAt, CustomId = eo.EventId, Type = "join-event", LineColor = "#f78f8f" }).ToList(); if (!eventOperationsTimeline.IsNullOrEmpty()) { timeline.AddRange(eventOperationsTimeline); } //Following Friend Operations var followFriendOperationsTimeline = (await _friendOperationRepo.Followings(userId)).Select(fo => new TimelineDTO() { Header = fo.FollowingUser.FirstName + " " + fo.FollowingUser.LastName, Body = TimelineHelper.GenerateMyFollowingBody(), Image = null, CreateAt = fo.CreatedAt, CustomId = fo.FollowingUserId, Type = "following", LineColor = "#ffeea3" }).ToList(); if (!followFriendOperationsTimeline.IsNullOrEmpty()) { timeline.AddRange(followFriendOperationsTimeline); } //Follow Friend Operations var followingFriendOperationsTimeline = (await _friendOperationRepo.Followers(userId)).Select(fo => new TimelineDTO() { Header = fo.FollowerUser.FirstName + " " + fo.FollowerUser.LastName, Body = TimelineHelper.GenerateMyFollowerBody(), Image = null, CreateAt = fo.CreatedAt, CustomId = fo.FollowerUserId, Type = "follower", LineColor = "#ffeea3" }).ToList(); if (!followingFriendOperationsTimeline.IsNullOrEmpty()) { timeline.AddRange(followingFriendOperationsTimeline); } //Comments var commentsTimeline = (await _commentRepo.UserComments(userId)).Select(c => new TimelineDTO() { Header = c.Event.Title, Body = TimelineHelper.GenerateMyCommentBody(userId, c), Image = null, CreateAt = c.CreatedAt, CustomId = c.EventId, Type = "comment-event", LineColor = "#dcd5f2" }).ToList(); if (!commentsTimeline.IsNullOrEmpty()) { timeline.AddRange(commentsTimeline); } if (timeline.IsNullOrEmpty()) { return(NotFound("Kayıt bulunamadı.")); } return(Ok(timeline.OrderByDescending(t => t.CreateAt))); } catch (Exception ex) { _logHelper.Log("AccountController", 500, "Timeline", ex.Message); return(null); } }