예제 #1
0
        public ActionResult <Vault> GetById(int id)
        {
            var   uId    = HttpContext.User.Identity.Name;
            Vault result = _repo.GetById(id, uId);

            return(Ok(result));
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        public ActionResult <Vault> Get(string userId)
        {
            IEnumerable <Vault> found = _vr.GetById(userId);

            if (found == null)
            {
                return(BadRequest());
            }
            return(Ok(found));
        }
예제 #5
0
 public ActionResult <Vault> Get(int id)
 {
     try
     {
         return(Ok(_repo.GetById(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
예제 #6
0
        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"));
        }
예제 #7
0
 public Vault GetById(int id)
 {
     return(_db.GetById(id));
 }
예제 #8
0
 public Vault Get(int id)
 {
     return(_repo.GetById(id));
 }