public CredentialViewModel Build(Credential credential)
 {
     return new CredentialViewModel()
       {
     Id = credential.Id,
     CredentialType = new CredentialTypeViewModelBuilder(this.handler).Build(
       this.handler.Storage.GetRepository<ICredentialTypeRepository>().WithKey(credential.CredentialTypeId)
     ),
     Identifier = credential.Identifier
       };
 }
        public Credential Map(CreateOrEditViewModel createOrEdit)
        {
            Credential credential = new Credential();

              if (createOrEdit.Id != null)
            credential = this.handler.Storage.GetRepository<ICredentialRepository>().WithKey((int)createOrEdit.Id);

              else credential.UserId = createOrEdit.UserId;

              credential.CredentialTypeId = createOrEdit.CredentialTypeId;
              credential.Identifier = createOrEdit.Identifier;

              if (!string.IsNullOrEmpty(createOrEdit.Secret))
            credential.Secret = createOrEdit.ApplyMd5HashingToSecret ? MD5Hasher.ComputeHash(createOrEdit.Secret) : createOrEdit.Secret;

              return credential;
        }