Esempio n. 1
0
 public void Dispose()
 {
     _context.Dispose();
     _icerikRepository = null;
     _konuRepository   = null;
     _likeRepository   = null;
 }
Esempio n. 2
0
 public GalleryController(ImageRepository imageRepository, LikeRepository likeRepository, StorageService storageService, IConfiguration config)
 {
     _imageRepository = imageRepository;
     _likeRepository  = likeRepository;
     _storageService  = storageService;
     _config          = config;
 }
        public async Task SendLike(StreamWriter writer, string[] msg, string replyTo, char direction, IServiceProvider services)
        {
            string phrase = msg[0].Split(":")[1];

            string[] input = new string[2];
            if (direction == '+')
            {
                phrase   = phrase.Split("+")[0];
                input[0] = phrase;
                input[1] = "1";
            }
            else
            {
                phrase   = phrase.Split("-")[0];
                input[0] = phrase;
                input[1] = "-1";
            }

            if (Like.CreateLike(input, replyTo) is Like like)
            {
                using var scope = services.CreateScope();
                LikeRepository repository = scope.ServiceProvider.GetRequiredService <LikeRepository>();
                Like           newLike    = await repository.UpsertLike(like);

                writer.WriteLine(newLike?.GetSendMessage());
                writer.Flush();
            }
        }
        public JsonResult Like(long id)
        {
            var result = ORRepository.Get(id);

            if (result == null)
            {
                return(Json(new { Success = false, Error = "Не удалось найти результат" }));
            }

            // Получить текущего юзера
            var curUser = GetCurrentUser();

            var like = LikeRepository.IsFavoriteResult(curUser.Id, id);

            if (like != null)
            {
                LikeRepository.Delete(like);
                return(Json(new { Success = true, Name = "like" }));
            }

            // Создать лайк
            like = LikeRepository.Create();

            // Заполнить свойства
            like.UserId   = curUser.Id;
            like.ResultId = result.Id;

            // Сохранить
            LikeRepository.Update(like);

            // Вернуться к списку операций
            return(Json(new { Success = true, Name = "dislike" }));
        }
