/// <summary>
        /// Reloads the page types from the database.
        /// </summary>
        private async Task <IEnumerable <PostType> > GetTypes()
        {
            var types = _cache?.Get <IEnumerable <PostType> >("Piranha_PostTypes");

            if (types == null)
            {
                types = await _repo.GetAll().ConfigureAwait(false);

                _cache?.Set("Piranha_PostTypes", types);
            }
            return(types);
        }
Ejemplo n.º 2
0
        public List <Post> getPostByUserType(string id_user)
        {
            List <Post> listPost     = new List <Post>();
            List <int>  listPostType = _detailUserTypeRepository.GetMulti(x => x.UserID == id_user).Select(x => x.Type).ToList();

            if (listPostType == null)
            {
                listPostType = _postTypeRepository.GetAll().Select(x => x.Id).ToList();
            }
            foreach (int i in listPostType)
            {
                List <Post> postType = new List <Post>();
                postType = _postRepository.GetMulti(x => x.Id_Type == i).OrderByDescending(x => x.DatePost).ToList();
                listPost.AddRange(postType);
            }
            return(listPost.OrderByDescending(x => x.DatePost).ToList());
        }