public async Task <bool> UpdateWorld(WorldUpdateRequest request) { var world = await _worldRepository.Get(request.WorldId); if (world != null) { world.Title = request.Title; world.Owner = await _userRepository.Get(request.UserId); await _worldRepository.Update(request.WorldId, world); await _worldPublisher.PublishUpdateWorld(request.WorldId, world.Title); return(true); } else { throw new WorldNotFoundException("The world with the id: " + request.WorldId + " does not exist"); } }
public ActionResult Put(WorldUpdateRequest updateRequest, [FromHeader(Name = "Authorization")] string jwt) { var idclaim = _authenticationHelper.getUserIdFromToken(jwt); if (idclaim == updateRequest.UserId) { try { _worldManagementService.UpdateWorld(updateRequest); return(Ok("Worldname changed to:" + updateRequest.Title)); } catch (Exception ex) { return(BadRequest(ex.Message)); } } else { return(Unauthorized("You are not authorised to do this")); } }