public static bool Create(Reply reply) { string data = JsonConvert.SerializeObject(reply); string response = Requester.Post(Const.Paths.API.Reply.Base.ToString(), data); return JsonConvert.DeserializeObject<bool>(response); }
public static bool Edit(int id, Reply reply) { string url = new Uri(Const.Paths.API.Order.Base, id.ToString()).ToString(); string data = JsonConvert.SerializeObject(reply); string response = Requester.Put(url, data); return JsonConvert.DeserializeObject<bool>(response); }
public static bool Create(Reply reply) { try { Database.Instance.Replies.Add(reply); Database.Instance.SaveChanges(); return true; } catch (Exception ex) { Log.Write("Fail to create Reply.", ex); return false; } }
public static bool Edit(int id, Reply reply) { try { Reply current = ReplyManager.Get(id); current.Comment = current.Comment == reply.Comment || string.IsNullOrEmpty(reply.Comment) ? current.Comment : reply.Comment; current.Name = current.Name == reply.Name || string.IsNullOrEmpty(reply.Name) ? current.Name : reply.Name; current.Website = current.Website == reply.Website || string.IsNullOrEmpty(reply.Website) ? current.Website : reply.Website; Database.Instance.SaveChanges(); return true; } catch (Exception ex) { Log.Write("Fail to update Comment.", ex); return false; } }
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); } }