Exemple #1
0
        static void Main(string[] args)
        {
            IPostRepository    postRepository    = new PostDataAccess();
            IUserRepository    userRepository    = new UserDataAccess();
            ICommentRepository commentRepository = new CommentDataAccess();

            var service = new UserService(userRepository, postRepository, commentRepository);

            var response = service.GetUserActiveRespose(1);

            foreach (var item in response)
            {
                Console.Write(item);
            }
            var service1 = new UserService(userRepository, postRepository, commentRepository);

            var comments = service1.GetUserComents(2);

            foreach (var item in comments)
            {
                Console.Write(item.Comment);
            }



            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            IPostRepository    postRepository    = new PostDataAccess();
            IUserRepository    userRepository    = new UserDataAccess();
            ICommentRepository commentRepository = new CommentDataAccess();

            var service = new UserService(userRepository, postRepository);

            // var response = service.GetUserActiveRespose(4);

            var commentService = new UserCommentsService(userRepository, postRepository, commentRepository);
            int user           = 9;
            var userComments   = commentService.GetUserComments(user);

            if (userComments.Comments.Count == 0)
            {
                Console.WriteLine($"User {user} has no comments");
            }
            foreach (var c in userComments.Comments)
            {
                Console.WriteLine($"Comment for User: {userComments.User.Id},PostId: {c.PostId}, Body: {c.Text}");
            }

            Console.ReadKey();
        }
 public static async Task <Comment> Add(Comment comment, Account account)
 {
     CheckValid(comment);
     comment.Post  = comment.Post.GetManaged;
     comment.Owner = account;
     return(await CommentDataAccess.Add(comment));
 }
        public static Comment Get(int id)
        {
            var comment = CommentDataAccess.Get(id);

            if (comment == null)
            {
                throw new Error404NotFound <Comment>(id);
            }

            return(comment);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            IPostRepository    postRepository    = new PostDataAccess();
            IUserRepository    userRepository    = new UserDataAccess();
            ICommentRepository commentRepository = new CommentDataAccess();

            var service = new UserService(userRepository, postRepository, commentRepository);

            var response = service.GetUserActiveRespose(2);

            var comments = service.GetCommentsPerUser(2);
        }
        public static async Task <Comment> Update(Comment comment, Account account)
        {
            var commentInDatabase = Get(comment.Id);

            if (!commentInDatabase.IsOwner(account))
            {
                throw new Error403Forbidden <Comment>("Bạn không có quyền chỉnh sửa bình luận này");
            }

            CheckValid(comment);

            return(await CommentDataAccess.Update(commentInDatabase, comment));
        }
        private void SubmitButtonClicked(object sender, EventArgs e)
        {
            CommentDataAccess commentDataAccess = new CommentDataAccess();
            Comment           comment           = new Comment()
            {
                Bookname      = nameOfPage,
                Date          = DateTime.Now,
                CommentOfBook = commentEditor.Text,
                UserEmail     = App.UserEmail
            };

            commentDataAccess.AddComment(comment);
            DisplayAlert("New Comment", "Comment sent.", "OK");
            AddCommentToPage(comment);
            commentEditor.Text = "";
        }
Exemple #8
0
        static void Main(string[] args)
        {
            IPostRepository    postRepository    = new PostDataAccess();
            IUserRepository    userRepository    = new UserDataAccess();
            ICommentRepository commentRepository = new CommentDataAccess();

            var service        = new UserService(userRepository, postRepository);
            var commentService = new CommentService(userRepository, postRepository, commentRepository);
            var response       = service.GetUserActiveRespose(2);
            var userComments   = commentService.GetUserComments(1);

            foreach (var c in userComments.Comments)
            {
                Console.WriteLine(c.Text);
            }

            Console.ReadKey();
        }
        public static async Task Delete(int id, Account account)
        {
            var comment = Get(id);

            var conditionOfAdmin = account.Access == EnumAccess.Administrator;

            var conditionOfMod = account.Access == EnumAccess.Moderator &&
                                 (EnumAccess.BannedUser | EnumAccess.NormalUser).HasFlag(comment.Owner.Access);

            var conditionOfNormal = comment.IsOwner(account);

            if (!(conditionOfAdmin || conditionOfMod || conditionOfNormal))
            {
                throw new Error403Forbidden <Comment>("Bạn không có quyền xóa bình luận này");
            }

            await CommentDataAccess.Delete(comment);
        }
Exemple #10
0
        static void Main(string[] args)
        {
            IPostRepository postRepository = new PostDataAccess();
            IUserRepository userRepository = new UserDataAccess();

            var service = new UserService(userRepository, postRepository);

            var response = service.GetUserActiveRespose(2);



            CommentDataAccess comment = new CommentDataAccess();
            var lista = comment.GetCommentsByUserId(8);

            foreach (var item in lista)
            {
                Console.WriteLine($" id : {item.Id} text : {item.Text}");
            }



            Console.ReadLine();
        }
        public BookPage(string name)
        {
            InitializeComponent();
            ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.FromHex("#efefef");
            Book book = BookDataAccess.GetBookByName(name);

            Bookphoto.Source     = book.BookPhoto;
            Bookname.Text        = book.BookName;
            BookDescription.Text = book.Description;
            AuthorName.Text      = book.AuthorName;
            Author authorClass = author.GetAuthorbyName(book.AuthorName);

            AuthorPhoto.Source = authorClass.AuthorPhoto;
            nameOfPage         = name;

            CommentDataAccess commentDataAccess = new CommentDataAccess();
            List <Comment>    comments          = commentDataAccess.GetCommentOfBook(name);

            foreach (Comment comment in comments)
            {
                AddCommentToPage(comment);
            }
        }
        public DBResponse SaveComment(CommentEntity objComment)
        {
            CommentDataAccess objDataAccess = new CommentDataAccess();

            return(objDataAccess.SaveComment(objComment));
        }
Exemple #13
0
 public CommentBl(SportWorldContext sportWorldContext)
 {
     _commentDal = new CommentDataAccess(sportWorldContext);
     _productDal = new ProductDataAccess(sportWorldContext);
     _userDal    = new UserDataAccess(sportWorldContext);
 }