コード例 #1
0
        public TransactionObject ToggleFavPost(int ID, int userID)
        {
            TransactionObject response = new TransactionObject();

            try
            {
                Post favPost     = postManager.GetPost(ID);
                User currentUser = userManager.GetUser(userID);

                FavouriteFeeds ff = currentUser.FavouriteFeeds;
                if (ff == null)
                {
                    ff      = new FavouriteFeeds();
                    ff.User = currentUser;
                    currentUser.FavouriteFeeds = ff;
                    favFeedManager.AddFavouriteFeed(ff);
                }

                if (CheckExistence(ff.FavouritePosts, favPost))
                {
                    ff.FavouritePosts.Remove(favPost);
                    favPost.FavouriteFeeds.Remove(ff);
                    favPost.FavouritedCount--;
                }
                else
                {
                    ff.FavouritePosts.Add(favPost);
                    favPost.FavouriteFeeds.Add(ff);
                    favPost.FavouritedCount++;
                }
                uow.Save();

                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess   = false;
                response.Explanation = base.GetExceptionMessage(ex);
            }
            return(response);
        }
コード例 #2
0
 public void DeleteFavouriteFeed(FavouriteFeeds favFeed)
 {
     favFeedRepository.Delete(favFeed);
 }
コード例 #3
0
 public void EditFavouriteFeed(FavouriteFeeds favFeed)
 {
     //favFeedRepository.Update(favFeed);
 }
コード例 #4
0
 public void AddFavouriteFeed(FavouriteFeeds favFeed)
 {
     favFeedRepository.Add(favFeed);
 }