Beispiel #1
0
        public static bool Create(Comment comment)
        {
            JToken token = JsonConvert.SerializeObject(comment);

            string response = Requester.Post(Const.Paths.API.Comment.Base.ToString(), token.ToString(), true);

            return JsonConvert.DeserializeObject<bool>(response);
        }
Beispiel #2
0
        public static bool Edit(int id, Comment comment)
        {
            string data = JsonConvert.SerializeObject(comment);

            string url = new Uri(Const.Paths.API.Comment.Base, id.ToString()).ToString();

            string response = Requester.Put(url, data, true);

            return JsonConvert.DeserializeObject<bool>(response);
        }
        public static bool Create(Comment comment)
        {
            try
            {
                Database.Instance.Comments.Add(comment);

                Database.Instance.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {
                Log.Write("Fail to create comment", ex);

                return false;
            }
        }
        public static bool Create(int id, Comment comment)
        {
            try
            {
                Book book = BookManager.Get(id);

                book.Comments.Add(comment);

                Database.Instance.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {
                Log.Write("Fail to create comment for book", ex);

                return false;
            }
        }
        public static bool Edit(int id, Comment comment)
        {
            try
            {
                Comment current = CommentManager.Get(id);

                current.Content = current.Content == comment.Content || string.IsNullOrEmpty(comment.Content) ? current.Content : comment.Content;
                current.Email = current.Email == comment.Email || string.IsNullOrEmpty(comment.Email) ? current.Email : comment.Email;
                current.Name = current.Name == comment.Name || string.IsNullOrEmpty(comment.Name) ? current.Name : comment.Name;

                Database.Instance.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {
                Log.Write("Fail to update Comments", ex);

                return false;
            }
        }
        public ActionResult Comment(Comment model)
        {
            IComment.Create(model);

            return View("All", "Books");
        }
Beispiel #7
0
        public static void Dummy()
        {
            int book_count = Database.Instance.Books.Count();
            int comment_count = Database.Instance.Comments.Count();
            int orders_count = Database.Instance.Orders.Count();
            int replies_count = Database.Instance.Replies.Count();

            List<Comment> _comments = new List<Comment>();
            List<Reply> _replies = new List<Reply>();
            List<Order> _orders = new List<Order>();

            for (int i = 0; i < 5; i++)
            {
                Comment comment = new Comment()
                {
                    Content = "No comment",
                    Email = "*****@*****.**",
                    Name = "Test"
                };

                Reply reply = new Reply()
                {
                    Comment = "No comment",
                    Email = "*****@*****.**",
                    Name = "Test Test",
                    Website = "http://test.com"
                };

                Order order = new Order()
                {
                    CardID = "123456789",
                    CVV = 123,
                    Date = DateTime.Now,
                    Email = "*****@*****.**",
                    ExpireDate = DateTime.Now.AddYears(1),
                    Name = "Test Test"
                };

                _comments.Add(comment);
                _replies.Add(reply);
                _orders.Add(order);
            }

            for (int i = book_count; i < 5; i++)
            {
                Book book = new Book()
                {
                    Comments = _comments,
                    Orders = _orders,
                    Active = true,
                    Authors = "Ivan Shotlekov",
                    Description = "No Description",
                    ImageUrl = "http://res.cloudinary.com/bucons/image/upload/v1393189612/book_rqxnr3.jpg",
                    Name = "ICT English",
                    Price = 10,
                    Year = 2014
                };

                IBook.Create(book);
            }
        }
        public static bool Remove(int id)
        {
            try
            {
                Comment comment = new Comment();

                Database.Instance.Comments.Remove(comment);

                Database.Instance.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {
                Log.Write("Fail to remove Comment", ex);

                return false;
            }
        }