public async void LoadCabinMember(CabinCrewLogin cabinCrewLogin) { var cabinCrewJson = JsonConvert.SerializeObject(cabinCrewLogin); Windows.Web.Http.HttpClient client = new Windows.Web.Http.HttpClient(); var res = await client.PostAsync(new Uri("http://localhost:5000/api/User/cabincrew/login"), new HttpStringContent(cabinCrewJson, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json")); if (res.IsSuccessStatusCode) { Model.CabinCrew cr = JsonConvert.DeserializeObject <Model.CabinCrew>(res.Content.ToString()); if (cr != null) { Flight = cr.Flight; } } }
public async Task LoginCabinCrew() { try { var cabinCrewJson = JsonConvert.SerializeObject(CabinCrewLogin); HttpClient client = new HttpClient(); var res = await client.PostAsync(new Uri("http://localhost:5000/api/User/cabincrew/login"), new HttpStringContent(cabinCrewJson, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json")); if (res.IsSuccessStatusCode) { Model.CabinCrew cr = JsonConvert.DeserializeObject <Model.CabinCrew>(res.Content.ToString()); if (cr != null) { VisibilityLogin = Visibility.Visible; VisibilityCheck = Visibility.Collapsed; Name = cr.FirstName + " " + cr.LastName; ErrorMessage = null; } } else { if ((int)res.StatusCode == 412) { ErrorMessage = "Username is incorrect!"; } if ((int)res.StatusCode == 404) { ErrorMessage = "Password is incorrect!"; } } } catch (Exception) { ErrorMessage = "Something went wrong! Please try again later."; } }