Exemplo n.º 1
0
 public Vault Post([FromBody] Vault vault)
 {
     if (ModelState.IsValid)
     {
         return(_repo.Create(vault));
     }
     throw new Exception("invalid vault");
 }
Exemplo n.º 2
0
 public Vault Post([FromBody] Vault vault)
 {
     if (ModelState.IsValid)
     {
         vault.UserId = HttpContext.User.Identity.Name;
         return(_repo.Create(vault));
     }
     throw new Exception("INVALID VAULT");
 }
Exemplo n.º 3
0
 public Vault Post([FromBody] Vault vault)
 {
     if (ModelState.IsValid)
     {
         vault = new Vault(vault.Name, vault.Description, vault.UserId);
         return(_repo.Create(vault));
     }
     throw new Exception("INVALID VAULT");
 }
Exemplo n.º 4
0
 public Vault Post([FromBody] Vault vault)
 {
     if (ModelState.IsValid)
     {
         vault = new Vault(vault.Name, vault.Description, vault.UserId);
         return(_repo.Create(vault));
         /// need Username?
     }
     throw new System.Exception("Invalid Vault");
 }
Exemplo n.º 5
0
 // [Authorize]
 public Vault Post([FromBody] Vault vault)
 {
     if (ModelState.IsValid)
     {
         var userId = HttpContext.User.Identity.Name;
         var vaults = _repo.GetByUserId(userId);
         vault = new Vault(vault.Name, vault.Description, vault.UserId);
         return(_repo.Create(vault));
     }
     throw new Exception("INVALID VAULT");
 }
Exemplo n.º 6
0
 public ActionResult <Vault> Post([FromBody] Vault vault)
 {
     vault.UserId = HttpContext.User.FindFirstValue("Id");
     try
     {
         return(Ok(_repo.Create(vault)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
Exemplo n.º 7
0
 public ActionResult <Vault> Post([FromBody] Vault value)
 {
     try
     {
         var id = HttpContext.User.FindFirstValue("Id");
         value.UserId = id;
         return(Ok(_repo.Create(value)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 8
0
        public Vault Post(Vault rawVault)
        {
            if (!ModelState.IsValid)
            {
                throw new Exception("Invalid information to create a vault.");
            }
            Vault vault = _repo.Create(rawVault);

            if (vault == null)
            {
                throw new Exception("Error inserting vault into the db.");
            }
            return(vault);
        }
Exemplo n.º 9
0
        public IActionResult Create([FromBody] Vault vault)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid vault"));
            }

            vault.UserId = HttpContext.User.Identity.Name;
            try {
                return(Ok(_repo.Create(vault)));
            } catch (Exception error) {
                return(BadRequest(error.Message));
            }
        }
Exemplo n.º 10
0
        public Vault Post([FromBody] Vault rawVault)
        {
            if (!ModelState.IsValid)
            {
                throw new Exception("Invalid Vault.");
            }
            rawVault.UserId = HttpContext.User.Identity.Name;
            Vault vault = _repo.Create(rawVault);

            if (vault == null)
            {
                throw new Exception("Error inserting Vault into the db.");
            }
            return(vault);
        }