public Vault Post([FromBody] Vault vault) { if (ModelState.IsValid) { return(_repo.Create(vault)); } throw new Exception("invalid vault"); }
public Vault Post([FromBody] Vault vault) { if (ModelState.IsValid) { vault.UserId = HttpContext.User.Identity.Name; return(_repo.Create(vault)); } throw new Exception("INVALID VAULT"); }
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"); }
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"); }
// [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"); }
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)); } }
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)); } }
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); }
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)); } }
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); }