public async Task <IActionResult> Get() { string jwt = Request.Headers["Authorization"]; string userName = JwtTokenAppService.decodeTokenForUserName(jwt); var userData = await userManager.FindByNameAsync(userName); var cityData = await _cityService.GetCity(userData.City); return(Ok(cityData)); }
public async Task <IActionResult> BuyBuilding([FromBody] newBuildingModel newbuilding) { string jwt = Request.Headers["Authorization"]; string userName = JwtTokenAppService.decodeTokenForUserName(jwt); var userData = await userManager.FindByNameAsync(userName); var cityData = await _cityService.GetCity(userData.City); var result = await _dataRepository.BuyBuilding(newbuilding.BuildingId, cityData.Id); if (!result.Succeeded) { return(BadRequest("Internal error! Can not buy new building")); } return(Ok()); }
public async Task <IActionResult> CreateArmy(object newArmy) { string jwt = Request.Headers["Authorization"]; string userName = JwtTokenAppService.decodeTokenForUserName(jwt); var userData = await userManager.FindByNameAsync(userName); var cityData = await _cityService.GetCity(userData.City); var result = await _dataRepository.CreateArmy(newArmy, cityData.Id); if (!result.Succeeded) { return(BadRequest("Internal error! Can not create new army")); } return(Ok()); }
public async Task <IActionResult> StartUpgrade([FromBody] newUpgradeModel newUpgrade) { string jwt = Request.Headers["Authorization"]; string userName = JwtTokenAppService.decodeTokenForUserName(jwt); var userData = await userManager.FindByNameAsync(userName); var cityData = await _cityService.GetCity(userData.City); var result = await _dataRepository.StartUpgrade(newUpgrade.UpgradeId, cityData.Id); if (!result.Succeeded) { return(BadRequest("Internal error! Can not start new research")); } return(Ok()); }