diff options
author | Ognjen Cirkovic <ciraboxkg@gmail.com> | 2022-05-19 23:11:33 +0200 |
---|---|---|
committer | Ognjen Cirkovic <ciraboxkg@gmail.com> | 2022-05-19 23:11:33 +0200 |
commit | 865552b098c1448975bb17357df5195799de18ff (patch) | |
tree | 43faa0d2a46f4e3409ee89e1fbe0f47a084a8f34 | |
parent | 8c9061ab07039665d1c7bc4a7a27fb9b9c76e742 (diff) | |
parent | 518943953e2bc182297647a29bc3a2ea65cc5ed0 (diff) |
Merge branch 'redesign' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into Redesign
-rw-r--r-- | backend/api/api/Controllers/UserController.cs | 11 | ||||
-rw-r--r-- | frontend/src/app/_pages/profile/profile.component.ts | 16 |
2 files changed, 20 insertions, 7 deletions
diff --git a/backend/api/api/Controllers/UserController.cs b/backend/api/api/Controllers/UserController.cs index 9f736679..9796afc2 100644 --- a/backend/api/api/Controllers/UserController.cs +++ b/backend/api/api/Controllers/UserController.cs @@ -125,7 +125,16 @@ namespace api.Controllers if (username == null) return BadRequest(); - return Ok(userService.Update(username, user)); + if (user.Username != username) + { + User user2 = userService.GetUserByUsername(user.Username); + if (user2 == null) + return Ok(userService.Update(username, user)); + else + return BadRequest("Username already exists!"); + } + else + return Ok(userService.Update(username, user)); } // DELETE api/<UserController>/5 diff --git a/frontend/src/app/_pages/profile/profile.component.ts b/frontend/src/app/_pages/profile/profile.component.ts index fdcd347c..3c81883e 100644 --- a/frontend/src/app/_pages/profile/profile.component.ts +++ b/frontend/src/app/_pages/profile/profile.component.ts @@ -7,7 +7,8 @@ import { PICTURES } from 'src/app/_data/ProfilePictures'; import { Picture } from 'src/app/_data/ProfilePictures'; import shared from '../../Shared'; import { share } from 'rxjs'; - +import { MatDialog } from '@angular/material/dialog'; +import { AlertDialogComponent } from 'src/app/_modals/alert-dialog/alert-dialog.component'; @Component({ selector: 'app-profile', @@ -49,7 +50,7 @@ export class ProfileComponent implements OnInit { pattPassword: RegExp = /.{6,30}$/; - constructor(private userInfoService: UserInfoService, private authService: AuthService, private router: Router) { } + constructor(private userInfoService: UserInfoService, private authService: AuthService, private router: Router, public dialog?: MatDialog) { } ngOnInit(): void { this.userInfoService.getUserInfo().subscribe((response) => { @@ -105,10 +106,13 @@ export class ProfileComponent implements OnInit { this.resetInfo(); }, (error: any) =>{ if (error.error == "Username already exists!") { - shared.openDialog("Obaveštenje", "Ukucano korisničko ime je već zauzeto! Izaberite neko drugo."); - //(<HTMLSelectElement>document.getElementById("inputUsername")).focus(); - //poruka obavestenja ispod inputa - this.resetInfo(); + const dialogRef = this.dialog?.open(AlertDialogComponent, { + width: '350px', + data: { title: "Obaveštenje", message: "Ukucano korisničko ime je već zauzeto! Izaberite neko drugo." } + }); + dialogRef?.afterClosed().subscribe(res => { + this.resetInfo(); + }); } }); } |