public ActionResult <VaultKeeps> Post([FromBody] VaultKeeps vaultKeep) { vaultKeep.UserId = HttpContext.User.Identity.Name; VaultKeeps result = _vkRepo.AddVaultKeeps(vaultKeep); return(Created("/api/vaultKeeps/" + result.Id, result)); }
public VaultKeeps Create(VaultKeeps newVaultKeeps) { int id = _vkr.Create(newVaultKeeps); newVaultKeeps.Id = id; return(newVaultKeeps); }
public string Delete(VaultKeeps vk, string userId) { if (vk == null || vk.UserId != userId) { throw new Exception("invalid Id"); } _vkr.Delete(vk); return("Success"); }
public VaultKeeps AddVK([FromBody] VaultKeeps newVK) { if (ModelState.IsValid) { var user = HttpContext.User; return(_db.AddVK(newVK)); } return(null); }
//SECTION REMOVE KEEPS FROM VAULTS //NOTE referenced petshop for delete. needs review public void RemoveKeepFromVault(VaultKeeps vk) { var success = _db.Execute("DELETE FROM vaultKeeps WHERE vaultId = @VaultId AND keepId = @KeepId AND userId = @UserId", vk); if (success != 1) { throw new Exception("Delete Request Failed."); } ; }
public VaultKeeps Create(VaultKeeps value) { string query = @" INSERT INTO vaultkeeps (vaultId, keepId, userId) VALUES(@VaultId, @KeepId, @UserId);"; int id = _db.ExecuteScalar <int>(query, value); value.Id = id; return(value); }
//SECTION ADD KEEPS TO VAULTKEEP (with an ID) public VaultKeeps AddKeepToVault(VaultKeeps vaultKeeps) { int id = _db.ExecuteScalar <int>(@" INSERT INTO vaultKeeps (vaultId, keepId, userId) VALUES (@VaultId, @KeepId, @UserId); SELECT LAST_INSERT_ID();", vaultKeeps); vaultKeeps.Id = id; return(vaultKeeps); }
public ActionResult <VaultKeeps> Create([FromBody] VaultKeeps vaultkeeps) { VaultKeeps newVaultKeeps = _vkr.CreateVaultKeeps(vaultkeeps); if (newVaultKeeps == null) { return(BadRequest("Something went wrong.")); } return(Ok(newVaultKeeps)); }
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 VaultKeeps AddToVault(VaultKeeps toAdd) { int Id = _db.ExecuteScalar <int>(@"INSERT INTO vaultkeeps (vaultId, keepId, userId) VALUES (@vaultId, @keepId, @userId); SELECT LAST_INSERT_ID(); ", toAdd); toAdd.id = Id; return(toAdd); }
public string DeleteVaultKeep(VaultKeeps value) { string query = @"DELETE FROM vaultkeeps WHERE vaultId = @VaultId AND keepId = @KeepId AND userId = @UserId;"; int rowsAffected = _db.Execute(query, value); if (rowsAffected < 1) { throw new Exception("Invalid Ids"); } return("Successfully Deleted VaultKeep"); }
public ActionResult <VaultKeeps> Delete([FromBody] VaultKeeps payload) { string userId = HttpContext.User.Identity.Name; payload.UserId = userId; if (_vkRepo.DeleteVaultKeeps(payload)) { return(Ok("success")); } return(NotFound("No Keep FOund")); }
//AddKeep vaultkeep public VaultKeeps AddVK(VaultKeeps newvk) { int id = _db.ExecuteScalar <int>(@" INSERT INTO vaultkeeps (vaultId, keepId, userId) VALUES (@vaultId, @keepId, @userId); SELECT LAST_INSERT_ID(); ", newvk); newvk.Id = id; return(newvk); }
//Delete/put request public string Delete(VaultKeeps value) { string query = "DELETE FROM vaultkeeps WHERE (vaultId = @VaultId AND keepId = @KeepId AND userId = @UserId)"; int changedRows = _db.Execute(query, value); if (changedRows < 1) { throw new Exception("Invalid Id"); } return("Successfully deleted"); }
// CREATE VAULTKEEP public VaultKeeps CreateVaultKeep(VaultKeeps newVaultKeep) { int id = _db.ExecuteScalar <int>(@" INSERT INTO vaultkeeps (vaultId, keepId, userId) VALUES (@VaultId,@KeepId,@UserId); SELECT LAST_INSERT_ID(); ", newVaultKeep); newVaultKeep.Id = id; return(newVaultKeep); }
public int Create(VaultKeeps newVaultKeeps) { string sql = @" INSERT INTO vaultKeeps (vaultId, keepId, userId) VALUES (@VaultId, @KeepId, @UserId); SELECT LAST_INSERT_ID(); "; return(_db.ExecuteScalar <int>(sql, newVaultKeeps)); //get the new id back from line 36 and return to service }
public ActionResult <VaultKeeps> Create([FromBody] VaultKeeps newVaultKeep) { try { newVaultKeep.UserId = HttpContext.User.FindFirstValue("Id"); return(Ok(_vks.Create(newVaultKeep))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <VaultKeeps> Delete([FromBody] VaultKeeps vaultKeep) { try { string userId = HttpContext.User.FindFirstValue("id"); return(Ok(_vks.Delete(vaultKeep, userId))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public VaultKeeps CreateVaultKeeps(VaultKeeps newVaultKeeps) //need to ask about this, should be (vaultkeep newVaultKeep) { int id = _db.ExecuteScalar <int>(@" INSERT INTO vaultkeeps (vaultId, keepId, userId) VALUES (@VaultId, @KeepId, @UserId); SELECT LAST_INSERT_ID(); ", newVaultKeeps); newVaultKeeps.Id = id; return(newVaultKeeps); }
public ActionResult <VaultKeeps> Post([FromBody] VaultKeeps value) { try { value.UserId = HttpContext.User.FindFirstValue("Id"); return(Ok(_repo.Create(value))); } catch (Exception e) { return(BadRequest(e)); } }
//AddKeep vaultkeep public VaultKeeps AddVK(VaultKeeps newvk) { // need to first run sql statement to check if keepId is already connected to the vaultId // this is to block adding same keeps to vault int id = _db.ExecuteScalar <int>(@" INSERT INTO vaultkeeps (vaultId, keepId, userId) VALUES (@vaultId, @keepId, @userId); SELECT LAST_INSERT_ID(); ", newvk); newvk.Id = id; return(newvk); }
public string Del(VaultKeeps value) { string query = @"DELETE FROM vaultkeeps WHERE (vaultId = @vaultId AND keepId = @keepId AND userId = @userId)"; int deleted = _db.Execute(query, value); if (deleted < 1) { throw new Exception("Invalid Request"); } return("Delete Complete"); }
public ActionResult <String> Put([FromBody] VaultKeeps value) { try { string userId = HttpContext.User.FindFirstValue("Id"); value.UserId = userId; return(Ok(_repo.Delete(value))); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult <string> Post([FromBody] VaultKeeps vk) { try { string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; vk.UserId = userId; return(Ok(_vks.Create(vk))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <VaultKeeps> AddKeepToVault([FromBody] VaultKeeps vaultKeeps) { try { vaultKeeps.UserId = HttpContext.User.FindFirstValue("Id"); //fixed in model return(Ok(_repository.AddKeepToVault(vaultKeeps))); } catch (Exception e) { return(BadRequest(e.Message)); // return BadRequest("Unable to add this Keep to this Vault."); //<---brooklyn change } }
public ActionResult <string> DeleteVaultKeep(int id, [FromBody] VaultKeeps value) { try { var uid = HttpContext.User.FindFirstValue("Id"); value.UserId = uid; value.Id = id; return(Ok(_repo.DeleteVaultKeep(value))); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult <String> AddKeepToVault(int id, [FromBody] VaultKeeps vaultKeeps) { try { var uid = HttpContext.User.FindFirstValue("Id"); vaultKeeps.UserId = uid; vaultKeeps.VaultId = id; return(Ok(_repo.AddKeepToVault(vaultKeeps))); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult <VaultKeeps> RemoveKeepFromVault([FromBody] VaultKeeps vk) //jake change to vk { try { // attach the your userId to vk here vk.UserId = HttpContext.User.FindFirstValue("Id"); _repository.RemoveKeepFromVault(vk); return(Ok("Keep successfully removed from Vault.")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult<string> Put([FromBody] VaultKeeps value) { try { var userId = HttpContext.User.FindFirstValue("Id"); value.UserId = userId; return Ok(_repo.Del(value)); } catch (Exception e) { return BadRequest(e.Message); } }
// Edit public VaultKeeps EditVaultKeep(int id, VaultKeeps VaultKeep) { VaultKeep.Id = id; var i = _db.Execute(@" UPDATE vaultkeeps SET vaultId = @VaultId, keepId = @KeepId WHERE id = @Id ", VaultKeep); if (i > 0) { return(VaultKeep); } return(null); }