public ActionResult <Vault> GetById(int id) { var uId = HttpContext.User.Identity.Name; Vault result = _repo.GetById(id, uId); return(Ok(result)); }
internal Vault GetById(int id, string userId) { Vault data = _repo.GetById(id); if (data == null) { throw new Exception("Invalid id"); } else if (data.CreatorId != userId && data.IsPrivate == true) { throw new Exception("You can only view your own private vaults"); } else { return(data); } }
public Vault GetById(int id, string userId) { Vault res = _vr.GetById(id); if (res.IsPrivate == true && res.CreatorId != userId) { throw new Exception("Access denied"); } return(res); }
public ActionResult <Vault> Get(string userId) { IEnumerable <Vault> found = _vr.GetById(userId); if (found == null) { return(BadRequest()); } return(Ok(found)); }
public ActionResult <Vault> Get(int id) { try { return(Ok(_repo.GetById(id))); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult <Vault> Get(int id) { Vault vault = null; string user = HttpContext.User.Identity.Name; if (user != null) { vault = _repo.GetById(id, user); } if (vault != null) { return(Ok(vault)); } return(NotFound("Not found")); }
public Vault GetById(int id) { return(_db.GetById(id)); }
public Vault Get(int id) { return(_repo.GetById(id)); }