SES-148 Endpointy dla Armor i Weapon #71
@ -1,33 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SessionCompanion.Services.Interfaces;
|
||||
using SessionCompanion.Extensions.EitherType;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using SessionCompanion.ViewModels.ApiResponses;
|
||||
|
||||
namespace SessionCompanion.Controllers
|
||||
{
|
||||
[Route("api/characterArmor")]
|
||||
[ApiController]
|
||||
public class CharacterArmorController : Controller
|
||||
{
|
||||
private ICharacterArmorService _service;
|
||||
public CharacterArmorController(ICharacterArmorService characterArmorService)
|
||||
{
|
||||
this._service = characterArmorService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metoda zmienia uzywany armor danej postaci
|
||||
/// </summary>
|
||||
/// <param name="characterId"></param>
|
||||
/// <param name="newArmorId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Either<ErrorResponse, SuccessResponse>> ChangeCharacterArmor(int characterId, int newArmorId)
|
||||
{
|
||||
return new ErrorResponse() { StatusCode = 1, Message = "asd" };
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace SessionCompanion.Controllers
|
||||
[ApiController]
|
||||
public class EquipmentController : Controller
|
||||
{
|
||||
private readonly ICharacterArmorService _characterArmorServic;
|
||||
private readonly ICharacterArmorService _characterArmorService;
|
||||
|
||||
private readonly ICharacterOtherEquipmentService _characterOtherEquipmentService;
|
||||
|
||||
@ -27,7 +27,7 @@ namespace SessionCompanion.Controllers
|
||||
ICharacterOtherEquipmentService characterOtherEquipmentService,
|
||||
ICharacterWeaponService characterWeaponService)
|
||||
{
|
||||
this._characterArmorServic = characterArmorService;
|
||||
this._characterArmorService = characterArmorService;
|
||||
this._characterOtherEquipmentService = characterOtherEquipmentService;
|
||||
this._characterWeaponService = characterWeaponService;
|
||||
}
|
||||
@ -51,7 +51,7 @@ namespace SessionCompanion.Controllers
|
||||
[HttpGet("getArmors")]
|
||||
public async Task<Either<List<CharacterArmorViewModelDetails>, ErrorResponse>> GetCharacterArmors(int characterId)
|
||||
{
|
||||
return await this._characterArmorServic.GetCharacterArmorsTaskList(characterId);
|
||||
return await this._characterArmorService.GetCharacterArmorsTaskList(characterId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -65,5 +65,37 @@ namespace SessionCompanion.Controllers
|
||||
return await this._characterWeaponService.GetCharacterWeaponsList(characterId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metoda zmienia uzywany armor danej postaci
|
||||
/// </summary>
|
||||
/// <param name="characterId"></param>
|
||||
s426135 marked this conversation as resolved
Outdated
|
||||
/// <param name="newArmorId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("changeArmor")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterArmor(int characterId, int newArmorId)
|
||||
{
|
||||
var response = await _characterArmorService.ChangeCharacterArmor(characterId, newArmorId);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metoda dodaje Armor do danej postaci
|
||||
/// </summary>
|
||||
/// <param name="characterArmorViewModel"></param>
|
||||
/// <returns></returns>
|
||||
s426135 marked this conversation as resolved
Outdated
s426134
commented
brak returna brak returna
|
||||
[HttpPut("addArmor")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterArmor(CharacterArmorViewModel characterArmorViewModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _characterArmorService.Create(characterArmorViewModel);
|
||||
await _characterArmorService.SaveAsync();
|
||||
return new SuccessResponse("Armor added to character") { SuccessCode = 200 };
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ErrorResponse() { StatusCode = 500, Message = e.Message };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user
opisy :D