public static async Task <ObservableCollection <Log> > GetActiveTrains() { var tempData = await WebConnect.GetData("Train/GetActiveTrains"); var results = JsonConvert.DeserializeObject <IEnumerable <Log> >(tempData); var log = new ObservableCollection <Log>(); foreach (var result in results) { var temp = new Log { TrainId = result.TrainId, Name = result.Name, StartTime = result.StartTime, Speed = result.Speed, Delay = TimeSpan.Parse(result.Delay).ToString(@"hh\:mm\:ss"), Status = result.Status, MaxSpeed = result.MaxSpeed, NextStop = result.NextStop, LastLocation = result.LastLocation, }; log.Add(temp); } return(log); }
public static async Task <ObservableCollection <InactiveTrains> > GetInActiveTrains() { var tempData = await WebConnect.GetData("Train/InactiveTrains"); var results = JsonConvert.DeserializeObject <IEnumerable <InactiveTrains> >(tempData); var log = new ObservableCollection <InactiveTrains>(); foreach (var result in results) { var temp = new InactiveTrains { TID = result.TID, Name = result.Name, ActionsEnum = ActionsEnum.SelectAction, DirectionEnum = DirectionEnum.SelectDirection }; log.Add(temp); } return(log); }
public async Task Login(object parameter) { await RunCommand(() => this.LoginIsRunning, async() => { await Task.Delay(2000); var userName = UserName; var password = (parameter as IHavePassword).SecureString.UnsSecure(); var response = WebConnect.PostData("user/login", new { Uname = userName, password }); if (response.StatusCode == HttpStatusCode.OK) { var jObject = JObject.Parse(response.Content.ReadAsStringAsync().Result); LogInFor.Data = jObject; var win = Application.Current.MainWindow; new Main().Show(); win.Close(); } else { DialogDisplayHelper.DisplayMessageBox("Check Your PassWord And Username", "Login Failed", MessageBoxButton.OK, MessageBoxImage.Question); } }); }