Пример #1
0
		public void TestBookInsertion()
		{
			var book = new Book()
			{
				ISBN = "ISBN-ISBN",
				Author = Guid.NewGuid().ToString(),
				Name = Guid.NewGuid().ToString(),
			};

			using (var db = new BookStoreService.Models.StoreDbContext())
			{
				db.Books.Add(book);

				db.SaveChanges();
			}

			Assert.IsTrue(book.BookId != 0);

			using (var db = new BookStoreService.Models.StoreDbContext())
			{
				var b = db.Books.Find(book.BookId);

				Assert.IsNotNull(b);
				Assert.IsTrue(b.Name == book.Name);
			}
		}
Пример #2
0
		public ActionResult Create(Book book)
        {
            try
            {
				using (var client = new ApiRef.StoreClient())
				{
					client.PostBook(book);
				}

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Пример #3
0
		public ActionResult Edit(int id, Book book)
        {
            try
            {
				_client.PutBook(id, book);
			
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }