예제 #1
0
        public static bool Create(Order order)
        {
            string data = JsonConvert.SerializeObject(order);

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

            return JsonConvert.DeserializeObject<bool>(response);
        }
예제 #2
0
        public static bool Edit(int id, Order order)
        {
            string url = new Uri(Const.Paths.API.Order.Base, id.ToString()).ToString();

            string data = JsonConvert.SerializeObject(order);

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

            return JsonConvert.DeserializeObject<bool>(response);
        }
예제 #3
0
        public static bool Create(int book_id, Order order)
        {
            string url = new Uri(Const.Paths.API.Order.Base, book_id.ToString()).ToString();

            string data = JsonConvert.SerializeObject(order);

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

            return JsonConvert.DeserializeObject<bool>(response);
        }
예제 #4
0
        public static bool Create(int book_id, Order order)
        {
            try
            {
                Book book = BookManager.Get(book_id);

                book.Orders.Add(order);

                Database.Instance.SaveChanges();

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

                return false;
            }
        }
예제 #5
0
        public static bool Create(Order order)
        {
            try
            {
                Database.Instance.Orders.Add(order);

                var errors = Database.Instance.GetValidationErrors();

                Database.Instance.SaveChanges();

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

                return false;
            }
        }
예제 #6
0
        public static bool Edit(int id, Order order)
        {
            try
            {
                Order current = OrderManager.Get(id);

                current.CardID = current.CardID == order.CardID || string.IsNullOrEmpty(current.CardID) ? current.CardID : order.CardID;
                current.CVV = current.CVV == order.CVV ? current.CVV : order.CVV;
                current.Date = current.Date == order.Date || current.Date == null ? current.Date : order.Date;
                current.Email = current.Email == order.Email || string.IsNullOrEmpty(current.Email) ? current.Email : order.Email;
                current.ExpireDate = current.ExpireDate == order.ExpireDate || current.Date == null ? current.ExpireDate : order.ExpireDate;
                current.Name = current.Name == order.Name || string.IsNullOrEmpty(current.Name) ? current.Name : order.Name;

                Database.Instance.SaveChanges();

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

                return false;
            }
        }
예제 #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);
            }
        }