diff --git a/SessionCompanion/SessionCompanion.Services/Services/CharacterArmorService.cs b/SessionCompanion/SessionCompanion.Services/Services/CharacterArmorService.cs index 9413e2f..d2d0c2d 100644 --- a/SessionCompanion/SessionCompanion.Services/Services/CharacterArmorService.cs +++ b/SessionCompanion/SessionCompanion.Services/Services/CharacterArmorService.cs @@ -50,7 +50,7 @@ namespace SessionCompanion.Services.Services { await Repository.Update(armorToUse); await Repository.Save(); - return new SuccessResponse("Character armor updated") { SuccessCode = 200 }; + return new SuccessResponse("Character armor updated") { StatusCode = 200 }; } catch (Exception e) { @@ -65,7 +65,7 @@ namespace SessionCompanion.Services.Services await Repository.Update(armorInUse); await Repository.Update(armorToUse); await Repository.Save(); - return new SuccessResponse("Character armor updated") { SuccessCode = 204 }; + return new SuccessResponse("Character armor updated") { StatusCode = 204 }; } catch (Exception e) { diff --git a/SessionCompanion/SessionCompanion.Services/Services/CharacterWeaponService.cs b/SessionCompanion/SessionCompanion.Services/Services/CharacterWeaponService.cs index e003791..00129f4 100644 --- a/SessionCompanion/SessionCompanion.Services/Services/CharacterWeaponService.cs +++ b/SessionCompanion/SessionCompanion.Services/Services/CharacterWeaponService.cs @@ -48,7 +48,7 @@ namespace SessionCompanion.Services.Services // just use new one await Repository.Update(weapon); await Repository.Save(); - return new SuccessResponse("Weapon changed") { SuccessCode = 200 }; + return new SuccessResponse("Weapon changed") { StatusCode = 200 }; } var weaponInBothHands = weaponsInUse.Where(w => w.HoldInLeftHand.Equals(true) && w.HoldInRightHand.Equals(true)); @@ -67,7 +67,7 @@ namespace SessionCompanion.Services.Services await Repository.Update(weapon); await Repository.Save(); - return new SuccessResponse("Weapon changed") { SuccessCode = 200 }; + return new SuccessResponse("Weapon changed") { StatusCode = 200 }; } var weaponsToChange = weaponsInUse.Where(w => w.HoldInLeftHand.Equals(model.HoldInLeftHand) && w.HoldInRightHand.Equals(model.HoldInRightHand)); @@ -82,13 +82,13 @@ namespace SessionCompanion.Services.Services await Repository.Update(weaponToChange); await Repository.Update(weapon); await Repository.Save(); - return new SuccessResponse("Weapon changed") { SuccessCode = 200 }; + return new SuccessResponse("Weapon changed") { StatusCode = 200 }; } // weapon is armed in empty hand await Repository.Update(weapon); await Repository.Save(); - return new SuccessResponse("Weapon changed") { SuccessCode = 200 }; + return new SuccessResponse("Weapon changed") { StatusCode = 200 }; } } } diff --git a/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/ErrorResponse.cs b/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/ErrorResponse.cs index 262dd62..7ac5adc 100644 --- a/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/ErrorResponse.cs +++ b/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/ErrorResponse.cs @@ -4,6 +4,40 @@ namespace SessionCompanion.ViewModels.ApiResponses { public class ErrorResponse { + /// + /// Pusty konstruktor + /// + public ErrorResponse() + { } + + /// + /// Konstruktor obiektu + /// + /// + public ErrorResponse(int code) + { + this.StatusCode = code; + } + + /// + /// Konstruktor obiektu + /// + /// + public ErrorResponse(string message) + { + this.Message = message; + } + + /// + /// Konstruktor obiektu + /// + /// + /// + public ErrorResponse(int code, string message) + { + this.StatusCode = code; + this.Message = message; + } /// /// Kod błędu /// diff --git a/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/SuccessResponse.cs b/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/SuccessResponse.cs index 4cefb98..882b204 100644 --- a/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/SuccessResponse.cs +++ b/SessionCompanion/SessionCompanion.ViewModels/ApiResponses/SuccessResponse.cs @@ -5,24 +5,50 @@ /// public class SuccessResponse { + /// + /// Pusty konstruktor obiektu + /// + public SuccessResponse() + { } + /// /// Konstruktor obiektu /// /// Wiadomość dotycząca operacji public SuccessResponse(string message) { - this.SuccessCode = 200; - this.SuccessMessage = message; + this.StatusCode = 200; + this.Message = message; + } + + /// + /// Konstruktor obiektu + /// + /// + public SuccessResponse(int code) + { + this.StatusCode = code; + } + + /// + /// Konstruktor obiektu + /// + /// + /// + public SuccessResponse(int code, string message) + { + this.StatusCode = code; + this.Message = message; } /// /// Kod odpowiedzi, domyślnie nadawany jest 200 /// - public int SuccessCode { get; set; } + public int StatusCode { get; set; } /// /// Wiadomość dotycząca wykoanania operacji /// - public string SuccessMessage { get; set; } + public string Message { get; set; } } } diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/types/SuccessResponse.ts b/SessionCompanion/SessionCompanion/ClientApp/src/types/SuccessResponse.ts index 2ac62c3..3e0f2cf 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/types/SuccessResponse.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/types/SuccessResponse.ts @@ -1,4 +1,4 @@ export interface SuccessResponse { - code: number; + statusCode: number; message: string; } diff --git a/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs b/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs index d15c584..1b03b8b 100644 --- a/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs +++ b/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs @@ -147,7 +147,7 @@ namespace SessionCompanion.Controllers try { await _service.CreateCharactersFromTemplate(characterId, userId, newName); - return new SuccessResponse("Character created") { SuccessCode = 200 }; + return new SuccessResponse("Character created") { StatusCode = 200 }; } catch (Exception e) { diff --git a/SessionCompanion/SessionCompanion/Controllers/EquipmentController.cs b/SessionCompanion/SessionCompanion/Controllers/EquipmentController.cs index c160ec3..45bb4ce 100644 --- a/SessionCompanion/SessionCompanion/Controllers/EquipmentController.cs +++ b/SessionCompanion/SessionCompanion/Controllers/EquipmentController.cs @@ -93,7 +93,7 @@ namespace SessionCompanion.Controllers { await _characterArmorService.Create(characterArmorViewModel); await _characterArmorService.SaveAsync(); - return new SuccessResponse("Armor added to character") { SuccessCode = 200 }; + return new SuccessResponse("Armor added to character") { StatusCode = 200 }; } catch (Exception e) { @@ -115,7 +115,7 @@ namespace SessionCompanion.Controllers { await _characterWeaponService.Create(characterWeaponViewModel); await _characterWeaponService.SaveAsync(); - return new SuccessResponse("Weapon added to character") { SuccessCode = 200 }; + return new SuccessResponse("Weapon added to character") { StatusCode = 200 }; } catch (Exception e) {