Ejemplo n.º 1
0
        public static MongoBoards getBoardByName(string boardName, Helper.Cache _redisCache, Helper.AppSettings _appSettings, ILogger _logger)
        {
            MongoRepository boardrepo = new MongoRepository("MongoBoards", _appSettings);

            try
            {
                MongoBoards inMemboard = _redisCache.Get <MongoBoards>(Domain.Socioboard.Consatants.SocioboardConsts.CacheBoard + boardName);
                if (inMemboard != null)
                {
                    return(inMemboard);
                }
                else
                {
                    var result = boardrepo.Find <MongoBoards>(t => t.boardName.Equals(boardName) && t.isActive == true);
                    var task   = Task.Run(async() =>
                    {
                        return(await result);
                    });
                    MongoBoards board = task.Result.First();
                    return(board);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.StackTrace);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public IActionResult DeleteBoard(string BoardId, long userId)
        {
            MongoRepository     boardrepo = new MongoRepository("MongoBoards", _appSettings);
            IList <MongoBoards> boards    = new List <MongoBoards>();

            try
            {
                var result = boardrepo.Find <MongoBoards>(t => t.objId.Equals(BoardId));
                var task   = Task.Run(async() =>
                {
                    return(await result);
                });
                boards = task.Result;
            }
            catch (Exception e)
            {
            }
            if (boards.Count() > 0)
            {
                MongoBoards board = boards.First();
                board.isActive = false;

                FilterDefinition <BsonDocument> filter = new BsonDocument("objId", board.objId);
                // var filter = Builders<MongoBoardTwtProfile>.Filter.Eq(s => s.strId, twitteracc.strId);
                var update = Builders <BsonDocument> .Update
                             .Set("isActive", false);

                boardrepo.Update <MongoBoards>(update, filter);
                return(Ok("Deleted"));
            }

            return(Ok("board not exist"));
        }
Ejemplo n.º 3
0
        public IActionResult UndoDeleteBoard(string BoardId, long userId)
        {
            MongoRepository     boardrepo = new MongoRepository("MongoBoards", _appSettings);
            IList <MongoBoards> boards    = new List <MongoBoards>();

            try
            {
                var result = boardrepo.Find <MongoBoards>(t => t.objId.Equals(BoardId));
                var task   = Task.Run(async() =>
                {
                    return(await result);
                });
                boards = task.Result;
            }
            catch (Exception e)
            {
            }
            if (boards.Count() > 0)
            {
                MongoBoards board = boards.First();
                board.isActive = true;

                FilterDefinition <BsonDocument> filter = new BsonDocument("objId", board.objId);
                var update = Builders <BsonDocument> .Update
                             .Set("isActive", true);

                boardrepo.Update <MongoBoards>(update, filter);
                return(Ok("success"));
            }

            return(Ok("failed to update"));
        }
Ejemplo n.º 4
0
        public async Task <string> CreateBoard(string boardName, string twitterHashTag, string instagramHashTag, string gplusHashTag, long userId, Helper.Cache _redisCache, Helper.AppSettings settings, ILogger _logger)
        {
            MongoRepository     boardrepo = new MongoRepository("MongoBoards", settings);
            IList <MongoBoards> boards    = new List <MongoBoards>();

            try
            {
                var result = boardrepo.Find <MongoBoards>(t => t.boardName.Equals(boardName.ToLower()));
                var task   = Task.Run(async() =>
                {
                    return(await result);
                });
                boards = task.Result;
            }
            catch (Exception e)
            {
            }
            if (boards == null || boards.Count() == 0)
            {
                MongoBoards board = new MongoBoards();
                //companyprofiles.UserId = UserId;
                board.id         = ObjectId.GenerateNewId();
                board.isActive   = true;
                board.objId      = board.id.ToString();
                board.boardName  = boardName.ToLower();
                board.createDate = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss");
                board.userId     = userId.ToString();
                if (!string.IsNullOrEmpty(twitterHashTag) && twitterHashTag != "undefined")
                {
                    TwitterRepository tr = new TwitterRepository();
                    board.twitterHashTag = await tr.AddTwitterHashTag(twitterHashTag, board.objId, _redisCache, settings, _logger);
                }
                if (!string.IsNullOrEmpty(instagramHashTag) && instagramHashTag != "undefined")
                {
                    InstagramRepository instRepo = new InstagramRepository();
                    board.instagramHashTag = await instRepo.AddInstagramHashTag(instagramHashTag, board.objId, _redisCache, settings, _logger);
                }
                if (!string.IsNullOrEmpty(gplusHashTag) && gplusHashTag != "undefined")
                {
                    GplusRepository gplusRepo = new GplusRepository();
                    board.gplusHashTag = await gplusRepo.AddGplusHashTag(gplusHashTag, board.objId, _redisCache, settings, _logger);
                }

                await boardrepo.Add <Domain.Socioboard.Models.Mongo.MongoBoards>(board);

                return("successfulyy added.");
            }
            else
            {
                return("board Exist");
            }
        }
Ejemplo n.º 5
0
        public IActionResult getTwitterFeeds(string boardId, int skip, int count)
        {
            MongoBoards     board     = BoardMeRepository.getBoard(boardId, _redisCache, _appSettings, _logger);
            MongoRepository boardrepo = new MongoRepository("MongoBoardTwtFeeds", _appSettings);

            try
            {
                var result = boardrepo.Find <MongoBoardTwtFeeds>(t => t.Twitterprofileid.Equals(board.twitterHashTag)).ConfigureAwait(false);
                var task   = Task.Run(async() =>
                {
                    return(await result);
                });
                IList <MongoBoardTwtFeeds> objTwitterPagelist     = task.Result;
                List <MongoBoardTwtFeeds>  objBoardGplusPagefeeds = objTwitterPagelist.OrderByDescending(t => t.Publishedtime).Skip(Convert.ToInt32(skip)).Take(Convert.ToInt32(count)).ToList();
                return(Ok(objBoardGplusPagefeeds));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return(Ok("Something Went Wrong"));
            }
        }