// internal VaultKeepViewModel Create(VaultKeepViewModel newVaultKeep) // { // int id = _repo.Create(newVaultKeep); // newVaultKeep.Id = id; // return newVaultKeep; // } // internal DTOVaultKeep Delete(int id) // { // DTOVaultKeep exists = (DTOVaultKeep)GetById(id); // _repo.Delete(id); // return exists; // } internal DTOVaultKeep Delete(int id, string userId) { DTOVaultKeep exists = GetById(id); _repo.Delete(id, userId); return(exists); }
internal DTOVaultKeep Delete(int id) { DTOVaultKeep exists = Get(id); _repo.Delete(id); return(exists); }
public DTOVaultKeep Delete(string userId, int id) { DTOVaultKeep exists = GetById(id); _repo.Delete(id, userId); return(exists); }
internal bool hasRelationship(DTOVaultKeep newVaultKeep) { string sql = "SELECT * FROM vaultkeeps WHERE vaultId = @VaultId AND keepId = @KeepId"; var found = _db.QueryFirstOrDefault <DTOVaultKeep>(sql, newVaultKeep); return(found != null); }
internal DTOVaultKeep Create(DTOVaultKeep newVaultKeep) { int id = _repo.Create(newVaultKeep); newVaultKeep.Id = id; return(newVaultKeep); }
internal DTOVaultKeep Delete(int keepid, int vaultid) { DTOVaultKeep exists = Get(keepid, vaultid); _repo.Delete(exists.Id); return(exists); }
public DTOVaultKeep Create(DTOVaultKeep newVaultKeep) { if (_repo.hasRelationship(newVaultKeep)) { throw new Exception("This Keep already exists in this vault!"); } return(_repo.Create(newVaultKeep)); }
// public DTOVaultKeep Get(int Id) // { // DTOVaultKeep exists = _repo.GetById(Id); // if (exists == null) // { // throw new Exception("Invalid vaultkeep"); // } // return exists; // } public DTOVaultKeep Create(DTOVaultKeep newVaultKeep) { // if (_repo.hasRelationship(newVaultKeep)) // { // throw new Exception("That's already in your vault"); // } return(_repo.Create(newVaultKeep)); }
internal DTOVaultKeep Create(DTOVaultKeep newVaultKeep) { if (_repo.hasRelationship(newVaultKeep)) { throw new Exception("That Keep is Already in that Vault"); } return(_repo.Create(newVaultKeep)); }
private DTOVaultKeep Get(int keepid, int vaultid) { DTOVaultKeep exists = _repo.GetById(keepid, vaultid); if (exists == null) { throw new Exception("Invalid Vault Id"); } return(exists); }
internal DTOVaultKeep GetById(int id) //TODO call in a different controller than VKC { DTOVaultKeep exists = _repo.GetById(id); if (exists == null) { throw new Exception("ur wrong bub"); } return(exists); }
public DTOVaultKeep Get(int Id) { DTOVaultKeep exists = _repo.GetById(Id); if (exists == null) { throw new Exception("Invalid Vault Keep"); } return(exists); }
public DTOVaultKeep Delete(int id, string userId) { DTOVaultKeep exists = Get(id); if (exists.UserId != userId) { throw new Exception("This is not your VaultKeep!"); } _repo.Delete(id); return(exists); }
// internal IEnumerable<VaultKeepViewModel> GetByUser() // { // string sql = @" // SELECT // k.*, // vk.id as vaultKeepId // FROM vaultkeeps vk // INNER JOIN vaults v ON v.id = vk.vaultId // WHERE userId = @UserId;"; // return _db.Query<VaultKeepViewModel>(sql); // } internal int Create(DTOVaultKeep newDTOVaultKeep) { string sql = @" INSERT INTO vaultkeeps (vaultId, keepId, userId) VALUES (@VaultId, @KeepId, @UserId); SELECT LAST_INSERT_ID();"; return(_db.ExecuteScalar <int>(sql, newDTOVaultKeep)); }
public ActionResult <DTOVaultKeep> Create([FromBody] DTOVaultKeep newVaultKeep) { try { newVaultKeep.UserId = findUserInfo(); return(Ok(_vks.Create(newVaultKeep))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
public ActionResult <DTOVaultKeep> Post([FromBody] DTOVaultKeep newDTOVaultKeep) { try { string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; return(Ok(_vks.Create(newDTOVaultKeep))); } catch (Exception e) { return(BadRequest(e.Message)); } }
internal DTOVaultKeep Create(DTOVaultKeep newVaultKeep) { string sql = @" INSERT INTO vaultkeeps (keepId, userId, vaultId) VALUES (@KeepId, @UserId, @VaultId); SELECT LAST_INSERT_ID();"; newVaultKeep.Id = _db.ExecuteScalar <int>(sql, newVaultKeep); return(newVaultKeep); }
[Authorize] //could throw it at top level i guess public ActionResult <DTOVaultKeep> Post([FromBody] DTOVaultKeep newDTOVaultKeep) { try { // var claim = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier); // if(claim != null){ // newDTOVaultKeep.UserId = claim.Value; // } this broke it lol string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; newDTOVaultKeep.UserId = userId; return(Ok(_vks.Create(newDTOVaultKeep))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public DTOVaultKeep Create(DTOVaultKeep newDTOVaultKeep) { return(_repo.Create(newDTOVaultKeep)); }
internal DTOVaultKeep Create(DTOVaultKeep newVault) { return(_repo.Create(newVault)); }