Ejemplo n.º 1
0
 public ActionResult <VaultKeep> Create([FromBody] VaultKeep newRelation)
 {
     try
     {
         return(_vks.Create(newRelation, HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public ActionResult <DTOVaultKeep> Create([FromBody] DTOVaultKeep newVaultKeep)
 {
     try
     {
         newVaultKeep.UserId = findUserInfo();
         return(Ok(_vks.Create(newVaultKeep)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Ejemplo n.º 3
0
 public ActionResult <VaultKeep> Create([FromBody] VaultKeep vaultKeep)
 {
     try
     {
         string userId = HttpContext.User.FindFirstValue("Id");
         return(Ok(_vks.Create(vaultKeep, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 4
0
 public ActionResult <VaultKeep> create([FromBody] VaultKeep vaultKeep)
 {
     try
     {
         vaultKeep.UserId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(_vks.Create(vaultKeep));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 5
0
 public ActionResult <DTOVaultedKeep> Post([FromBody] DTOVaultedKeep newDTOVK)
 {
     try
     {
         newDTOVK.UserId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_vks.Create(newDTOVK)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 6
0
 public async Task<ActionResult<VaultKeep>> CreateAsync([FromBody] VaultKeep newVK)
 {
     try
     {
         Profile userInfo = await HttpContext.GetUserInfoAsync<Profile>();
         newVK.CreatorId = userInfo.Id;
         return Ok(_vkserv.Create(newVK));
     }
     catch (System.Exception err)
     {
         return BadRequest(err.Message);
     }
 }
Ejemplo n.º 7
0
 public ActionResult <String> Create([FromBody] VaultKeep newData)
 {
     try
     {
         newData.UserId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         _vks.Create(newData);
         return(Ok("Success"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 8
0
 public ActionResult <VaultKeep> Create([FromBody] VaultKeep newVaultKeep)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         newVaultKeep.UserId = userId;
         return(Ok(_vks.Create(newVaultKeep)));
     }
     catch (System.Exception error)
     {
         return(BadRequest(error.Message));
     }
 }
Ejemplo n.º 9
0
        public ActionResult <VaultKeep> Create([FromBody] VaultKeep newVKeep)
        {
            string reqUserId = HttpContext.User.FindFirstValue("Id");
            User   user      = _as.GetUserById(reqUserId);

            newVKeep.UserId = user.Id;
            //Check if vault is owned by user
            newVKeep.VaultId = _vs.Get(newVKeep.VaultId, newVKeep.UserId).Id;
            //Check if keep exists
            newVKeep.KeepId = _ks.Get(newVKeep.KeepId).Id;
            //Post to vk repo
            return(Ok(_vks.Create(newVKeep)));
        }
Ejemplo n.º 10
0
 public ActionResult <VaultKeep> Post([FromBody] VaultKeep newVaultKeep)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         newVaultKeep.UserId = userId;
         return(Ok(_vs.Create(newVaultKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 11
0
        public async Task <ActionResult <VaultKeep> > Post([FromBody] VaultKeep newVk)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVk.CreatorId = userInfo.Id;
                return(Ok(_vks.Create(newVk, userInfo.Id)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 12
0
        public async Task <ActionResult <string> > CreateAsync([FromBody] VaultKeep newVk)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVk.CreatorId = userInfo.Id;
                return(Ok(_service.Create(newVk)));
            }
            catch (System.Exception err)
            {
                return(BadRequest(err.Message));
            }
        }
Ejemplo n.º 13
0
        async public Task <ActionResult <VaultKeep> > Post([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVaultKeep.CreatorId = userInfo.Id;
                return(Ok(_service.Create(newVaultKeep)));
            }
            catch (Exception err)
            {
                return(BadRequest(err.Message));
            }
        }
Ejemplo n.º 14
0
        public async System.Threading.Tasks.Task <ActionResult <string> > Create([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVaultKeep.CreatorId = userInfo.Id;
                VaultKeep vaultKeep = _vks.Create(newVaultKeep, userInfo.Id);
                return(Ok(vaultKeep));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 15
0
        public async Task <ActionResult <VaultKeep> > CreateAsync([FromBody] VaultKeep newVK)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVK.CreatorId = userInfo.Id;
                VaultKeep createdVK = _service.Create(newVK);
                return(Ok(createdVK));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 16
0
        public async Task <ActionResult <VaultKeep> > Create([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVaultKeep.CreatorId = userInfo.Id;
                VaultKeep created = _vaultKeepsService.Create(newVaultKeep, userInfo);
                return(Ok(created));
            }
            catch (System.Exception error)
            {
                return(BadRequest(error.Message));
            }
        }
Ejemplo n.º 17
0
        public async Task <ActionResult <VaultKeep> > Post([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVaultKeep.creatorId = userInfo.id;
                VaultKeep created = _vks.Create(newVaultKeep);
                return(Ok(created));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 18
0
        public async Task <ActionResult <VaultKeep> > Create([FromBody] VaultKeep newVK)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVK.CreatorId = userInfo.Id;
                _serv.Create(newVK);
                return(Ok("nice job"));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 19
0
 public ActionResult <VaultKeep> Post([FromBody] VaultKeep newVaultKeep)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         newVaultKeep.UserId = userId;
         VaultKeep newVK = _vks.Create(newVaultKeep);
         _ks.Keep(newVK.KeepId);
         return(Ok(newVK));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 20
0
        public async Task <ActionResult <VaultKeep> > Create([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                Profile userinfo = await HttpContext.GetUserInfoAsync <Profile>();

                Vault vault = _vserv.GetById(newVaultKeep.VaultId, userinfo.Id);
                newVaultKeep.CreatorId = userinfo.Id;
                return(Ok(_serv.Create(newVaultKeep, vault.CreatorId)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 21
0
        public async Task <ActionResult <VaultKeep> > Create([FromBody] VaultKeep newVKS)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVKS.CreatorId = userInfo.Id;
                _ks.updateKeepCount(newVKS.KeepId);
                VaultKeep created = _vks.Create(newVKS);
                return(Ok(created));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 22
0
        public async Task <ActionResult <VaultKeep> > CreateVaultKeep([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                var userInfo = await HttpContext.GetUserInfoAsync <Account>();

                newVaultKeep.CreatorId = userInfo?.Id;
                VaultKeep vk = _vks.Create(newVaultKeep);
                _ks.incrementKeeps(vk.KeepId);
                return(Ok(vk));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 23
0
        public async Task <ActionResult <VaultKeep> > Create([FromBody] VaultKeep vaultKeep)
        {
            try
            {
                Vault   original = _vs.GetOne(vaultKeep.VaultId);
                Profile userinfo = await HttpContext.GetUserInfoAsync <Profile>();

                vaultKeep.CreatorId = userinfo.Id;

                return(Ok(_vks.Create(vaultKeep)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 24
0
 [Authorize] //could throw it at top level i guess
 public ActionResult <DTOVaultKeep> Post([FromBody] DTOVaultKeep newDTOVaultKeep)
 {
     try
     {
         // var claim = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         // if(claim != null){
         //     newDTOVaultKeep.UserId = claim.Value;
         // }   this broke it lol
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         newDTOVaultKeep.UserId = userId;
         return(Ok(_vks.Create(newDTOVaultKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 25
0
 public ActionResult <VaultKeep> Post([FromBody] VaultKeep newVaultKeep)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         newVaultKeep.UserId = userId;
         int  updateId = newVaultKeep.KeepId;
         int  vaultId  = newVaultKeep.VaultId;
         Keep update   = _ks.GetById(updateId);
         _vks.IncrementKeepCount(update, vaultId, userId);
         return(Ok(_vks.Create(newVaultKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 26
0
 public ActionResult <VaultKeep> Create([FromBody] VaultKeep newVaultKeep)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("You must be logged in.");
         }
         newVaultKeep.UserId = user.Value;
         return(Ok(_vks.Create(newVaultKeep)));
     }
     catch (System.Exception error)
     {
         return(BadRequest(error.Message));
     }
 }
Ejemplo n.º 27
0
 public ActionResult <VaultKeepViewModel> Create([FromBody] VaultKeepViewModel newVaultKeep)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("Must be logged in.");
         }
         newVaultKeep.UserId = user.Value;
         return(Ok(_vks.Create(newVaultKeep)));
     }
     catch (System.Exception)
     {
         throw;
     }
 }
Ejemplo n.º 28
0
 public ActionResult <VaultKeep> Create([FromBody] VaultKeep newVaultKeep)
 {
     try
     {
         var user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("Please Login to Continue!");
         }
         newVaultKeep.UserId = user.Value;
         return(Ok(_vk.Create(newVaultKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 29
0
 public ActionResult <VaultKeep> Create([FromBody] VaultKeep newVaultKeep)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("invalid id");
         }
         // TODO  why isnt this returning a userId?
         string userId = user.Value;
         return(Ok(_vks.Create(newVaultKeep)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Ejemplo n.º 30
0
        public async Task <ActionResult <VaultKeep> > Post([FromBody] VaultKeep newVk)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                int   vaultId       = newVk.VaultId;
                Vault selectedVault = _vs.GetVaultById(vaultId, userInfo.Id);
                newVk.CreatorId = userInfo.Id;
                return(Ok(_vks.Create(newVk, userInfo.Id, selectedVault)));
            }
            catch (Exception err)
            {
                return(BadRequest(err.Message));

                throw;
            }
        }