Beispiel #1
0
        static void Main(string[] args)
        {
            Comment c1 = new Comment("Have a nice trip.");
            Comment c2 = new Comment("Wow that's awesome!");
            Post    p1 = new Post(
                DateTime.Parse("21/06/2018 13:05:44"),
                "Traveling to New Zeland",
                "I'm goingo to visit this wonderful country",
                12);

            p1.AddComments(c1);
            p1.AddComments(c2);

            Comment c3 = new Comment("Good night");
            Comment c4 = new Comment("May the force be with you");
            Post    p2 = new Post(
                DateTime.Parse("28/07/2018 23:14:19"),
                "Good night guys",
                "See you tomorrow",
                5);

            p2.AddComments(c3);
            p2.AddComments(c4);

            Console.WriteLine(p1);
            Console.WriteLine(p2);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //Post #1
            Post Post1 = new Post(
                DateTime.Parse("21/06/2018 13:05:44"),
                "Traveling to New Zealand",
                "I'm going to visit this wonderful country!",
                12);

            //Comments Post #1
            Post1.AddComments(new Comment("Have a nice trip"));
            Post1.AddComments(new Comment("Wow that's awesome!"));

            //Post #@
            Post Post2 = new Post(
                DateTime.Parse("28/07/2018 23:14:19"),
                "Good night guys",
                "See you tomorrow",
                5);

            //Comments Post #2
            Post2.AddComments(new Comment("Good night"));
            Post2.AddComments(new Comment("May the Force be with you"));

            Console.WriteLine(Post1);
            Console.WriteLine(Post2);
        }
        static void Main(string[] args)
        {
            Comments c1 = new Comments("Have a nice trip!");
            Comments c2 = new Comments("Wow that's awesome!");

            Post p1 = new Post(DateTime.Parse("06/21/2018 13:05:04"), "Traveling to New Zealand", "I'm going to visit this wonderful country", 12);


            p1.AddComments(c1);
            p1.AddComments(c2);

            Console.WriteLine(p1);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Comments c1 = new Comments("Have a nice trip");
            Comments c2 = new Comments("Wooowww");
            Post     p1 = new Post(DateTime.Parse("21/06/2018 13:05:00"), "Travaling a new zeeland", "I´m going to visit new zeeland", 12);

            p1.AddComments(c1);
            p1.AddComments(c2);


            Comments c3 = new Comments("Good night");
            Comments c4 = new Comments("May tge force be with you");

            Post p2 = new Post(DateTime.Now, "Comments test", "É so um teste", 100);

            p2.AddComments(c3);
            p2.AddComments(c4);
            Console.WriteLine(p1);
            Console.WriteLine(p2);
        }
Beispiel #5
0
        public ActionResult <Post> AddComment(string title, CommentsDTO comment)
        {
            User user         = _userRepository.GetByEmail(User.Identity.Name);
            Post postToModify = user.GetPostByTitle(title);

            if (postToModify == null)
            {
                return(NotFound());
            }

            var commentToAdd = new Comments(comment.Text);

            postToModify.AddComments(commentToAdd);
            _userRepository.SaveChanges();
            return(CreatedAtAction(nameof(GetCommentFromPost), new { userId = user.Id, postId = postToModify.Id, commentId = commentToAdd.Id }, commentToAdd));
        }
        static void Main(string[] args)
        {
            DateTime moment1  = DateTime.ParseExact("21/06/2019 13:05:44", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            string   title1   = "Viajando com a familia";
            string   content1 = "Indo viajar com essa família linda";

            Comment comment1 = new Comment("Familia Linda!");
            Comment comment2 = new Comment("Que delícia, aproveitem por nós!");

            Post post1 = new Post(moment1, title1, content1, 23);

            post1.AddComments(comment1, comment2);

            DateTime moment2  = DateTime.ParseExact("25/04/2020 14:35:12", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            string   title2   = "Medo do Coronga";
            string   content2 = "Morrendo de medo do corona vírus #FiqueEmCasa!";

            Comment comment3 = new Comment("Ta complicado essa situação...");
            Comment comment4 = new Comment("Se deus quiser as coisas vão melhorar!");

            Post post2 = new Post(moment2, title2, content2, 30);

            post2.AddComments(comment3, comment4);

            List <Post> posts = new List <Post>()
            {
                post1, post2
            };

            Console.Write("Escreva o caminho completo do arquivo: ");
            string path = Console.ReadLine();

            try
            {
                using (StreamWriter writer = File.CreateText(path))
                {
                    string s = JsonConvert.SerializeObject(posts, Formatting.Indented);
                    writer.WriteLine(s);
                    Console.WriteLine("Finalizado!");
                }
            }
            catch (IOException err)
            {
                Console.Write("Um erro ocorreu: ");
                Console.WriteLine(err.Message);
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            DateTime moment1  = DateTime.ParseExact("21/06/2018 13:05:44", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            string   title1   = "Traveling to New Zealand";
            string   content1 = "I'm going to visit this wonderful country!";

            Comment c1 = new Comment("Have a nice trip");
            Comment c2 = new Comment("Wow that's awesome!");

            Post post1 = new Post(moment1, title1, content1, 12);

            post1.AddComments(c1, c2);

            DateTime moment2  = DateTime.ParseExact("28/07/2018 23:14:19", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            string   title2   = "Good night guys";
            string   content2 = "See you tomorrow";

            Comment c3 = new Comment("Good night");
            Comment c4 = new Comment("May the Force be with you");

            Post post2 = new Post(moment2, title2, content2, 5);

            post2.AddComments(c3, c4);

            List <Post> list = new List <Post>()
            {
                post1, post2
            };

            Console.Write("Enter file full path: ");
            string path = Console.ReadLine();

            try {
                using (StreamWriter sw = File.CreateText(path)) {
                    string s = JsonConvert.SerializeObject(list, Formatting.Indented);
                    sw.WriteLine(s);
                    Console.WriteLine("Done!");
                }
            }
            catch (IOException e) {
                Console.WriteLine("An error occurred");
                Console.WriteLine(e.Message);
            }
        }