Esempio n. 1
0
        public static bool Create(Book book)
        {
            string bookJson = JsonConvert.SerializeObject(book);

            string response = Requester.Post(Const.Paths.API.Book.Base.ToString(), bookJson);

            return JsonConvert.DeserializeObject<bool>(response);
        }
Esempio n. 2
0
        public static bool Create(Book book)
        {
            try
            {
                Database.Instance.Books.Add(book);

                Database.Instance.SaveChanges();

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

                return false;
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        public static bool Edit(int id, Book book)
        {
            string url = new Uri(Const.Paths.API.Base, id.ToString()).ToString();

            string bookJson = JsonConvert.SerializeObject(book);

            string response = Requester.Put(url, bookJson);

            return JsonConvert.DeserializeObject<bool>(response);
        }