public IHttpActionResult CreateFeedDiscussion([FromBody] FeedDiscussion feedDis) { FeedDiscussionRepository db = new FeedDiscussionRepository(); db.CreateFeedDiscussion(feedDis); return(Ok()); }
public IHttpActionResult GetFeed(Guid?Id) { List <Feed> Feed = new List <Feed>(); FeedRepository db = new FeedRepository(); UserRepository userRep = new UserRepository(); FeedDiscussionRepository FeedDisRep = new FeedDiscussionRepository(); if (Id.HasValue) { Feed = db.GetUserFeed(Id.Value); } else { Feed.AddRange(db.GetTextFeed()); Feed.AddRange(db.GetImageFeed()); Feed.AddRange(db.GetVideoFeed()); } Feed.OrderBy(x => x.CreatedAt); List <FeedViewModel> viewmodels = new List <FeedViewModel>(); foreach (Feed feed in Feed) { List <FeedDiscussion> comments = FeedDisRep.GetFeedDiscussions(feed.Id); List <FeedDiscussionViewModel> commentsViewModel = new List <FeedDiscussionViewModel>(); foreach (var comment in comments) { User CommentUser = userRep.GetUser(comment.User_Id); commentsViewModel.Add(new FeedDiscussionViewModel() { Id = comment.Id, UserId = comment.User_Id, CommentText = comment.Text, CreatedDate = comment.CreatedAt, FirstName = CommentUser.FirstName, LastName = CommentUser.LastName, ProfilePicUrl = CommentUser.ProfilePictureUrl }); } viewmodels.Add(new FeedViewModel() { Feed = feed, Creator = userRep.GetUser(feed.CreatorId), Comments = commentsViewModel }); } return(Ok(viewmodels)); }
public IHttpActionResult CreateFeedDiscussion(Guid FeedId, string CommentText) { if (FeedId.Equals(Guid.Empty) || CommentText == "" || CommentText == null) { throw new Exception("Geen comment ingevuld"); } UserRepository UserRep = new UserRepository(); FeedRepository FeedRep = new FeedRepository(); FeedDiscussionRepository FeedDisRep = new FeedDiscussionRepository(); FeedDiscussion Comment = new FeedDiscussion() { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, Text = CommentText, User_Id = UserRep.GetUserByEmail(User.Identity.Name).Id, Feed_Id = FeedId }; FeedDisRep.CreateFeedDiscussion(Comment); return(Ok()); }
public IHttpActionResult GetFeedDiscussion(Guid FeedId) { FeedDiscussionRepository db = new FeedDiscussionRepository(); return(Ok(db.GetFeedDiscussions(FeedId))); }