public void Create(PassOneObject obj) { obj.Id = GetNextIdValue(); using (var db = new PassOneContext()) { db.Users.Add(ConvertToEntity(obj)); db.SaveChanges(); } }
public void Delete(PassOneObject obj) { using (var db = new PassOneContext()) { var userQuery = from u in db.Users select u; var user = userQuery.ToList().FirstOrDefault(user1 => user1.Id == obj.Id); db.Users.Remove(user); db.SaveChanges(); } }
public void Delete(PassOneObject obj) { using (var db = new PassOneContext()) { var query = from c in db.Credentials select c; var creds = query.ToList().FirstOrDefault(creds1 => creds1.Id == obj.Id); db.Credentials.Remove(creds); db.SaveChanges(); } }
public void Edit(PassOneObject obj) { using (var db = new PassOneContext()) { var userQuery = from u in db.Users select u; var user = userQuery.ToList().FirstOrDefault(user1 => user1.Id == obj.Id); userQuery.ToList().Remove(user); userQuery.ToList().Add((ConvertToEntity(obj))); db.SaveChanges(); } }
public void Edit(PassOneObject obj) { using (var db = new PassOneContext()) { var credsQuery = from u in db.Credentials select u; var creds = credsQuery.ToList().FirstOrDefault(user1 => user1.Id == obj.Id); db.Credentials.Remove(creds); db.Credentials.Add((ConvertToEntity(obj))); db.SaveChanges(); } }
public void Edit(PassOneObject obj) { using (var db = new PassOneContext()) { var credsQuery = from u in db.Credentials select u; var creds = credsQuery.ToList().FirstOrDefault(user1 => user1.Id == obj.Id); var userQuery = from u in db.Users select u; var user = userQuery.ToList().FirstOrDefault(user1 => user1.Id == creds.UserId); db.Credentials.Remove(creds); db.Credentials.Add(new EntityCredential(new Encryption(user.k, user.v), (Credentials) obj)); db.SaveChanges(); } }
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(); } }
private User ConvertToEntity(PassOneObject obj) { var user = (PassOneUser) obj; var newUser = new User { Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Username = user.Username, Password = user.Password, k = user.K, v = user.V }; return newUser; }
private Credential ConvertToEntity(PassOneObject obj) { var creds = (PassOneCredentials)obj; var newCred = new Credential { Id = creds.Id, UserId = creds.UserId, Title = creds.Website, Url = creds.Url, Username = creds.Username, Email = creds.EmailAddress, Password = creds.Password }; return newCred; }
private Credential ConvertToEntity(PassOneObject obj) { var creds = (PassOneCredentials) obj; var newCred = new Credential { Website = creds.EncryptedWebsite, Url = creds.EncryptedUrl, Username = creds.EncryptedUsername, Email = creds.EncryptedEmail, Password = creds.EncryptedPassword }; return newCred; }