Beispiel #1
0
        public void ReadFromJson()
        {
            PhoneOrderEntity orderInstance;
            var          factory = new PhoneOrderEntityFactory();
            const String json    = "{\"first_name\":\"John\",\"last_name\":\"Smith\"}";

            factory.FromJson(json);
            orderInstance = factory.GetInstance();

            Assert.AreEqual("John", orderInstance.FirstName);
            Assert.AreEqual("Smith", orderInstance.LastName);
        }
Beispiel #2
0
        public String CreatePhoneOrder(Stream body)
        {
            String           json        = getJsonFromBody(body);
            ResponseDTO      responseDTO = new ResponseDTO();
            PhoneOrderEntity order;

            phoneOrderEntityFactory.FromJson(json);
            phoneOrderEntityFactory.GenerateId();
            phoneOrderEntityFactory.GeneratePlacedOnDate();
            phoneOrderEntityFactory.SetStatus(PhoneOrderEntity.ApprovalStatus.Open);
            order = phoneOrderEntityFactory.GetInstance();
            phoneOrderRepository.InsertPhoneOrder(order);

            responseDTO.Result = "Done";
            return(JsonConvert.SerializeObject(responseDTO));
        }