Exemplo n.º 1
0
        public ActionResult Index()
        {
            er.ClearUnreadPosts(User.Identity.GetUserId());
            EducationBlogViewModel model = new EducationBlogViewModel();

            model.Posts = er.GetAll().ToList();


            foreach (var post in model.Posts)
            {
                EducationPostFileCombo rpfc = new EducationPostFileCombo()
                {
                    AttatchedPost = post
                };
                using (DataContext context = new DataContext())
                {
                    EducationPost rp = new EducationPost();
                    var           EducationPostId  = context.EducationPosts.Select(r => r.Id);
                    var           categoryFiles    = context.UserFiles.Where(x => EducationPostId.Contains(x.BlogPostId)).ToList();
                    var           picExtensionList = new List <string>()
                    {
                        ".png", ".PNG", ".jpg", ".JPG", ".jpeg", ".JPEG"
                    };
                    var picList = categoryFiles.Where(x => picExtensionList.Contains(x.FileExtension)).Where(x => x.BlogPostId == post.Id);
                    rpfc.AttatchedPics = picList.ToList();
                    rpfc.AttatchedDocs = categoryFiles.Where(x => x.BlogPostId == post.Id).Where(x => !picExtensionList.Contains(x.FileExtension)).ToList();
                }
                model.PostFileCombinations.Add(rpfc);
            }

            return(View(model));
        }
        public ActionResult Cv()
        {
            CvViewModel cvViewModel = new CvViewModel()
            {
                Contact             = _contactRepository.GetAll().FirstOrDefault(),
                PrivateInformation  = _privateInformationRepository.GetAll().FirstOrDefault(),
                Achievements        = _achievementRepository.GetAll().ToList(),
                AdditionalInfos     = _additionalInformationRepository.GetAll().ToList(),
                Educations          = _educationRepository.GetAll().ToList(),
                EmploymentHistories = _employmentHistoryRepository.GetAll().ToList(),
                Projects            = _projectsRepository.GetAll().ToList(),
                Technologies        = _technologyRepository.GetAll().ToList()
            };

            return(View(cvViewModel));
        }
        public void EducationRepository_GetAll_Works()
        {
            var listToReturn = new List <IEducationEntity>();

            for (int i = 0; i < 315; i++)
            {
                IEducationEntity ee = new EducationEntity();
                ee.Credential  = "test credential";
                ee.Institution = "test institution";
                listToReturn.Add(ee);
            }
            var mockXml = new Mock <IEducationXMLService>();

            mockXml.Setup(T => T.GetAll()).Returns(listToReturn);
            var repos = new EducationRepository(mockXml.Object);

            var list = repos.GetAll();

            Assert.AreEqual(315, list.Count);
            Assert.AreEqual("test credential", list[0].Credential);
            Assert.AreEqual("test institution", list[0].Institution);
        }