Example #1
0
        // POST: api/Plants
        public IHttpActionResult Post([FromBody] Dictionary <Guid, object> data)
        {
            var appId = Request.GetApplicationIdFromReferrer();

            if (appId == null)
            {
                return(InternalServerError());
            }

            var plant = applicationGridService.MapDataToEntity <Plant>(appId.Value, data);

            plantRepository.Create(plant);

            return(Ok(data));
        }
        public void MapDataToEntity_ReturnsEntityWithCorrespondingValues()
        {
            var appId = new Guid("E8349DE1-65E4-E811-8226-D89EF34A256D");
            var id    = Guid.NewGuid();

            var item = new Dictionary <Guid, object>
            {
                { new Guid("FF9264C6-52E8-E811-8229-D89EF34A256D"), id },
                { new Guid("82497bb3-98e6-e811-8226-d89ef34a256d"), "Vendor Number" },
                { new Guid("83497bb3-98e6-e811-8226-d89ef34a256d"), "Vendor Name" },
                { new Guid("84497bb3-98e6-e811-8226-d89ef34a256d"), "Inv Item Number" },
                { new Guid("85497bb3-98e6-e811-8226-d89ef34a256d"), "JDE" }
            };

            var result = service.MapDataToEntity <ItemNumber>(appId, item);

            Assert.AreEqual(id, result.Id);
            Assert.AreEqual("Vendor Number", result.VendorNumber);
            Assert.AreEqual("Vendor Name", result.VendorName);
            Assert.AreEqual("Inv Item Number", result.InvoiceItemNumber);
            Assert.AreEqual("JDE", result.JDENumber);
        }