예제 #1
0
        public ActionResult EditComment(int?taskId, int?id)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            CommentsRepository commentsRepository = new CommentsRepository(new TaskManagerDb());

            Comment comment = null;

            if (id == null)
            {
                comment        = new Comment();
                comment.TaskId = taskId.Value;
                comment.UserId = AuthenticationManager.LoggedUser.Id;
            }
            else
            {
                comment = commentsRepository.GetById(id.Value);
            }

            ViewData["comments"] = comment;

            return(View());
        }
예제 #2
0
 public CommentController(CommentsRepository commentsRepository,
                          UsersRepository userRepository, IOptions <JwtAuthentication> jwtAuthentication)
 {
     _commentsRepository = commentsRepository;
     _userRepository     = userRepository;
     _jwtAuthentication  = jwtAuthentication ?? throw new ArgumentNullException(nameof(jwtAuthentication));
 }
예제 #3
0
        public ActionResult Update(int id)
        {
            var commentsRepository = new CommentsRepository();
            var entity             = commentsRepository.GetById(id);

            return(View(entity));
        }
예제 #4
0
 public BaseListVM()
 {
     Users    = new UsersRepository().GetAll();
     Tasks    = new TasksRepository().GetAll();
     Comments = new CommentsRepository().GetAll();
     Logworks = new LogworksRepository().GetAll();
 }
        public void Setup()
        {
            var client = new MongoClient(Constants.MongoDbConnectionUri());

            _userRepository    = new UsersRepository(client);
            _commentRepository = new CommentsRepository(client);
            _movieRepository   = new MoviesRepository(client);
            _opinionatedUser   = new User
            {
                Name     = "Inigo Montoya",
                Email    = "*****@*****.**",
                Password = "******"
            };
            _anotherUser = new User
            {
                Name     = "Vizzini",
                Email    = "*****@*****.**",
                Password = "******"
            };
            _movieId = "573a1398f29313caabcea974";
            var jwt = new JwtAuthentication
            {
                SecurityKey   = "ouNtF8Xds1jE55/d+iVZ99u0f2U6lQ+AHdiPFwjVW3o=",
                ValidAudience = "https://localhost:5000/",
                ValidIssuer   = "https://localhost:5000/"
            };
            var appSettingsOptions = Options.Create(jwt);

            _userController    = new UserController(_userRepository, _commentRepository, appSettingsOptions);
            _commentController = new CommentController(_commentRepository, _userRepository, appSettingsOptions);
        }
        // DELETE: api/ManagerComment/5
        public void Delete(int id)
        {
            ManagerComment comment = new ManagerComment();

            comment.managerid = id;
            CommentsRepository.Delete(comment);
        }
        //
        // GET: /Comment/
        public ActionResult Index(int id)
        {
            var commentsRepository = new CommentsRepository();
            var commentsList       = new List <Comment>();

            var commentsFromRepository = commentsRepository
                                         .GetAll(comment => comment.AssignmentId == id);

            //foreach (var comment in commentsFromRepository)
            //{
            //    if (comment.AssignmentId == id)
            //    {
            //        commentsList.Add(comment);
            //    }
            //}

            ViewBag.AssignmentId = id;

            var assignmentRepository = new AssignmentRepository();

            ViewBag.AssignmentTitle =
                assignmentRepository.GetById(id).Title;

            // Navigational Property Demo

            //var firstComment = commentsList.FirstOrDefault();
            //ViewBag.AssignmentTitle = firstComment.Assignment.Title;

            commentsList.AddRange(commentsFromRepository);

            return(View(commentsList));
        }
 public ActivityController(
     FeedManagementService feedService,
     FeedItemRepository feedItemRepository,
     CommentsManagementService commentsService,
     CommentsRepository commentsRepository,
     ActivityManagementService activityService,
     ActivityRepository activityRepository,
     JunaUserRepository userRepository,
     ContentUploadService contentUploadService,
     BoardRepository boardsRepository,
     TelemetryClient trace,
     Stream.StreamClient streamClient,
     IdentityHelper identityHelper,
     IAppConfiguration appConfig
     )
 {
     _feedService          = feedService;
     _feedItemRepository   = feedItemRepository;
     _commentsService      = commentsService;
     _commentsRepository   = commentsRepository;
     _activityService      = activityService;
     _activityRepository   = activityRepository;
     _userRepository       = userRepository;
     _contentUploadService = contentUploadService;
     _boardsRepository     = boardsRepository;
     logger          = trace;
     _streamClient   = streamClient;
     _identityHelper = identityHelper;
     _appConfig      = appConfig;
 }
