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;
        }
Пример #2
0
        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);
        }
Пример #3
0
 public EnterpriseUserProfile(EnterpriseUserRegistrationModel enterpriseUserModel)
 {
     this.CompanyName = enterpriseUserModel.ContactPersonName;
     this.Website     = enterpriseUserModel.Website;
 }
Пример #4
0
 public EnterpriseUser(EnterpriseUserRegistrationModel model, EnterpriseUserProfile profile)
     : base(model, profile)
 {
     this.Roles = new List <string>();
     Roles.Add(RoleNames.ROLE_ENTERPRISE);
 }
Пример #5
0
 public EnterpriseUser(EnterpriseUserRegistrationModel model, EnterpriseUserProfile profile) 
     : base(model, profile)
 {
     this.Roles = new List<string>();
     Roles.Add(RoleNames.ROLE_ENTERPRISE);
 }