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; }
public RideJobBuilder(RideOrder order, UserModel userModel, UserModel adminUserModel, IHRIDService hridService) : base(order, userModel, adminUserModel, hridService) { this._order = order; }