コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: VaultsController.cs プロジェクト: ryanochoa8/Keepr
 [HttpGet("{id}")] //NOTE "Can Get Vault By Id"
 public ActionResult <Vault> Get(int id)
 {
     try
     {
         return(Ok(_repo.GetVaultById(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #3
0
        internal Vault GetVaultById(int id, string userId)
        {
            Vault foundVault = _repo.GetVaultById(id);

            if (foundVault == null)
            {
                throw new Exception("This vault does not exist.");
            }
            if (foundVault.UserId != userId)
            {
                throw new Exception("This vault does not belong to you.");
            }
            return(foundVault);
        }
コード例 #4
0
ファイル: VaultsController.cs プロジェクト: Felixr91/keepr
        public IEnumerable <Vault> GetVault()
        {
            string uid = HttpContext.User.Identity.Name;

            return(_repo.GetVaultById(uid));
        }