public async Task UpdateCommander(UpdateCommanderDto commanderDto) { var commander = await _commanderRepository.GetByPesel(commanderDto.Pesel); commander = CommanderMapper.UpdateCommanderMap(commanderDto, commander); await _commanderRepository.UpdateCommander(commander); }
public static Commander UpdateCommanderMap(UpdateCommanderDto commanderDto, Commander commander) { commander.FirstName = commanderDto.FirstName; commander.LastName = commanderDto.LastName; commander.Email = commanderDto.Email; commander.Pesel = commanderDto.Pesel; commander.PhoneNumber = commanderDto.PhoneNumber; commander.Street = commanderDto.Address.Substring(0, commanderDto.Address.IndexOf(' ')); commanderDto.Address = commanderDto.Address.Remove(0, commanderDto.Address.IndexOf(' ') + 1); commander.HouseNumber = commanderDto.Address.Substring(0, commanderDto.Address.IndexOf(' ')); commanderDto.Address = commanderDto.Address.Remove(0, commanderDto.Address.IndexOf(' ') + 1); commander.PostCode = commanderDto.Address.Substring(0, commanderDto.Address.IndexOf(' ')); commanderDto.Address = commanderDto.Address.Remove(0, commanderDto.Address.IndexOf(' ') + 1); commander.City = commanderDto.Address.Substring(0, commanderDto.Address.Length); commander.MilitaryRank = commanderDto.MilitaryRank; return(commander); }
public async Task <ActionResult> UpdateCommander([FromBody] UpdateCommanderDto commanderDto) { await _commanderService.UpdateCommander(commanderDto); return(Ok()); }