public void CheckLogins() { if (EmployeeLogins != null && _logintrue == false) { foreach (Employee e in EmployeeLogins) { if (_logintrue == false) { if (e.Barcode == Int64.Parse(Barcode)) { _logintrue = true; LoggedInEmployee = e; } } } if (_logintrue == true) { ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM; appvm.LoggedIn = LoggedInEmployee; appvm.From = DateTime.Now; appvm.ChangePage(new PageTwoVM()); } else { Error = "You are not registered in the system"; } } else { Error = "There are no users in the system, please contact helpdesk"; } }
private async void LogOff() { ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM; using (HttpClient client = new HttpClient()) { EmployeeRegister er = new EmployeeRegister() { RegisterID = 5, EmployeeID = CurrentEmployee.Barcode, From = appvm.From, Untill = DateTime.Now }; string input = JsonConvert.SerializeObject(er); HttpResponseMessage response = await client.PostAsync("http://localhost:41983/api/EmployeeRegister", new StringContent(input, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { string output = await response.Content.ReadAsStringAsync(); Console.WriteLine(Int32.Parse(output)); } else { Console.WriteLine("error: could not save employeeregister"); } } appvm.ChangePage(new LoginVM()); }