예제 #9
0
 public CommentsController(ApplicationDbContext context, OgmaConfig ogmaConfig, CommentsRepository commentsRepo, IMapper mapper)
 {
     _context      = context;
     _ogmaConfig   = ogmaConfig;
     _commentsRepo = commentsRepo;
     _mapper       = mapper;
 }
예제 #10
0
 public CommentsController()
 {
     commentsRepo     = new CommentsRepository(db);
     projectTasksRepo = new ProjectTasksRepository(db);
     usersRepo        = new UsersRepository(db);
     coursesRepo      = new CoursesRepository(db);
 }
        public MasterPresenter(IMasterView masterView = null)
        {
            this.masterView = masterView;

            db = new PortalAukcyjnyEntities();

            if (IsUserLoggedIn())
            {
                currentUserId = GetCurrentUserId();
            }
            else
            {
                currentUserId = Guid.Empty;
            }

            currencyRepo   = new CurrencyExchangeRepository(db);
            auctionsRepo   = new AuctionsRepository(db);
            catRepo        = new CategoriesRepository(db);
            offersRepo     = new OffersRepository(db);
            usersRepo      = new UsersRepository(db);
            commentsRepo   = new CommentsRepository(db);
            observersRepo  = new ObserversRepository(db);
            shipmentsRepo  = new ShipmentsRepository(db);
            imagesRepo     = new ImagesRepository(db);
            buyedItemsRepo = new BuyedItemsRepository(db);
        }
예제 #12
0
        //
        // GET: /Comment/
        public ActionResult Index(int id)
        {
            var commentsRepository = new CommentsRepository();
            var commentsList       = new List <Comment>();

            var commentsFromRepo = commentsRepository.GetAll(comment => comment.AssignmentId == id);

            // var commentsFromRepo = commentsRepository.GetAll();
            //foreach (var comment in commentsFromRepo)
            //{
            //    if (comment.AssignmentId == id)
            //    {
            //        commentsList.Add(comment);
            //    }
            //}
            ViewBag.AssignmentId = id;

            var assignmentRepository = new AssignmentRepository();

            ViewBag.AssignmentTitle = assignmentRepository.GetById(id).Title;

            commentsList.AddRange(commentsFromRepo);

            return(View(commentsList));
        }
예제 #13
0
        public Repositories(string connection)
        {
            #region Data context creating
            // ReSharper disable UseObjectOrCollectionInitializer
            _Context = new TimezDataContext(connection);
            // ReSharper restore UseObjectOrCollectionInitializer
#if DEBUG
            _Context.CommandTimeout = 60 * 5;
            _Context.Log            = new DebuggerWriter();
#endif
            #endregion

            Boards        = BoardsRepository.Create(_Context);
            BoardsColors  = BoardsColorsRepository.Create(_Context);
            BoardsUsers   = BoardsUsersRepository.Create(_Context);
            Tasks         = TasksRepository.Create(_Context);
            TasksStatuses = TasksStatusesRepository.Create(_Context);
            Users         = UsersRepository.Create(_Context);
            Organizations = OrganizationsRepository.Create(_Context);
            Projects      = ProjectsRepository.Create(_Context);
            Comments      = CommentsRepository.Create(_Context);
            EventHistory  = EventHistoryRepository.Create(_Context);
            Invites       = InvitesRepository.Create(_Context);
            Texts         = TextsRepository.Create(_Context);
        }
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Personal\\dev\\SigTrade\\SigTrade", "/")]
        //[UrlToTest("http://localhost:1431/")]
        public void testGetCommentsbyID()
        {
            ICommentsRepository comments = new CommentsRepository();

            IList <ParagraphComment> com = comments.getCommentsByID(1);

            Assert.AreEqual(com.Count, 1);
        }
 public CommentsManagementService(CommentsRepository commentRepository,
                                  FeedItemRepository feedItemRepository,
                                  Stream.StreamClient streamClient)
 {
     _commentsRepository = commentRepository;
     _feedItemRepository = feedItemRepository;
     _streamClient       = streamClient;
 }
        // GET: api/ManagerComment/5
        public ManagerComment Get(int id)
        {
            ProjectEntiryDbcontext db      = new ProjectEntiryDbcontext();
            ManagerComment         comment = new ManagerComment();

            comment.managerid = id;
            return(CommentsRepository.Search(comment, db));
        }
        // GET: api/ManagerComment/5
        public managercomments Get(int id)
        {
            ProjectTrackingDbcontext db      = new ProjectTrackingDbcontext();
            managercomments          comment = new managercomments();

            comment.managercomment_id = id;
            return(CommentsRepository.Search(comment, db));
        }
