Skip to content

Commit 84b9e88

Browse files
committed
Release Candidate 1
1 parent 1c877e2 commit 84b9e88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+56
-27440
lines changed

api/Controllers/GroupController.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,26 @@ public GroupController(GroupService groupService)
3333

3434
return groups;
3535
}
36+
37+
[HttpGet("{id:length(24)}", Name = "GetUserGroup")]
38+
public ActionResult<Models.Group> GetUserGroup(string id)
39+
{
40+
var group = _groupService.GetGroup(id);
41+
42+
if (group == null)
43+
{
44+
return NotFound();
45+
}
46+
47+
return group;
48+
}
49+
50+
[HttpPost]
51+
public ActionResult<Models.Group> Create(Models.Group group)
52+
{
53+
_groupService.Create(group);
54+
55+
return CreatedAtRoute("GetUserGroup", new { id = group.Id.ToString() }, group);
56+
}
3657
}
3758
}

api/Services/GroupService.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,17 @@ public GroupService(IBookstoreDatabaseSettings settings)
2323

2424
public List<Models.Group> Get(string id) =>
2525
_groups.Find<Group>(group => group.AzId == id).ToList();
26+
27+
public Models.Group GetGroup(string id) =>
28+
_groups.Find<Group>(group => group.Id == id).FirstOrDefault();
29+
30+
public Group Create(Models.Group group)
31+
{
32+
group.Id = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
33+
34+
_groups.InsertOne(group);
35+
36+
return group;
37+
}
2638
}
2739
}

bin/Debug/net5.0/Books.dll

1 KB
Binary file not shown.

bin/Debug/net5.0/Books.pdb

244 Bytes
Binary file not shown.

bin/Debug/net5.0/ref/Books.dll

512 Bytes
Binary file not shown.

client/src/components/Buttons.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
import * as React from 'react';
22
import { AuthService } from '../services/AuthService';
3+
import { Constants } from '../helpers/Constants';
34

45
interface IButtonsProps {
56
login: () => void;
67
getUser: () => void;
78
callApi: () => void;
89
renewToken: () => void;
910
logout: () => void;
11+
editProfile: () => void;
1012
}
1113

1214
const Buttons: React.SFC<IButtonsProps> = props => {
1315
let authService = new AuthService();
1416

15-
authService.isAuthenticated().then(function(data) {
17+
authService.isAuthenticated().then(function(isAuthenticated) {
1618
var logoutButton = document.getElementById('logoutButton');
1719
var loginButton = document.getElementById('loginButton');
20+
var editProfileButton = document.getElementById('editProfileButton');
1821

19-
if(data) {
20-
if(logoutButton != null && loginButton != null) {
22+
if(isAuthenticated) {
23+
if(logoutButton != null && loginButton != null && editProfileButton != null) {
2124
logoutButton.style.display = "inline";
25+
editProfileButton.style.display = "inline";
2226
loginButton.style.display = "none;";
2327
}
2428
} else {
25-
if(logoutButton != null && loginButton != null) {
29+
if(logoutButton != null && loginButton != null && editProfileButton != null) {
2630
logoutButton.style.display = "none";
31+
editProfileButton.style.display = "none";
2732
loginButton.style.display = "inline";
2833
}
2934
}
@@ -32,10 +37,14 @@ const Buttons: React.SFC<IButtonsProps> = props => {
3237
return (
3338
<div className="row">
3439
<div className="col-md-12 text-left" style={{ marginTop: '30px' }}>
35-
<button id="logoutButton" className="btn btn-dark btn-logout" style={{ margin: '10px', display:'none' }} onClick={props.logout}>
40+
<a id="editProfileButton" className="btn btn-primary" style={{ margin: '10px', display: 'none' }}
41+
href="https://mittbalans.b2clogin.com/MittBalans.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_react_edit&client_id=26df1c6a-8029-4b7b-b620-4c94866d3e23&nonce=defaultNonce&redirect_uri=http%3A%2F%2Flocalhost%3A48599%2F&scope=openid&response_type=id_token&prompt=login">
42+
My Profile
43+
</a>
44+
<button id="logoutButton" className="btn btn-dark btn-logout" style={{ margin: '10px', display: 'none' }} onClick={props.logout}>
3645
Logout
3746
</button>
38-
<button id="loginButton" className="btn btn-primary btn-login" style={{ margin: '10px', display:'none' }} onClick={props.login}>
47+
<button id="loginButton" className="btn btn-primary btn-login" style={{ margin: '10px', display: 'none' }} onClick={props.login}>
3948
Login/Register
4049
</button>
4150
</div>

client/src/components/TopContent.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export default class TopContent extends React.Component<any, any> {
3131
this.authService.login();
3232
};
3333

34+
public editProfile = () => {
35+
this.authService.editProfile();
36+
}
37+
3438
public callApi = () => {
3539
this.apiService
3640
.callApi()
@@ -95,6 +99,7 @@ export default class TopContent extends React.Component<any, any> {
9599
renewToken={this.renewToken}
96100
getUser={this.getUser}
97101
callApi={this.callApi}
102+
editProfile={this.editProfile}
98103
/>
99104

100105
{Constants.debug &&

client/src/services/AuthService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,7 @@ export class AuthService {
6262
public async isAuthenticated(): Promise<boolean> {
6363
return await this.getUser() != null;
6464
}
65+
66+
public editProfile(): void {
67+
}
6568
}

obj/Debug/net5.0/Books.dll

1 KB
Binary file not shown.

obj/Debug/net5.0/Books.pdb

244 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)