Beispiel #1
0
        internal VaultKeep GetById(int id)
        {
            var data = _repo.GetById(id);

            if (data == null)
            {
                throw new Exception("Invalid Id");
            }
            return(data);
        }
        public DTOVaultKeep Get(int Id)
        {
            DTOVaultKeep exists = _repo.GetById(Id);

            if (exists == null)
            {
                throw new Exception("Invalid Vault Keep");
            }
            return(exists);
        }
        internal VaultKeep GetById(int id, Profile userInfo)
        {
            VaultKeep data = _repo.GetById(id);

            if (data == null)
            {
                throw new Exception("Invalid Id");
            }
            return(data);
        }
        public ActionResult <Keep> Get(int vaultId)
        {
            string             UserId = HttpContext.User.Identity.Name;
            IEnumerable <Keep> found  = _vkr.GetById(vaultId, UserId);

            if (found == null)
            {
                return(BadRequest("No"));
            }
            return(Ok(found));
        }
Beispiel #5
0
        internal void Delete(int id, string userId)
        {
            VaultKeep vaultkeep = _repo.GetById(id);

            if (vaultkeep == null)
            {
                throw new Exception("Invalid ID");
            }
            if (vaultkeep.CreatorId != userId)
            {
                throw new Exception("You can only interact with your own private data");
            }
            _repo.Delete(id);
        }
Beispiel #6
0
        public ActionResult <IEnumerable <Keep> > Get(int id)
        {
            try
            {
                var Userid = HttpContext.User.FindFirstValue("Id");



                return(Ok(_repo.GetById(id, Userid)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public string Delete(int id, string userId)
        {
            VaultKeep original = _repo.GetById(id);

            if (original == null)
            {
                throw new Exception("Bad Id");
            }
            if (original.CreatorId != userId)
            {
                throw new Exception("Not the User : Access Denied");
            }
            if (_repo.Remove(id))
            {
                return("deleted succesfully");
            }
            return("did not remove succesfully");
        }
 public IEnumerable <VaultKeepViewModel> GetById(int id, string userId)
 {
     return(_repo.GetById(id, userId));
 }
Beispiel #9
0
 public VaultKeep Get(int id)
 {
     return(db.GetById(id));
 }