public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = JObject.Load(reader); RegistrationModelBase model; var type = obj["Type"]; if (type == null) { obj["Type"] = ((IdentityTypes)0).ToString(); type = obj["Type"]; } string modelType = type.Value<string>(); IdentityTypes actualType; if (!Enum.TryParse<IdentityTypes>(modelType, out actualType)) throw new NotSupportedException("Invalid AssetType Provided"); switch (actualType) { case IdentityTypes.USER: model = new UserRegistrationModel(); break; case IdentityTypes.ENTERPRISE: model = new EnterpriseUserRegistrationModel(); break; default: model = new AssetRegistrationModel(); break; } serializer.Populate(obj.CreateReader(), model); return model; }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = JObject.Load(reader); RegistrationModelBase model; var type = obj["Type"]; if (type == null) { obj["Type"] = ((IdentityTypes)0).ToString(); type = obj["Type"]; } string modelType = type.Value <string>(); IdentityTypes actualType; if (!Enum.TryParse <IdentityTypes>(modelType, out actualType)) { throw new NotSupportedException("Invalid AssetType Provided"); } switch (actualType) { case IdentityTypes.USER: model = new UserRegistrationModel(); break; case IdentityTypes.ENTERPRISE: model = new EnterpriseUserRegistrationModel(); break; default: model = new AssetRegistrationModel(); break; } serializer.Populate(obj.CreateReader(), model); return(model); }
public AssetProfile(AssetRegistrationModel assetModel) : base(assetModel as UserRegistrationModel) { this.NationalId = assetModel.NationalId; this.DriversLicenseId = assetModel.DrivingLicenceId; }
public Asset(AssetRegistrationModel model, AssetProfile profile) : base(model, profile, RoleNames.ROLE_ASSET) { }