Пример #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var obj = JObject.Load(reader);
            OrderModel orderModel;

            var type = obj["Type"];
            if (type == null)
            {
                throw new ArgumentNullException("Type", "Order type is null");
            }

            string orderType = type.Value<string>();
            switch (orderType)
            {
                case OrderTypes.Ride:
                    orderModel = new RideOrder();
                    break;
                case OrderTypes.Delivery:
                    orderModel = new DeliveryOrder();
                    break;
                case OrderTypes.ClassifiedDelivery:
                    orderModel = new ClassifiedDeliveryOrder();
                    break;
                default:
                    throw new NotSupportedException(string.Concat("Order Entry type invalid/not supported - ", orderType));
            }

            serializer.Populate(obj.CreateReader(), orderModel);
            return orderModel;

        }
Пример #2
0
 public RideJobBuilder(RideOrder order, UserModel userModel, UserModel adminUserModel, IHRIDService hridService) : base(order, userModel, adminUserModel, hridService)
 {
     this._order = order;
 }