diff --git a/Client/src/app/components/members/member-edit/member-edit.component.ts b/Client/src/app/components/members/member-edit/member-edit.component.ts index 05e69c1..f407206 100644 --- a/Client/src/app/components/members/member-edit/member-edit.component.ts +++ b/Client/src/app/components/members/member-edit/member-edit.component.ts @@ -3,6 +3,8 @@ import { ActivatedRoute } from '@angular/router'; import { User } from 'src/app/models/user'; import { AlertifyService } from 'src/app/services/alertify.service'; import { NgForm } from '@angular/forms'; +import { UserService } from 'src/app/services/user.service'; +import { AuthService } from 'src/app/services/auth.service'; @Component({ selector: 'app-member-edit', @@ -20,7 +22,12 @@ export class MemberEditComponent implements OnInit { user: User; - constructor(private route: ActivatedRoute, private alertify: AlertifyService) { } + constructor( + private route: ActivatedRoute, + private alertify: AlertifyService, + private userService: UserService, + private authService: AuthService + ) { } ngOnInit() { this.route.data.subscribe(data => { @@ -29,7 +36,14 @@ export class MemberEditComponent implements OnInit { } updateUser() { - this.alertify.success("Changes were saved"); - this.editForm.reset(this.user); + const userId = this.authService.decodedToken.nameid; + this.userService.updateUser(+userId, this.user) + .subscribe(next => { + this.alertify.success("Changes were saved"); + this.editForm.reset(this.user); + }, error => { + this.alertify.error(error); + }); + } } diff --git a/Client/src/app/services/user.service.ts b/Client/src/app/services/user.service.ts index 9feecce..fb840ed 100644 --- a/Client/src/app/services/user.service.ts +++ b/Client/src/app/services/user.service.ts @@ -19,4 +19,8 @@ export class UserService { getUser(id): Observable { return this.http.get(`${this.usersUrl}${id}`); } + + updateUser(id: number, user: User) { + return this.http.put(`${this.usersUrl}${id}`, user); + } } diff --git a/Helpers/CloudSettings.cs b/Helpers/CloudSettings.cs new file mode 100644 index 0000000..e7f49c6 --- /dev/null +++ b/Helpers/CloudSettings.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Friendster.Helpers +{ + public class CloudSettings + { + public string CloudName { get; set; } + public string ApiKey { get; set; } + public string ApiSecret { get; set; } + } +} diff --git a/Startup.cs b/Startup.cs index 97435b7..7e03a89 100644 --- a/Startup.cs +++ b/Startup.cs @@ -36,6 +36,7 @@ public void ConfigureServices(IServiceCollection services) services.AddTransient(); + services.Configure(Configuration.GetSection("CloudSettings")); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/appsettings.json b/appsettings.json index f50db6e..d9b95d0 100644 --- a/appsettings.json +++ b/appsettings.json @@ -10,5 +10,10 @@ "Default": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "CloudSettings": { + "CloudName": "dxtg2ci0b", + "ApiKey": "881683384793647", + "ApiSecret": "G_N5n6ZKQfJyzSMcXIfOf6wwNMA" + } }