diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..8de36d7
Binary files /dev/null and b/.DS_Store differ
diff --git a/keepr.client/src/assets/img/404.svg b/keepr.client/src/assets/img/404.svg
new file mode 100644
index 0000000..df46b65
--- /dev/null
+++ b/keepr.client/src/assets/img/404.svg
@@ -0,0 +1,2185 @@
+
+
+
+
diff --git a/keepr.client/src/components/Attribution.vue b/keepr.client/src/components/Attribution.vue
new file mode 100644
index 0000000..206a28b
--- /dev/null
+++ b/keepr.client/src/components/Attribution.vue
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/keepr/Controllers/KeepsController.cs b/keepr/Controllers/KeepsController.cs
new file mode 100644
index 0000000..99d5ed6
--- /dev/null
+++ b/keepr/Controllers/KeepsController.cs
@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+using keepr.Models;
+using keepr.Services;
+using Microsoft.AspNetCore.Mvc;
+using CodeWorks.Auth0Provider;
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+
+namespace keepr.Controllers
+{
+ [ApiController]
+ [Route("api/[controller]")]
+ public class KeepsController : ControllerBase
+ {
+ private readonly KeepsService _ks;
+ public KeepsController(KeepsService ks)
+ {
+ _ks = ks;
+ }
+
+ [HttpPost]
+ [Authorize]
+ public async Task> Create([FromBody] Keep keep)
+ {
+ try
+ {
+ Account userInfo = await HttpContext.GetUserInfoAsync();
+ keep.CreatorId = userInfo.Id;
+ Keep newKeep = _ks.Create(keep);
+ return Ok(newKeep);
+ }
+ catch (System.Exception e)
+ {
+ return BadRequest(e.Message);
+ }
+ }
+
+ [HttpGet]
+ public ActionResult> GetAll()
+ {
+ try
+ {
+ List keeps = _ks.GetAll();
+ return Ok(keeps);
+ }
+ catch (System.Exception e)
+ {
+ return BadRequest(e.Message);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Controllers/ProfilesController.cs b/keepr/Controllers/ProfilesController.cs
new file mode 100644
index 0000000..39f72b7
--- /dev/null
+++ b/keepr/Controllers/ProfilesController.cs
@@ -0,0 +1,67 @@
+using System.Collections.Generic;
+using keepr.Models;
+using keepr.Services;
+using Microsoft.AspNetCore.Mvc;
+
+namespace keepr.Controllers
+{
+ // Establish endpoint path
+ [ApiController]
+ [Route("api/[controller]")]
+ public class ProfilesController : ControllerBase
+ {
+ // 'Instantiate' ProfilesService
+ private readonly ProfilesService _ps;
+ private readonly KeepsService _ks;
+ private readonly VaultsService _vs;
+ public ProfilesController(ProfilesService ps, KeepsService ks, VaultsService vs)
+ {
+ _ps = ps;
+ _ks = ks;
+ _vs = vs;
+ }
+
+ // Get Profile by Id endpoint
+ [HttpGet("{id}")]
+ public ActionResult Get(string id)
+ {
+ try
+ {
+ Profile profile = _ps.Get(id);
+ return Ok(profile);
+ }
+ catch (System.Exception e)
+ {
+ return BadRequest(e.Message);
+ }
+ }
+
+ [HttpGet("{id}/keeps")]
+ public ActionResult> GetKeeps(string id)
+ {
+ try
+ {
+ List keeps = _ks.GetProfileKeeps(id);
+ return Ok(keeps);
+ }
+ catch (System.Exception e)
+ {
+ return BadRequest(e.Message);
+ }
+ }
+
+ [HttpGet("{id}/vaults")]
+ public ActionResult> GetProfileVaults(string id)
+ {
+ try
+ {
+ List vaults = _vs.GetProfileVaults(id);
+ return Ok(vaults);
+ }
+ catch (System.Exception e)
+ {
+ return BadRequest(e.Message);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Models/Keep.cs b/keepr/Models/Keep.cs
index edfc603..11ce9e2 100644
--- a/keepr/Models/Keep.cs
+++ b/keepr/Models/Keep.cs
@@ -7,17 +7,21 @@ namespace keepr.Models
public class Keep
{
public int Id { get; set; }
- public string creatorId { get; set; }
+ public string CreatorId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Img { get; set; }
public int Views { get; set; }
public int Kept { get; set; }
+ public Profile Creator { get; set; }
// populate creator?
// shares int - stretch goal
}
- public class
+ // public class KeepVaultViewModel : Keep
+ // {
+ // public int MyProperty { get; set; }
+ // }
}
\ No newline at end of file
diff --git a/keepr/Models/Vault.cs b/keepr/Models/Vault.cs
index 76a59c3..0d62f49 100644
--- a/keepr/Models/Vault.cs
+++ b/keepr/Models/Vault.cs
@@ -10,6 +10,13 @@ namespace keepr.Models
public string Name { get; set; }
public string Description { get; set; }
public bool IsPrivate { get; set; }
-
+
+ public Account Creator { get; set; }
+
+ }
+
+ public class VaultKeepViewModel : Vault
+ {
+ public Keep VaultKeep { get; set; }
}
}
\ No newline at end of file
diff --git a/keepr/Repositories/KeepsRepository.cs b/keepr/Repositories/KeepsRepository.cs
new file mode 100644
index 0000000..da5e76d
--- /dev/null
+++ b/keepr/Repositories/KeepsRepository.cs
@@ -0,0 +1,67 @@
+using keepr.Controllers;
+using keepr.Models;
+using keepr.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using keepr.Services;
+using CodeWorks.Auth0Provider;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Dapper;
+using System.Data;
+using System.Linq;
+
+
+namespace keepr.Repositories
+{
+ public class KeepsRepository
+ {
+ // Connect to Dapper
+ private readonly IDbConnection _db;
+ public KeepsRepository(IDbConnection db)
+ {
+ _db = db;
+ }
+
+ public List GetProfileKeeps(string id)
+ {
+ string sql = @"
+ SELECT *
+ FROM keeps
+ WHERE creatorId = @id;
+ ";
+ return _db.Query(sql, new {id}).ToList();
+ }
+
+ public Keep Create(Keep keep)
+ {
+ string sql = @"
+ INSERT INTO keeps
+ (creatorId, name, description, img)
+ VALUES
+ (@CreatorId, @Name, @Description, @Img);
+ SELECT LAST_INSERT_ID();
+ ";
+ keep.Id = _db.ExecuteScalar(sql, keep);
+ return keep;
+ }
+
+ public List GetAll()
+ {
+ string sql = @"
+ SELECT
+ a.*,
+ k.*
+ FROM keeps k
+ JOIN accounts a
+ ON a.id = k.creatorId;
+ ";
+ return _db.Query(sql, (prof, keep) =>
+ {
+ keep.Creator = prof;
+ return keep;
+ }).ToList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Repositories/ProfilesRepository.cs b/keepr/Repositories/ProfilesRepository.cs
new file mode 100644
index 0000000..22bc38c
--- /dev/null
+++ b/keepr/Repositories/ProfilesRepository.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using keepr.Models;
+using keepr.Services;
+using keepr.Repositories;
+using CodeWorks.Auth0Provider;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Dapper;
+using System.Data;
+
+namespace keepr.Repositories
+{
+ public class ProfilesRepository
+ {
+ // Connect to Dapper
+ private readonly IDbConnection _db;
+ public ProfilesRepository(IDbConnection db)
+ {
+ _db = db;
+ }
+
+ public Profile Get(string id)
+ {
+ string sql = @"
+ SELECT *
+ FROM accounts
+ WHERE id = @id;";
+ return _db.QueryFirstOrDefault(sql, new {id});
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Repositories/VaultsRepository.cs b/keepr/Repositories/VaultsRepository.cs
new file mode 100644
index 0000000..b2a47f3
--- /dev/null
+++ b/keepr/Repositories/VaultsRepository.cs
@@ -0,0 +1,35 @@
+using keepr.Controllers;
+using keepr.Models;
+using keepr.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using keepr.Services;
+using CodeWorks.Auth0Provider;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Dapper;
+using System.Data;
+using System.Linq;
+
+namespace keepr.Repositories
+{
+ public class VaultsRepository
+ {
+ private readonly IDbConnection _db;
+ public VaultsRepository(IDbConnection db)
+ {
+ _db = db;
+ }
+
+ internal List GetProfileVaults(string id)
+ {
+ string sql = @"
+ SELECT *
+ FROM vaults
+ WHERE creatorId = @id
+ AND isPrivate = 0;";
+ return _db.Query(sql, new {id}).ToList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Services/KeepsService.cs b/keepr/Services/KeepsService.cs
new file mode 100644
index 0000000..fbcf39b
--- /dev/null
+++ b/keepr/Services/KeepsService.cs
@@ -0,0 +1,39 @@
+using keepr.Controllers;
+using keepr.Models;
+using keepr.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using keepr.Services;
+using CodeWorks.Auth0Provider;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace keepr.Services
+{
+ public class KeepsService
+ {
+ private readonly KeepsRepository _repo;
+ public KeepsService(KeepsRepository repo)
+ {
+ _repo = repo;
+ }
+
+ internal List GetProfileKeeps(string id)
+ {
+ return _repo.GetProfileKeeps(id);
+ }
+
+ internal Keep Create(Keep keep)
+ {
+ Keep newKeep = _repo.Create(keep);
+ return newKeep;
+ }
+
+ internal List GetAll()
+ {
+ List keeps = _repo.GetAll();
+ return keeps;
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Services/ProfilesService.cs b/keepr/Services/ProfilesService.cs
new file mode 100644
index 0000000..9c7e2bf
--- /dev/null
+++ b/keepr/Services/ProfilesService.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using keepr.Models;
+using keepr.Services;
+using keepr.Repositories;
+using CodeWorks.Auth0Provider;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace keepr.Services
+{
+ public class ProfilesService
+ {
+ // 'Instantiate' ProfilesRepository
+ private readonly ProfilesRepository _repo;
+ public ProfilesService(ProfilesRepository repo)
+ {
+ _repo = repo;
+ }
+
+ public Profile Get(string id)
+ {
+ Profile foundProfile = _repo.Get(id);
+ if (foundProfile == null)
+ {
+ throw new Exception("Profile not found");
+ }
+ return foundProfile;
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Services/VaultsService.cs b/keepr/Services/VaultsService.cs
new file mode 100644
index 0000000..245b48d
--- /dev/null
+++ b/keepr/Services/VaultsService.cs
@@ -0,0 +1,27 @@
+using keepr.Controllers;
+using keepr.Models;
+using keepr.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using keepr.Services;
+using CodeWorks.Auth0Provider;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace keepr.Services
+{
+ public class VaultsService
+ {
+ private readonly VaultsRepository _repo;
+ public VaultsService(VaultsRepository repo)
+ {
+ _repo = repo;
+ }
+
+ internal List GetProfileVaults(string id)
+ {
+ return _repo.GetProfileVaults(id);
+ }
+ }
+}
\ No newline at end of file
diff --git a/keepr/Startup.cs b/keepr/Startup.cs
index 9fdd0fa..45ed984 100644
--- a/keepr/Startup.cs
+++ b/keepr/Startup.cs
@@ -42,6 +42,15 @@ namespace keepr
services.AddScoped();
services.AddScoped();
+
+ services.AddScoped();
+ services.AddScoped();
+
+ services.AddScoped();
+ services.AddScoped();
+
+ services.AddScoped();
+ services.AddScoped();
}
private void ConfigureCors(IServiceCollection services)
diff --git a/keepr/appsettings.json b/keepr/appsettings.json
index 7a9c965..00894e0 100644
--- a/keepr/appsettings.json
+++ b/keepr/appsettings.json
@@ -1,5 +1,5 @@
{
- "CONNECTION_STRING": "server=SG-Azula-6401-mysql-master.servers.mongodirector.com;port=3306;database=keepr;user id=keepr;password=sPZ6wy4nbfHj!NE;",
+ "CONNECTION_STRING": "server=SG-Azula-6401-mysql-master.servers.mongodirector.com;port=3306;database=keepr;user id=keepr;password=PWMsucks123!;",
"AUTH0_DOMAIN": "dev-h9kk6tgd.us.auth0.com",
"AUTH0_AUDIENCE": "https://AnniDev.com"
}
diff --git a/keepr/dbSetup.sql b/keepr/dbSetup.sql
index 7505353..1cd3a26 100644
--- a/keepr/dbSetup.sql
+++ b/keepr/dbSetup.sql
@@ -6,3 +6,40 @@ CREATE TABLE IF NOT EXISTS accounts(
email varchar(255) COMMENT 'User Email',
picture varchar(255) COMMENT 'User Picture'
) default charset utf8 COMMENT '';
+
+SELECT * FROM keepr.accounts;
+
+CREATE TABLE IF NOT EXISTS vaultKeeps(
+ id INT NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'primary key',
+ creatorId VARCHAR(255) NOT NULL COMMENT 'id of vault creator',
+ vaultId INT NOT NULL COMMENT 'ID of vault this keep is in',
+ keepId INT NOT NULL COMMENT 'ID of keep'
+) default charset utf8;
+
+CREATE TABLE IF NOT EXISTS vaults(
+ id INT NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'primary key',
+ creatorId VARCHAR(255) NOT NULL COMMENT 'id of vault creator',
+ name VARCHAR(255) NOT NULL COMMENT 'name of vault',
+ description VARCHAR(255) COMMENT 'description of vault'
+ idPrivate TINYINT DEFAULT 0 COMMENT 'flag for if vault is private'
+) default charset utf8;
+
+CREATE TABLE IF NOT EXISTS keeps(
+ id INT NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'primary key',
+ creatorId VARCHAR(255) NOT NULL COMMENT 'id of keep creator',
+ name VARCHAR(255) NOT NULL COMMENT 'name of keep',
+ description VARCHAR(255) COMMENT 'description of keep',
+ img VARCHAR(255) DEFAULT 'assets/img/404.svg' COMMENT 'URL of image',
+ views INT DEFAULT 0 COMMENT 'Number of views',
+ kept INT DEFAULT 0 COMMENT 'Number of times added to a vault'
+) default charset utf8;
+
+
+ SELECT *
+ FROM accounts
+ WHERE id = '62df16f445a8ad25b2c9485c';
+
+ SELECT *
+ FROM vaults
+ WHERE creatorId = '62df16f445a8ad25b2c9485c'
+ AND isPrivate = 0;
\ No newline at end of file