Esempio n. 5
0
        public JsonResult Like(int id, string value)
        {
            bool              success           = false;
            Like              like              = new Like();
            Article           article           = new Article();
            ArticleRepository articleRepository = new ArticleRepository();
            LikeRepository    likeRepository    = new LikeRepository();

            article = articleRepository.GetById(id);
            List <Like> likeList  = new List <Like>();
            string      type      = AuthenticationManager.LoggedUser.GetType().BaseType.ToString();
            int         start     = type.LastIndexOf(".") + 1;
            int         positions = type.Length - start;

            type = type.Substring(start, positions);
            if (value == "Like")
            {
                like.ArticleID = id;
                like.UserID    = AuthenticationManager.LoggedUser.Id;

                like.UserType = type;
                likeRepository.Save(like);
                success = true;
            }
            if (value == "UnLike")
            {
                like = likeRepository.GetAll(filter: l => l.ArticleID == id && l.UserID == AuthenticationManager.LoggedUser.Id && l.UserType == type).FirstOrDefault();
                likeRepository.Delete(like);
                success = true;
            }
            return(Json(success, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
 public CommentController(ApplicationContext context, IHubContext <CommentHub> commentHub)
 {
     CommentRepository         = new CommentRepository(context);
     ApplicationUserRepository = new ApplicationUserRepository(context);
     LikeRepository            = new LikeRepository(context);
     _commentHubContext        = commentHub;
 }
Esempio n. 7
0
 public PostService(PostsRepository postsRepository, UsersRepository usersRepository,
                    LikeRepository likeRepository)
 {
     _postsRepository = postsRepository;
     _usersRepository = usersRepository;
     _likeRepository  = likeRepository;
 }
Esempio n. 8
0
        static async Task Main(string[] args)
        {
            var medium = new Medium();
            var pack   = await medium.GetPack(MEDIUM_USERS);

            var contextOptions = new DbContextOptionsBuilder <BlogContext>()
                                 .UseNpgsql("Server=localhost;Database=blog;Username=blogadmin;Password=blogadmin")
                                 .Options;
            var blogContext = new BlogContext(contextOptions);

            var usersRepository = new UserRepository(blogContext);
            var users           = pack.Users.Where(u => usersRepository.IsUsernameUniq(u.Username)).ToList();

            users.ForEach(usersRepository.Add);
            usersRepository.Commit();
            Console.WriteLine($"{users.Count} new users added");

            var storiesRepository = new StoryRepository(blogContext);
            var stories           = pack.Stories.Where(s =>
                                                       storiesRepository.GetSingle(os => os.Title == s.Title && os.PublishTime == s.PublishTime) == null
                                                       ).ToList();

            stories.ForEach(storiesRepository.Add);
            storiesRepository.Commit();
            Console.WriteLine($"{stories.Count} new stories added");

            var likeRepository = new LikeRepository(blogContext);
            var likes          = GenerateLikes(new Pack {
                Users = pack.Users, Stories = stories
            });

            likes.ForEach(likeRepository.Add);
            likeRepository.Commit();
            Console.WriteLine($"{likes.Count} new likes added");
        }
Esempio n. 9
0
        public async void AddOrRemoveLike_RemoveLike()
        {
            Guid guid              = Guid.NewGuid();
            var  mockDbContext     = new Mock <DatabaseContext>();
            var  mockDbSet         = new Mock <DbSet <Like> >();
            IQueryable <Like> data = new List <Like>()
            {
                new Like()
                {
                    Id = guid, PostId = guid, UserId = guid
                }
            }.AsQueryable();

            mockDbSet.As <IQueryable <Like> >().Setup(m => m.Provider).Returns(
                new TestAsyncQueryProvider <Like>(data.Provider)
                );
            mockDbSet.As <IQueryable <Like> >().Setup(m => m.Expression).Returns(data.Expression);
            mockDbSet.As <IQueryable <Like> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockDbSet.As <IQueryable <Like> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            mockDbContext.Setup(a => a.Likes).Returns(mockDbSet.Object);

            mockDbSet.Setup(a => a.Remove(data.First())).Returns(() =>
            {
                Assert.True(true);
                return(null);
            });

            var likeRepo = new LikeRepository(mockDbContext.Object);

            await likeRepo.AddOrRemoveLike(guid, new DomainModels.Post()
            {
                Id = guid
            });
        }
Esempio n. 10
0
        public JsonResult GetPeopleLiked(string statusId)
        {
            ILikeRepository likeRepository = new LikeRepository(_dbContext);
            var             listUserLiked  = likeRepository.GetListUserLiked(statusId);

            return(Json(listUserLiked, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
 public UnitOfWork(ApplicationDataContext db, ILogger <PostRepository> log)
 {
     _db               = db;
     _log              = log;
     PostRepository    = new PostRepository(_db, _log);
     LikeRepository    = new LikeRepository(_db);
     commentRepository = new CommentRepository(_db);
 }
Esempio n. 12
0
 public UnitOfWork(ImgSpotContext context)
 {
     _context = context;
     Users    = new UserRepository(_context);
     Pictures = new PictureRepository(_context);
     Comments = new CommentRepository(_context);
     Likes    = new LikeRepository(_context);
 }
Esempio n. 13
0
 public EntityService()
 {
     _categoryService = new CategoryRepository();
     _commentService  = new CommentRepository();
     _appUserService  = new AppUserRepository();
     _articleService  = new ArticleRepository();
     _likeService     = new LikeRepository();
 }
Esempio n. 14
0
 public PostUnitOfWork(string connectionString, string migrationAssemblyName)
     : base(connectionString, migrationAssemblyName)
 {
     PostRepository    = new PostRepository(_dbContext);
     CommentRepository = new CommentRepository(_dbContext);
     LikeRepository    = new LikeRepository(_dbContext);
     ReplayRepository  = new ReplayRepository(_dbContext);
 }
Esempio n. 15
0
 public RoleController(RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager, ApplicationContext context)
 {
     FanficRepository          = new FanficRepository(context);
     CommentRepository         = new CommentRepository(context);
     RatingRepository          = new RatingRepository(context);
     LikeRepository            = new LikeRepository(context);
     ApplicationUserRepository = new ApplicationUserRepository(context);
     _roleManager = roleManager;
     _userManager = userManager;
 }
Esempio n. 16
0
 public SqlDAL()
 {
     DBContext = new AlbumsDBModel();
     _albumRepository = new AlbumRepository(DBContext);
     _roleRepository = new RoleRepository(DBContext);
     _userRepository = new UserRepository(DBContext);
     _commentRepository = new CommentRepository(DBContext);
     _likeRepository = new LikeRepository(DBContext);
     _albumsPhotoRepository = new AlbumsPhotoRepository(DBContext);
     _photoRepository = new PhotoRepository(DBContext);
 }
Esempio n. 17
0
 public ArticleManageController(UserManager <ApplicationUser> userManager,
                                TagRepository tagRepository, ArticleRepository articleRepository, MarkRepository markRepository, IHubContext <ChatHub> hubContext
                                , ComentRepository comentRepository, LikeRepository likeRepository, Search search, SignInManager <ApplicationUser> signInManager)
 {
     _userManager       = userManager;
     _tagRepository     = tagRepository;
     _articleRepository = articleRepository;
     _markRepository    = markRepository;
     _hubContext        = hubContext;
     _comentRepository  = comentRepository;
     _likeRepository    = likeRepository;
     _searchService     = search;
     _signInManager     = signInManager;
 }
Esempio n. 18
0
 public Search(
     SearchRepository searchRepository,
     ArticleRepository articleRepository,
     ComentRepository comentRepository,
     LikeRepository likeRepository,
     TagRepository tagRepository,
     ArticleTagRepository articleTagRepository)
 {
     _searchRepository     = searchRepository;
     _articleRepository    = articleRepository;
     _comentRepository     = comentRepository;
     _tagRepository        = tagRepository;
     _articleTagRepository = articleTagRepository;
 }
        public ActionResult Index()
        {
            var curUser = GetCurrentUser();

            var results = ORRepository.GetByUser(curUser);

            var likes = LikeRepository.GetByUser(curUser).Select(it => it.ResultId);

            foreach (var result in results)
            {
                result.IsLiked = likes.Contains(result.Id);
            }

            return(View(results));
        }
Esempio n. 20
0
 public ContextController(EaDbContext dbContext,
                          IOptions <WebApiSettings> settings,
                          SignInManager <EaUser> signInManager,
                          ContentRepository contentRepository,
                          GroupRepository groupRepository,
                          CommentRepository commentRepository,
                          LikeRepository likeRepository)
 {
     _dbContext         = dbContext;
     _settings          = settings;
     _signInManager     = signInManager;
     _contentRepository = contentRepository;
     _groupRepository   = groupRepository;
     _commentRepository = commentRepository;
     _likeRepository    = likeRepository;
 }
Esempio n. 21
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            ConfigureConsul(services);

            var secret = "eBCatxoffIIq6ESdrDZ8LKI3zpxhYkYM";
            var key    = Encoding.ASCII.GetBytes(secret);

            services.AddAuthentication(option =>
            {
                option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                option.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(options =>
            {
                options.RequireHttpsMetadata      = false;
                options.SaveToken                 = true;
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuerSigningKey = true,
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            services.AddAuthorization();

            services.AddMessagePublishing("LikeService", builder =>
            {
                builder.WithHandler <ForgetUserMessageHandler>("ForgetUserMessage");
                builder.WithHandler <DeleteTweetMessageHandler>("DeleteTweetMessage");
                builder.WithHandler <UnApproveTweetMessageHandler>("UnApproveTweetMessage");
            });

            var config = new ServerConfig();

            Configuration.Bind(config);

            var likeContext = new LikeContext(config.MongoDB);
            var repo        = new LikeRepository(likeContext);

            services.AddSingleton <ILikeRepository>(repo);

            services.AddScoped <ILikeService, Services.LikeService>();
        }
Esempio n. 22
0
        public static string GetHtml_statusBoxLikeShare(string statusId, string userId)
        {
            ApplicationDbContext dbContext      = new ApplicationDbContext();
            ILikeRepository      likeRepository = new LikeRepository(dbContext);

            int    isLike  = likeRepository.IsLiked(statusId, userId);
            string strLike = (isLike == 1) ? "unlike" : "like";

            return
                ("<div class='box-like-share'>"
                 + "<a class='like' data-isliked='" + isLike + "' data-statusid='" + statusId + "'>"
                 + strLike
                 + "</a> &nbsp;<span data-statusid='" + statusId + "' class='glyphicon glyphicon-thumbs-up icon-liked' data-toggle='modal' data-target='#liked'></span> <span id='numLike-" + statusId + "'>" + likeRepository.Count(statusId) + "</span>"
                 + "&nbsp;.&nbsp;"
                 + "<a class='share' data-statusid='" + statusId + "'>Share</a> &nbsp;<span class='glyphicon glyphicon-share-alt'></span> <span id='numShare-" + statusId + "'>0</span>"
                 + "</div>");
        }
        public ActionResult Index()
        {
            var curUser = GetCurrentUser();

            var results = ORRepository.GetByUser(curUser);

            // var likes = LikeRepository.GetLikes(curUser.Id).Select(it => it.ResultId);

            var likes = LikeRepository.GetAll()              // получаем все лайки
                        .Where(u => u.User.Id == curUser.Id) // фильтруем по текущему юзеру
                        .Select(it => it.Result.Id);         // достаем из лайков результаты операций

            foreach (var result in results)
            {
                result.IsLiked = likes.Contains(result.Id);
            }
            return(View(results));
        }
Esempio n. 24
0
 public ContentController(EaDbContext dbContext,
                          UserManager <EaUser> userManager,
                          ContentRepository contentRepository,
                          SignInManager <EaUser> signInManager,
                          GroupRepository groupRepository,
                          LikeRepository likeRepository,
                          CommentRepository commentRepository,
                          ContentFileRepository contentFileRepository)
 {
     _userManager           = userManager;
     _contentRepository     = contentRepository;
     _signInManager         = signInManager;
     _likeRepository        = likeRepository;
     _commentRepository     = commentRepository;
     _contentFileRepository = contentFileRepository;
     _groupRepository       = groupRepository;
     _dbContext             = dbContext;
 }
        public JsonResult Like(long id)
        {
            var result = ORRepository.Get(id);

            if (result == null)
            {
                return(Json(new { Success = false, Error = "Не удалось найти результат" }));
            }

            var curUser = GetCurrentUser();

            //var like = LikeRepository.GetLikes(curUser.Id)
            //    .FirstOrDefault(it => it.UserId == curUser.Id && it.ResultId == id);

            var like = LikeRepository.GetAll().FirstOrDefault(it => it.User.Id == curUser.Id && it.Result.Id == id);

            if (like != null)
            {
                //Dislike
                LikeRepository.Delete(like);
                return(Json(new { Success = true, Name = "Like" }));
            }

            // Создать лайк
            like = LikeRepository.Create();

            // Заполнить свойства
            like.User   = curUser;
            like.Result = result;

            // Сохранить
            LikeRepository.Update(like);

            // Вернуться к списку операций
            return(Json(new { Success = true, Name = "Dislike" }));
        }
 public LikeController(LikeRepository repository)
 {
     _repository = repository;
 }
Esempio n. 27
0
 public LikeRepoTests()
 {
     _mockContext = new Mock <DataContext>();
     _mockRepo    = new LikeRepository(_mockContext.Object, Mock.Of <ILogger <LikeRepository> >());
 }
Esempio n. 28
0
        public ActionResult Articles()
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Default"));
            }
            List <Article>    articleList              = new List <Article>();
            ArticleRepository articleRepository        = new ArticleRepository();
            Dictionary <int, List <Comment> > comments = new Dictionary <int, List <Comment> >();
            CommentRepository        commentRepository = new CommentRepository();
            Dictionary <int, string> userDictionary    = new Dictionary <int, string>();
            List <int>        subjectId         = new List <int>();
            Teacher           teacher           = new Teacher();
            TeacherRepository teacherRepository = new TeacherRepository();
            Student           student           = new Student();
            StudentRepository studentRepository = new StudentRepository();
            List <Article>    list = new List <Article>();

            if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher)))
            {
                teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id);
                foreach (var item in teacher.CourseSubject)
                {
                    subjectId.Add(item.Subject.Id);
                }
            }
            else if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Student)))
            {
                student = studentRepository.GetById(AuthenticationManager.LoggedUser.Id);
                List <CourseSubject>    courseSubjectList       = new List <CourseSubject>();
                CourseSubjectRepository courseSubjectRepository = new CourseSubjectRepository();
                courseSubjectList = courseSubjectRepository.GetAll(filter: cs => cs.CourseID == student.CourseID);
                foreach (var item in courseSubjectList)
                {
                    subjectId.Add(item.Subject.Id);
                }
            }
            subjectId = subjectId.Distinct().ToList();
            foreach (var item in subjectId)
            {
                List <Article> article = articleRepository.GetAll(filter: s => s.Subject.Id == item);
                if (article != null)
                {
                    articleList.AddRange(article);
                }
            }
            articleList = articleList.OrderBy(d => d.DateCreated.TimeOfDay).ToList();
            articleList.Reverse();
            ArticleControllerArticlesVM model              = new ArticleControllerArticlesVM();
            LikeRepository            likeRepository       = new LikeRepository();
            Dictionary <Article, int> ArticlesAndLikeCount = new Dictionary <Article, int>();
            Dictionary <int, bool>    Liked = new Dictionary <int, bool>();
            int    articleId = 0;
            string type      = AuthenticationManager.LoggedUser.GetType().BaseType.ToString();
            int    start     = type.LastIndexOf(".") + 1;
            int    positions = type.Length - start;

            type = type.Substring(start, positions);
            foreach (var item in articleList)
            {
                List <Comment> commentedCommentList = new List <Comment>();
                commentedCommentList = commentRepository.GetAll(filter: c => c.Article.Id == item.Id);
                commentedCommentList.OrderBy(c => c.DateCreated.TimeOfDay).ToList();
                commentedCommentList.Reverse();
                foreach (var comment in commentedCommentList)
                {
                    string userName = "";
                    if (comment.UserType == "Teacher")
                    {
                        teacher = teacherRepository.GetById(comment.UserID);
                        if (teacher != null)
                        {
                            userName = teacher.FirstName + " " + teacher.LastName;
                            userDictionary.Add(comment.Id, userName);
                        }
                    }
                    else
                    {
                        student  = studentRepository.GetById(comment.UserID);
                        userName = student.FirstName + " " + student.LastName;
                        userDictionary.Add(comment.Id, userName);
                    }
                }
                comments.Add(item.Id, commentedCommentList);
                int count = likeRepository.GetAll(filter: a => a.ArticleID == item.Id).Count;
                ArticlesAndLikeCount.Add(item, count);
                List <Like> likes = new List <Like>();

                likes = likeRepository.GetAll(l => l.ArticleID == item.Id);
                foreach (var like in likes.Where(l => l.UserID == AuthenticationManager.LoggedUser.Id && l.UserType == type))
                {
                    Liked.Add(item.Id, true);
                }
                model.ArticleId = item.Id;
                if (Liked.Count != ArticlesAndLikeCount.Count)
                {
                    foreach (var dictionary in ArticlesAndLikeCount.Where(a => a.Key.Id == item.Id))
                    {
                        articleId = item.Id;
                    }
                    Liked.Add(articleId, false);
                }
            }
            model.UserType       = type;
            model.IsLiked        = Liked;
            model.UserID         = AuthenticationManager.LoggedUser.Id;
            model.Articles       = ArticlesAndLikeCount;
            model.CommentList    = comments;
            model.UserDictionary = userDictionary;
            return(View(model));
        }
