Ejemplo n.º 1
0
        public List <CommentDto> GetCommentsWithUserInformation()
        {
            var result = new List <CommentDto>();

            using (var context = new MyBlogDbContext())
            {
                result = context.Comments.Include(x => x.Post).Include(x => x.AspNetUsers).Select(item => new CommentDto()
                {
                    //AspNetUsers=item.AspNetUsers,    //TODO EKLENECEK:
                    //Post=item.Post,
                    CommentDate    = item.CommentDate,
                    Content        = item.Content,
                    Id             = item.Id,
                    IsActive       = item.IsActive,
                    UserCommentDto = new UserCommentDto()
                    {
                        CitizenshipNumber = item.AspNetUsers.CitizenshipNumber,
                        Email             = item.AspNetUsers.Email,
                        FirstName         = item.AspNetUsers.FirstName,
                        Id = item.AspNetUsers.Id
                    },
                    PostCommentDto = new PostCommentDto()
                    {
                        Id    = item.Post.Id,
                        Title = item.Post.Title
                    }
                }).ToList();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public List <CommentDto> GetListWithUserInformation(Expression <Func <Comment, bool> > expression)
        {
            var result = new List <CommentDto>();

            using (var context = new MyBlogDbContext())
            {
                result = context.Comments.Include(x => x.AspNetUsers).Select(item => new CommentDto()
                {
                    CommentDate    = item.CommentDate,
                    Content        = item.Content,
                    Id             = item.Id,
                    IsActive       = item.IsActive,
                    PostId         = item.PostId,
                    UserId         = item.UserId,
                    UserCommentDto = new UserCommentDto()
                    {
                        Id                = item.AspNetUsers.Id,
                        FirstName         = item.AspNetUsers.FirstName,
                        Email             = item.AspNetUsers.Email,
                        CitizenshipNumber = item.AspNetUsers.CitizenshipNumber
                    }
                }).ToList();
            }

            return(result);
        }
Ejemplo n.º 3
0
        public List <PostDto> GetPostsWithUserInformation()
        {
            var result = new List <PostDto>();

            using (var context = new MyBlogDbContext())
            {
                result = context.Posts.Include(y => y.Category).Include(x => x.AspNetUsers).Select(item => new PostDto {
                    CreationDate = item.CreationDate,
                    Content      = item.Content,
                    Id           = item.Id,
                    IsActive     = item.IsActive,
                    Title        = item.Title,
                    ReadCount    = item.ReadCount,
                    Voting       = item.Voting,
                    PostsUser    = new PostsUserDto()
                    {
                        Id       = item.AspNetUsers.Id,
                        UserName = item.AspNetUsers.UserName
                    },
                    Category = new CategoryDto()
                    {
                        CategoryName     = item.Category.CategoryName,
                        Id               = item.Category.Id,
                        ParentCategoryId = item.Category.ParentCategoryId
                    },
                    CategoryId = item.CategoryId,
                }).ToList();
            }

            return(result);
        }
Ejemplo n.º 4
0
        public List <UserDto> GetUsersWithUserRoles()
        {
            var result = new List <UserDto>();

            using (var context = new MyBlogDbContext())
            {
            }



            return(result);
        }
Ejemplo n.º 5
0
        public List <Comment> GetListWithUserInformation(Expression <Func <Comment, bool> > expression)
        {
            var result = new List <Comment>();

            using (var context = new MyBlogDbContext())
            {
                result = context.Comments.Include(x => x.AspNetUsers).Where(expression).Select(item => new Comment()
                {
                    CommentDate = item.CommentDate,
                    Content     = item.Content,
                    Id          = item.Id,
                    IsActive    = item.IsActive,
                    PostId      = item.PostId,
                    AspNetUsers = item.AspNetUsers,
                    UserId      = item.UserId
                }).ToList();
            }

            return(result);
        }