Пример #1
0
 public VaultKeeps Create([FromBody] VaultKeeps newVaultKeep)
 {
     if (ModelState.IsValid)
     {
         var user = HttpContext.User;
         newVaultKeep.UserId = user.Identity.Name;
         return(db.CreateVaultKeep(newVaultKeep));
     }
     return(null);
 }
        public VaultKeep CreateVaultKeep(VaultKeep newVk)
        {
            Vault found = _vaultRepo.GetVaultById(newVk.VaultId);

            if (found.CreatorId != newVk.CreatorId)
            {
                throw new Exception("Cannot add Keeps to vaults that are not yours");
            }

            newVk.Id = _repo.CreateVaultKeep(newVk);
            return(newVk);
        }
        public ActionResult <VaultKeep> Create([FromBody] VaultKeep VaultKeep)
        // needs a keep id and a vault id
        {
            VaultKeep.UserId = HttpContext.User.FindFirstValue("Id");

            try
            {
                return(Ok(_repository.CreateVaultKeep(VaultKeep)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Пример #4
0
 public VaultKeep CreateVaultKeep(VaultKeep newVaultKeep)
 {
     return(_repo.CreateVaultKeep(newVaultKeep));
 }