SES-164 Add new constructors and change succesResponse
This commit is contained in:
parent
3466b54785
commit
ee05b0d381
@ -48,7 +48,7 @@ namespace SessionCompanion.Services.Services
|
|||||||
// just use new one
|
// just use new one
|
||||||
await Repository.Update(weapon);
|
await Repository.Update(weapon);
|
||||||
await Repository.Save();
|
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));
|
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.Update(weapon);
|
||||||
await Repository.Save();
|
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));
|
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(weaponToChange);
|
||||||
await Repository.Update(weapon);
|
await Repository.Update(weapon);
|
||||||
await Repository.Save();
|
await Repository.Save();
|
||||||
return new SuccessResponse("Weapon changed") { SuccessCode = 200 };
|
return new SuccessResponse("Weapon changed") { StatusCode = 200 };
|
||||||
}
|
}
|
||||||
|
|
||||||
// weapon is armed in empty hand
|
// weapon is armed in empty hand
|
||||||
await Repository.Update(weapon);
|
await Repository.Update(weapon);
|
||||||
await Repository.Save();
|
await Repository.Save();
|
||||||
return new SuccessResponse("Weapon changed") { SuccessCode = 200 };
|
return new SuccessResponse("Weapon changed") { StatusCode = 200 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,40 @@ namespace SessionCompanion.ViewModels.ApiResponses
|
|||||||
{
|
{
|
||||||
public class ErrorResponse
|
public class ErrorResponse
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Pusty konstruktor
|
||||||
|
/// </summary>
|
||||||
|
public ErrorResponse()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Konstruktor obiektu
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
public ErrorResponse(int code)
|
||||||
|
{
|
||||||
|
this.StatusCode = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Konstruktor obiektu
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
public ErrorResponse(string message)
|
||||||
|
{
|
||||||
|
this.Message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Konstruktor obiektu
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
public ErrorResponse(int code, string message)
|
||||||
|
{
|
||||||
|
this.StatusCode = code;
|
||||||
|
this.Message = message;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kod błędu
|
/// Kod błędu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -5,24 +5,50 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SuccessResponse
|
public class SuccessResponse
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Pusty konstruktor obiektu
|
||||||
|
/// </summary>
|
||||||
|
public SuccessResponse()
|
||||||
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Konstruktor obiektu
|
/// Konstruktor obiektu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message"> Wiadomość dotycząca operacji </param>
|
/// <param name="message"> Wiadomość dotycząca operacji </param>
|
||||||
public SuccessResponse(string message)
|
public SuccessResponse(string message)
|
||||||
{
|
{
|
||||||
this.SuccessCode = 200;
|
this.StatusCode = 200;
|
||||||
this.SuccessMessage = message;
|
this.Message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Konstruktor obiektu
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
public SuccessResponse(int code)
|
||||||
|
{
|
||||||
|
this.StatusCode = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Konstruktor obiektu
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
public SuccessResponse(int code, string message)
|
||||||
|
{
|
||||||
|
this.StatusCode = code;
|
||||||
|
this.Message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kod odpowiedzi, domyślnie nadawany jest 200
|
/// Kod odpowiedzi, domyślnie nadawany jest 200
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int SuccessCode { get; set; }
|
public int StatusCode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wiadomość dotycząca wykoanania operacji
|
/// Wiadomość dotycząca wykoanania operacji
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SuccessMessage { get; set; }
|
public string Message { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user