public async Task <string> GetAsync() { AzureApi api = new AzureApi(); string bearerToken = await api.GetBearerTokenAsync(); //return await api.CreateVm(bearerToken); await api.GetAllVmAsync(bearerToken); return(""); //return await api.RemoveVmWithTags(bearerToken, "Tezt", "wabaduu"); //await api.CreateVm(bearerToken); }
public async Task <List <object> > GetAllVmInfoAsync() { var bearer = await aapi.GetBearerTokenAsync(); var allVms = await aapi.GetAllVmAsync(bearer); List <object> result = new List <object>(); foreach (var vm in allVms) { var origin = vmh.FindOrigin(vm); var user = new CyberSparrow(); if (origin != "unknown") { var originObject = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(origin); var userId = originObject[0]["PlayerId"]; if (userId == null || string.IsNullOrWhiteSpace(userId.ToString())) { var obj = originObject[0]; var usrobj = originObject[0]["User"]; //user = obj["Id"]; user = usrobj.ToObject <CyberSparrow>(); userId = null; } if (userId != null) { var userIdString = userId.ToString(); //userIdString = userId.Split(new char[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries); user = userHandler.GetUserById(userIdString); } } //var originUser = userHandler.GetUserById(originObject); var x = new { vmName = vm, origin = vmh.FindOrigin(vm), player = user }; result.Add(x); } return(result); }