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