SES-148 CharacterWeaponViewModel doesnt need valid ID anymore

This commit is contained in:
Karol Górzyński 2021-01-13 20:24:10 +01:00
parent 71f01a167c
commit ad92ad468b

View File

@ -36,9 +36,12 @@ namespace SessionCompanion.Services.Services
public async Task<Either<SuccessResponse,ErrorResponse>> ChangeCharacterWeapon(CharacterWeaponViewModel model) public async Task<Either<SuccessResponse,ErrorResponse>> ChangeCharacterWeapon(CharacterWeaponViewModel model)
{ {
// Dodaj optional rozbro postac // Dodaj optional rozbro postac
var weaponsInUse = await Repository.Get(c => c.CharacterId.Equals(model.CharacterId)).Where(w => w.InUse.Equals(true)).ToListAsync(); var allWeapons = await Repository.Get(c => c.CharacterId.Equals(model.CharacterId)).AsNoTracking().ToListAsync();
//var weaponsInUse = await Repository.Get(c => c.CharacterId.Equals(model.CharacterId)).Where(w => w.InUse.Equals(true)).ToListAsync();
var weaponsInUse = allWeapons.Where(w => w.InUse.Equals(true)).ToList();
var weapon = Mapper.Map<CharacterWeapon>(model); var weapon = Mapper.Map<CharacterWeapon>(model);
weapon.Id = allWeapons.Where(w => w.WeaponId.Equals(model.WeaponId)).Select(x => x.Id).FirstOrDefault();
if (weaponsInUse.Count() == 0) if (weaponsInUse.Count() == 0)
{ {