Esempio n. 29
0
 public LikeController(LikeRepository likeRepository)
 {
     this.likeRepository = likeRepository;
 }
        public JsonResult Like(int id, string value)
        {
            bool success = false;
            Like like = new Like();
            Article article = new Article();
            ArticleRepository articleRepository = new ArticleRepository();
            LikeRepository likeRepository = new LikeRepository();
            article = articleRepository.GetById(id);
            List<Like> likeList = new List<Like>();
            string type = AuthenticationManager.LoggedUser.GetType().BaseType.ToString();
            int start = type.LastIndexOf(".") + 1;
            int positions = type.Length - start;
            type = type.Substring(start, positions);
            if (value == "Like")
            {
                like.ArticleID = id;
                like.UserID = AuthenticationManager.LoggedUser.Id;

                like.UserType = type;
                likeRepository.Save(like);
                success = true;
            }
            if (value == "UnLike")
            {
                like = likeRepository.GetAll(filter: l => l.ArticleID == id && l.UserID == AuthenticationManager.LoggedUser.Id && l.UserType == type).FirstOrDefault();
                likeRepository.Delete(like);
                success = true;
            }
            return Json(success, JsonRequestBehavior.AllowGet);
        }
Esempio n. 31
0
 public LikeUnitOfWork(string connectionString, string migrationAssemblyName)
     : base(connectionString, migrationAssemblyName)
 {
     Likes = new LikeRepository(_dbContext);
 }
