public IHttpActionResult Post([FromBody] ProductResource product)
        {
            var newId = _fakeDatabase.Items.Max(i => i.Id) + 1;

            var r = new ResourceWithHiddenId
            {
                Id   = newId,
                Name = product.Model
            };

            _fakeDatabase.Items.Add(r);

            return(Created(Url.Link("GetById", new { productId = newId }), r));
        }
Esempio n. 2
0
        public void formatter_withNeverShowProperty_neverShowPropertyOmitted()
        {
            // arrange
            var resource = new ResourceWithHiddenId
            {
                Id   = 1234,
                Name = "Pat Smith"
            };

            // act
            var result = TestHelpers.Format.FormatObject(resource, _formatter);

            // assert
            result.Should().NotContain("internalId");
            result.Should().NotContain("1234");
            result.Should().Contain("Pat Smith");
        }