コード例 #1
0
 public void Create(PassOneObject obj)
 {
     obj.Id = GetNextIdValue();
     var creds = (Credentials) obj;
     using (var db = new PassOneContext())
     {
         var userQuery = from u in db.Users select u;
         var user = userQuery.ToList().FirstOrDefault(user1 => user1.Id == creds.UserId);
         var entity = new EntityCredential(new Encryption(user.k, user.v), creds) {User = user};
         db.Credentials.Add(entity);
         db.SaveChanges();
     }
 }
コード例 #2
0
 private Credentials ConvertToDomainObject(User user, EntityCredential entity)
 {
     var encrypted = new EncryptedCredentials()
         {
             Id = entity.Id,
             UserId = entity.UserId,
             Website = entity.Website,
             Url = entity.Url,
             Username = entity.Username,
             EmailAddress = entity.Email,
             Password = entity.Password
         };
     return new Credentials(new Encryption(user.K, user.V), encrypted);
 }
コード例 #3
0
        public PassOneObject RetreiveById(int id)
        {
            var db = new PassOneContext();
            var query = from u in db.Credentials select u;
            var creds = query.ToList();

            var selected = new EntityCredential();
            foreach (var cred in query.Where(cred => cred.Id == id))
                selected = cred;

            var userQuery = from u in db.Users select u;
            var user = userQuery.ToList().FirstOrDefault(user1 => user1.Id == selected.UserId);
            return ConvertToDomainObject(new User(user), selected);
        }