예제 #18
0
 public CommentsController(ApplicationDbContext context, OgmaConfig ogmaConfig, CommentsRepository commentsRepo, NotificationsRepository notificationsRepo, CommentRedirector redirector, IMapper mapper)
 {
     _context           = context;
     _ogmaConfig        = ogmaConfig;
     _commentsRepo      = commentsRepo;
     _notificationsRepo = notificationsRepo;
     _redirector        = redirector;
     _mapper            = mapper;
 }
        private async static Task <TaskedListener> CreateListenerAsync()
        {
            Configurations configurations = await LoadConfigurationsAsync();

            CommentsRepository commentsRepository = new CommentsRepository(_httpClient.Value, new Uri(configurations.RedditApiEndpoint));
            RedditListener     redditListener     = new RedditListener(commentsRepository);

            return(new TaskedListener(redditListener, Console.WriteLine));
        }
        public ActionResult Delete(int id)
        {
            var commentRepository = new CommentsRepository();
            var entity            = commentRepository.GetById(id);

            commentRepository.Delete(entity);

            return(RedirectToAction("Index/" + entity.AssignmentId));
        }
예제 #21
0
 public LFDataManager()
 {
     _itemRepository     = new ItemRepository();
     _regionRepository   = new RegionRepository();
     _countryRepository  = new CountryRepository();
     _cityRepository     = new CityRepository();
     _commentRepository  = new CommentsRepository();
     _categoryRepository = new CategoryRepository();
     _userRepository     = new UserRepository();
 }
예제 #22
0
        public ActionResult Update(Comment entity)
        {
            entity.UpdatedAt = DateTime.Now;

            var commentRepository = new CommentsRepository();

            commentRepository.Update(entity);

            return(RedirectToAction("Index/" + entity.AssignmentId));
        }
예제 #23
0
        public ActionResult Details(int id)
        {
            //all object that we want to map with tryupdatemodel
            TaskDetailsVM model = new TaskDetailsVM();

            model.PagerComments = new Pager();
            model.PagerWorkLog  = new Pager();
            TryUpdateModel(model);

            //All repositories
            TasksRepository    taskRepo    = new TasksRepository();
            UsersRepository    userRepo    = new UsersRepository();
            TimeRepository     timeRepo    = new TimeRepository();
            CommentsRepository commentRepo = new CommentsRepository();

            //get the specific name that we show (inache kazano da ne e int kakto vika Bai Georgi)
            TaskEntity task            = (id <= 0) ? new TaskEntity() : taskRepo.GetById(id);
            UserEntity creatorUser     = null;
            UserEntity responsibleUser = null;

            if (id == 0)
            {
                creatorUser     = userRepo.GetById(AuthenticationManager.LoggedUser.Id);
                responsibleUser = userRepo.GetById(AuthenticationManager.LoggedUser.Id);
            }
            else
            {
                creatorUser     = userRepo.GetById(task.CreatorId);
                responsibleUser = userRepo.GetById(task.ResponsibleUsers);
            }

            //fill the model
            model.Id              = task.Id;
            model.CreatorName     = creatorUser.FirstName + " " + creatorUser.LastName;
            model.ResponsibleName = responsibleUser.FirstName + " " + responsibleUser.LastName;
            model.Content         = task.Content;
            model.Title           = task.Title;
            model.CreateTime      = task.CreateTime;
            UserEntity Users = userRepo.GetAll().FirstOrDefault(u => u.Id == task.CreatorId);

            //fill the model's list that give to the partialsViews
            model.CommentsList = commentRepo.GetAll(c => c.TaskId == model.Id, model.PagerComments.CurrentPage, model.PagerComments.PageSize).ToList();
            model.WorkLogList  = timeRepo.GetAll(w => w.TaskId == model.Id, model.PagerWorkLog.CurrentPage, model.PagerWorkLog.PageSize).ToList();

            //fill the pager with the specific data //Yanka beshe tuk :D :D :D kaza da go iztriq ama nqma da e

            string action     = this.ControllerContext.RouteData.Values["action"].ToString();
            string controller = this.ControllerContext.RouteData.Values["controller"].ToString();

            model.PagerComments = new Pager(commentRepo.GetAll().Count(c => c.TaskId == model.Id), model.PagerComments.CurrentPage, "PagerComments.", action, controller, model.PagerComments.PageSize);

            model.PagerWorkLog = new Pager(timeRepo.GetAll().Count(l => l.TaskId == model.Id), model.PagerWorkLog.CurrentPage, "PagerWorkLog.", action, controller, model.PagerWorkLog.PageSize);

            return(View(model));
        }
