Esempio n. 1
0
        public async Task <ActionResult <IEnumerable <VaultKeepsViewModel> > > GetKeepsByVaultAsync(int id)
        {
            try
            {
                // Profile userInfo = await HttpContext.GetUserInfoAsync<Profile>();
                if (await HttpContext.GetUserInfoAsync <Profile>() != null)
                {
                    Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                    Vault vault = _vs.GetOne(id, userInfo.Id);
                    if (vault.IsPrivate == true)
                    {
                        if (userInfo.Id == vault.CreatorId)
                        {
                            return(Ok(_ks.GetByVaultId(id)));
                        }
                        return(BadRequest("this vault is private"));
                    }
                    return(Ok(_ks.GetByVaultId(id)));
                }
                Vault vaulttwo = _vs.GetOne(id);
                if (vaulttwo.IsPrivate == true)
                {
                    return(BadRequest("private vault"));
                }
                return(Ok(_ks.GetByVaultId(id)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Esempio n. 2
0
 public ActionResult <IEnumerable <Keep> > GetKeeps(int vaultId)
 {
     try
     {
         Vault testVault = _vs.Get(vaultId);
         if (testVault.isPrivate)
         {
             return(BadRequest("This is a private vault"));
         }
         return(Ok(_ks.GetByVaultId(vaultId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     };
 }
Esempio n. 3
0
 // finds a vaultkeep by vault id
 public ActionResult <IEnumerable <VaultKeepViewModel> > GetKeepsByVaultId(int id)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_ks.GetByVaultId(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Esempio n. 4
0
        public async Task <ActionResult <IEnumerable <VaultKeepViewModel> > > GetKeeps(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_ks.GetByVaultId(id)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Esempio n. 5
0
        public async Task <ActionResult <IEnumerable <VaultKeepViewModel> > > GetKeepsByVaultIdAsync(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                Vault v = _vs.Get(id);
                if (v.IsPrivate && v.CreatorId != userInfo.Id)
                {
                    return(BadRequest());
                }
                return(Ok(_ks.GetByVaultId(id)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }