Ejemplo n.º 1
0
        public ActionResult <Vault> AddVault(VaultModel vault)
        {
            var id = HttpContext.User.Identity.Name;

            vault.UserId = id;
            return(Ok(_repo.AddVault(vault)));
        }
Ejemplo n.º 2
0
        //add a vault
        public VaultModel AddVault(VaultModel newVault)
        {
            int id = _db.ExecuteScalar <int>(@"INSERT INTO Vaults (userId, name, description, location)
      VALUES (@UserId, @Name, @Description, @Location);
      SELECT LAST_INSERT_ID();", newVault);

            if (id == 0)
            {
                return(null);
            }
            newVault.Id = id;
            return(newVault);
        }
Ejemplo n.º 3
0
        static VaultModel ToVaultModel(Vault vault)
        {
            string dname    = null;
            string username = null;
            var    model    = new VaultModel
            {
                VaultUri    = vault.Properties.VaultUri,
                DisplayName = vault.Tags?.TryGetValue("displayName", out dname) == true ? dname : null,
                Username    = vault.Tags?.TryGetValue("userName", out username) == true ? username : null,
                Name        = vault.Name,
                Location    = vault.Location
            };

            return(model);
        }