Example #1
0
        public async Task UpdateSoldier(UpdateSoldierDto soldierDto)
        {
            var soldier = await _soldierRepository.GetByPesel(soldierDto.Pesel);

            soldier = SoldierMapper.UpdateSoldierMap(soldierDto, soldier);
            await _soldierRepository.UpdateSoldier(soldier);
        }
Example #2
0
 public static Soldier UpdateSoldierMap(UpdateSoldierDto soldierDto, Soldier soldier)
 {
     soldier.FirstName    = soldierDto.FirstName;
     soldier.LastName     = soldierDto.LastName;
     soldier.Email        = soldierDto.Email;
     soldier.Pesel        = soldierDto.Pesel;
     soldier.PhoneNumber  = soldierDto.PhoneNumber;
     soldier.Street       = soldierDto.Address.Substring(0, soldierDto.Address.IndexOf(' '));
     soldierDto.Address   = soldierDto.Address.Remove(0, soldierDto.Address.IndexOf(' ') + 1);
     soldier.HouseNumber  = soldierDto.Address.Substring(0, soldierDto.Address.IndexOf(' '));
     soldierDto.Address   = soldierDto.Address.Remove(0, soldierDto.Address.IndexOf(' ') + 1);
     soldier.PostCode     = soldierDto.Address.Substring(0, soldierDto.Address.IndexOf(' '));
     soldierDto.Address   = soldierDto.Address.Remove(0, soldierDto.Address.IndexOf(' ') + 1);
     soldier.City         = soldierDto.Address.Substring(0, soldierDto.Address.Length);
     soldier.MilitaryRank = soldierDto.MilitaryRank;
     return(soldier);
 }
Example #3
0
        public async Task <ActionResult> UpdateSoldier([FromBody] UpdateSoldierDto soldierDto)
        {
            await _soldierService.UpdateSoldier(soldierDto);

            return(Ok());
        }