Esempio n. 32
0
        public LikeTest()
        {
            var repository = new LikeRepository();

            _service = new LikeService(repository);
        }
        public ActionResult Articles()
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return RedirectToAction("Login", "Default");
            }
            List<Article> articleList = new List<Article>();
            ArticleRepository articleRepository = new ArticleRepository();
            Dictionary<int, List<Comment>> comments = new Dictionary<int, List<Comment>>();
            CommentRepository commentRepository = new CommentRepository();
            Dictionary<int, string> userDictionary = new Dictionary<int, string>();
            List<int> subjectId = new List<int>();
            Teacher teacher = new Teacher();
            TeacherRepository teacherRepository = new TeacherRepository();
            Student student = new Student();
            StudentRepository studentRepository = new StudentRepository();
            List<Article> list = new List<Article>();
            if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher)))
            {
                teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id);
                foreach (var item in teacher.CourseSubject)
                {
                    subjectId.Add(item.Subject.Id);
                }
            }
            else if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Student)))
            {
                student = studentRepository.GetById(AuthenticationManager.LoggedUser.Id);
                List<CourseSubject> courseSubjectList = new List<CourseSubject>();
                CourseSubjectRepository courseSubjectRepository = new CourseSubjectRepository();
                courseSubjectList = courseSubjectRepository.GetAll(filter: cs => cs.CourseID == student.CourseID);
                foreach (var item in courseSubjectList)
                {
                    subjectId.Add(item.Subject.Id);
                }
            }
            subjectId = subjectId.Distinct().ToList();
            foreach (var item in subjectId)
            {
                List<Article> article = articleRepository.GetAll(filter: s => s.Subject.Id == item);
                if (article != null)
                {
                    articleList.AddRange(article);
                }
            }
            articleList = articleList.OrderBy(d => d.DateCreated.TimeOfDay).ToList();
            articleList.Reverse();
            ArticleControllerArticlesVM model = new ArticleControllerArticlesVM();
            LikeRepository likeRepository = new LikeRepository();
            Dictionary<Article, int> ArticlesAndLikeCount = new Dictionary<Article, int>();
            Dictionary<int, bool> Liked = new Dictionary<int, bool>();
            int articleId = 0;
            string type = AuthenticationManager.LoggedUser.GetType().BaseType.ToString();
            int start = type.LastIndexOf(".") + 1;
            int positions = type.Length - start;
            type = type.Substring(start, positions);
            foreach (var item in articleList)
            {
                List<Comment> commentedCommentList = new List<Comment>();
                commentedCommentList = commentRepository.GetAll(filter: c => c.Article.Id == item.Id);
                commentedCommentList.OrderBy(c => c.DateCreated.TimeOfDay).ToList();
                commentedCommentList.Reverse();
                foreach (var comment in commentedCommentList)
                {
                    string userName = "";
                    if (comment.UserType == "Teacher")
                    {
                        teacher = teacherRepository.GetById(comment.UserID);
                        if (teacher != null)
                        {
                            userName = teacher.FirstName + " " + teacher.LastName;
                            userDictionary.Add(comment.Id, userName);
                        }
                    }
                    else
                    {
                        student = studentRepository.GetById(comment.UserID);
                        userName = student.FirstName + " " + student.LastName;
                        userDictionary.Add(comment.Id, userName);
                    }
                }
                comments.Add(item.Id, commentedCommentList);
                int count = likeRepository.GetAll(filter: a => a.ArticleID == item.Id).Count;
                ArticlesAndLikeCount.Add(item, count);
                List<Like> likes = new List<Like>();

                likes = likeRepository.GetAll(l => l.ArticleID == item.Id);
                foreach (var like in likes.Where(l => l.UserID == AuthenticationManager.LoggedUser.Id && l.UserType == type))
                {
                    Liked.Add(item.Id, true);
                }
                model.ArticleId = item.Id;
                if (Liked.Count != ArticlesAndLikeCount.Count)
                {
                    foreach (var dictionary in ArticlesAndLikeCount.Where(a => a.Key.Id == item.Id))
                    {
                        articleId = item.Id;
                    }
                    Liked.Add(articleId, false);
                }
            }
            model.UserType = type;
            model.IsLiked = Liked;
            model.UserID = AuthenticationManager.LoggedUser.Id;
            model.Articles = ArticlesAndLikeCount;
            model.CommentList = comments;
            model.UserDictionary = userDictionary;
            return View(model);
        }