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)); } }
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)); }; }
// 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)); } }
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)); } }
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)); } }