Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. DbContext.SaveChanges(); doesn't give error but does not add entity to database
  2. public void Add(object entity)
  3.         {
  4.             DbContext.Entry(entity).State = System.Data.EntityState.Added;
  5.             DbContext.SaveChanges();
  6.         }
  7.        
  8. public void StoreElectronicSignatureType(ElectronicSignatureTypeModel model)
  9.     {
  10.         var RSA = new System.Security.Cryptography.RSACryptoServiceProvider();
  11.         var parameters = RSA.ExportParameters(false);
  12.         model.modulus = Convert.ToBase64String(parameters.Modulus);
  13.         model.exponent = Convert.ToBase64String(parameters.Exponent);
  14.         model.privatekey = RSA.ToXmlString(true);
  15.  
  16.         ElectronicSignatureType electronicSignatureType = new ElectronicSignatureType();
  17.         Entity entity =  GetEntity(model.entity);
  18.         electronicSignatureType.Entity = entity;
  19.         electronicSignatureType.HashAlgorithm = model.hashAlgorithm;
  20.         electronicSignatureType.Exponent = model.exponent;
  21.         electronicSignatureType.Modulus = model.modulus;
  22.         electronicSignatureType.Version = model.version;
  23.         //electronicSignatureType.EntityId = entity.EntityId;
  24.         electronicSignatureType.PrivateKey = StrToByteArray(model.privatekey);
  25.         Add(electronicSignatureType);
  26.     }
  27.        
  28. context.ElectronicSignatureTypes.Add(electronicSignatureType);
  29. context.SaveChanges();