public Vault GetVaultById(int id, string userId) { Vault selectedVault = _repo.GetOne(id); if (selectedVault.CreatorId != userId && selectedVault.isPrivate == true) { throw new Exception("Private Vault"); } return(_repo.GetVaultById(id)); }
internal Vault GetOne(int id) { Vault foundVault = _repo.GetOne(id); if (foundVault == null) { throw new Exception("This Vault doesn't exist"); } return(foundVault); }
public Vault GetOne(int id, Profile userInfo) { Vault vault = _vaultsRepository.GetOne(id); if (vault.IsPrivate) { if (userInfo != null && vault.CreatorId != userInfo.Id) { throw new Exception("Vault is private"); } } return(vault); }
internal Vault GetVaultById(int vaultId) { Vault res = _repo.GetOne(vaultId); if (res == null) { throw new Exception("Bad Id"); } if (res.IsPrivate == true) { throw new Exception("Vault is Private : Access Denied"); } return(res); }
public VaultKeep Create(VaultKeep newVaultKeep) { Vault vault = _vaultsRepository.GetOne(newVaultKeep.VaultId); if (newVaultKeep.CreatorId != vault.CreatorId) { throw new Exception("Invalid <VaultKeep> creator"); } newVaultKeep.Id = _vaultKeepsRepository.Create(newVaultKeep); return(newVaultKeep); }
internal string Delete(int id, Profile userInfo) { Vault returnedVault = _repo.GetOne(id); if (returnedVault == null) { throw new Exception("Does not exist"); } if (returnedVault.CreatorId != userInfo.Id) { throw new Exception("Access Denied"); } if (_repo.Delete(id)) { return("Deleted!"); } else { return("Failed"); } }
public VaultKeep Create(VaultKeep newVk, string userId) { Vault original = _vr.GetOne(newVk.VaultId); if (original == null) { throw new Exception("Bad Id"); } if (original.CreatorId != userId) { throw new Exception("Not the User : Access Denied"); } newVk.Id = _repo.Create(newVk); return(newVk); }