예제 #24
0
        public async Task GivenValidApi_Get_CommentsReturned()
        {
            const string        expectedBaseAddress     = "https://reddit.com/r/all/comments.json";
            string              expectedResponseContent = JsonConvert.SerializeObject(GetFakeRedditComments());
            ICommentsRepository repository = new CommentsRepository(new HttpClient(GetMockedHttpMessageHandler(expectedResponseContent)), new Uri(expectedBaseAddress));

            var actual = await repository.Get();

            Assert.IsTrue(actual.Any());
            Assert.AreEqual(2, actual.Count());
        }
예제 #25
0
        public void CommentsRepository_Can_Get_Comments_By_Number()
        {
            //  Arrange
            var commentsRepository = new CommentsRepository(new WebClient(new HttpClient()));

            //  Act
            var result = commentsRepository.GetN <IList <Comment> >(6, 4);

            //  Assert
            Assert.True(result.Result.Count == 4);
        }
예제 #26
0
        public async Task GivenInvalidResponse_Get_RedditCommentsFormatExceptionThrown()
        {
            const string        expectedBaseAddress     = "https://reddit.com/r/all/comments.json";
            string              expectedResponseContent = JsonConvert.SerializeObject(new { UnexpectedProperty = "InvalidObject" });
            ICommentsRepository repository = new CommentsRepository(new HttpClient(GetMockedHttpMessageHandler(expectedResponseContent)), new Uri(expectedBaseAddress));

            var actual = await repository.Get();

            Assert.IsTrue(actual.Any());
            Assert.AreEqual(2, actual.Count());
        }
        public void PostsRepository_HasComments()
        {
            //  Arrange
            var commentsRepository = new CommentsRepository(new WebClient(new HttpClient()));

            //  Act
            var result = commentsRepository.GetAll <IList <Comment> >(6);

            //  Assert
            Assert.True(result.Result.Count > 0);
        }
        public CommentsRepositoryTests()
        {
            var camelCaseConvention = new ConventionPack {
                new CamelCaseElementNameConvention()
            };

            ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);

            _client             = new MongoClient(Constants.MongoDbConnectionUri());
            _commentsRepository = new CommentsRepository(_client);
        }
예제 #29
0
        public void CommentsRepository_Comments_Only_By_Valid_Id()
        {
            //  Arrange
            var commentsRepository = new CommentsRepository(new WebClient(new HttpClient()));

            //  Act
            var result = commentsRepository.GetAll <IList <Comment> >(-100);

            //  Assert
            Assert.True(result.Result.Count == 0);
        }
        public void DeleteUser()
        {
            Console.Clear();
            Console.Write("Enter user id to delete: ");
            int  id    = 0;
            bool isInt = int.TryParse(Console.ReadLine(), out id);

            while (isInt == false)
            {
                Console.WriteLine("Only numbers can be entered for user ID's");
                isInt = int.TryParse(Console.ReadLine(), out id);
            }

            UsersRepository userRepo = new UsersRepository("users.txt");

            if (userRepo.CheckEntityExistence(User => User.Id == id) == false)
            {
                Console.WriteLine("No user with that id exists!!");
                Console.ReadKey(true);
                return;
            }
            if (id == 1)
            {
                Console.WriteLine("You cannot delete the built-in administrator account!!");
                Console.ReadKey(true);
                return;
            }

            CommentsRepository commentRepo = new CommentsRepository("comments.txt");
            List <Comment>     comments    = commentRepo.GetAll(Comment => Comment.CreatorId == id);

            foreach (Comment comment in comments)
            {
                commentRepo.Delete(comment);
            }

            TasksRepository taskRepo = new TasksRepository("tasks.txt");
            List <Task>     tasks    = taskRepo.GetAll(Task => Task.CreatorId == id || Task.AssigneeId == id);

            foreach (Task task in tasks)
            {
                taskRepo.Delete(task);
            }

            List <User> users = userRepo.GetAll(User => User.Id == id);

            foreach (User user in users)
            {
                userRepo.Delete(user);
            }

            Console.WriteLine("User successfully deleted!");
            Console.ReadKey(true);
        }