コード例 #1
0
        public ActionResult <Vault> AddVault([FromBody] Vault vault)
        {
            var id = HttpContext.User.Identity.Name;

            vault.UserId = id;
            return(Ok(_repo.AddVault(vault)));
        }
コード例 #2
0
        public ActionResult <Vault> Post([FromBody] Vault Vault)
        {
            Vault.UserId = HttpContext.User.Identity.Name;
            Vault result = _repo.AddVault(Vault);

            return(Created("api/vaults/" + result.Id, result));
        }
コード例 #3
0
 public ActionResult <string> Post([FromBody] Vault vault)
 {
     vault.UserId = HttpContext.User.Identity.Name;
     if (vault.UserId != null)
     {
         return(Ok(_repo.AddVault(vault)));
     }
     return(Unauthorized($"Can not add vault. {vault.Name}"));
 }
コード例 #4
0
        public Vault Post([FromBody] Vault newVualt)
        {
            var userId = HttpContext.User.Identity.Name;

            newVualt.userId = userId;
            if (ModelState.IsValid)
            {
                return(db.AddVault(newVualt));
            }
            return(null);
        }
コード例 #5
0
 public Vault AddVault([FromBody] Vault vault)
 {
     if (ModelState.IsValid)
     {
         return(_repo.AddVault(vault));
     }
     else
     {
         return(null);
     }
 }
コード例 #6
0
 public ActionResult <Vault> Post([FromBody] Vault vault)
 {
     vault.UserId = HttpContext.User.Identity.Name;
     return(Created("/api/vaults", _vaultRepo.AddVault(vault)));
 }