Пример #1
0
        public Cheese Create(CheeseRequest request)
        {
            var result = _db.Cheeses.Add(request.ToCheese(0));

            _db.SaveChanges();
            return(result.Entity);
        }
Пример #2
0
        public void Update()
        {
            _db.Cheeses.Add(GetTestCheese());
            _db.SaveChanges();

            var updated = new CheeseRequest
            {
                Name         = "Updated Name",
                Color        = "Updated Color",
                ImageUrl     = "https://google.com/updated-image-url.jpg",
                PricePerKilo = (decimal)9.99
            };

            _controller.Update(1, updated);

            _db.Cheeses.Find(1L).Should().BeEquivalentTo(updated.ToCheese(1));
        }