public List <CategoryDTO> TumListe()
        {
            List <Category>    CategoryList    = CategoryRepo.TumListe().ToList();
            List <CategoryDTO> CategoryDtoList = new List <CategoryDTO>();

            foreach (Category item in CategoryList)
            {
                CategoryDTO CategoryDto = new CategoryDTO()
                {
                    CategoryDtoId          = item.Id,
                    CreatedUserNameDto     = item.CreatedUserName,
                    CreatedDateDto         = item.CreatedDate.Value,
                    ModifiedUserNameDto    = item.ModifiedUserName,
                    ModifiedDateDto        = item.ModifiedDate.Value,
                    NameCategoryDto        = item.Name,
                    SeoCategoryDTO         = item.SeoCategory,
                    DescriptionCategoryDto = item.Description,
                    PostDtoList            = item.PostList.Select(postEntity => new PostDTO
                    {
                        PostDtoId = postEntity.Id,
                    }).ToList()
                };
                CategoryDtoList.Add(CategoryDto);
            }
            return(CategoryDtoList);
        }
Example #2
0
        public List <UserDTO> TumListe()
        {
            List <User>    UserList    = UserRepo.TumListe().ToList();
            List <UserDTO> UserDtoList = new List <UserDTO>();

            foreach (User item in UserList)
            {
                UserDTO AdminDto = new UserDTO()
                {
                    UserNameDTO = item.UserName,
                    PasswordDTO = item.Password
                };
                UserDtoList.Add(AdminDto);
            }
            return(UserDtoList);
        }
        public List <PostDTO> TumListe()
        {
            List <Post> PostList = PostRepo.TumListe().ToList();

            List <PostDTO> PostDTOList = new List <PostDTO>();

            foreach (Post item in PostList)
            {
                PostDTO PostDTO = new PostDTO()
                {
                    PostDtoId           = item.Id,
                    TitleDto            = item.Title,
                    ContentDto          = item.Content,
                    SeolinkDto          = item.Seolink,
                    CreatedUserNameDto  = item.CreatedUserName,
                    CreatedDateDto      = item.CreatedDate.Value,
                    ModifiedUserNameDto = item.ModifiedUserName,
                    ModifiedDateDto     = item.ModifiedDate.Value,
                    ViewCountDto        = item.ViewCount.Value,
                    LikeCountDto        = item.LikeCount.Value,
                    CategoryDTO         = new CategoryDTO()
                    {
                        CategoryDtoId          = item.Category.Id,
                        NameCategoryDto        = item.Category.Name,
                        DescriptionCategoryDto = item.Category.Description
                    },
                    UserDTO = new UserDTO()
                    {
                        NameDTO        = item.User.Name,
                        SurnameDTO     = item.User.Surname,
                        CreatedDateDto = item.CreatedDate.Value
                    }
                };

                PostDTOList.Add(PostDTO);
            }

            return(PostDTOList);
        }