public async Task <bool> RegisterDriver(DriverApplicant applicant) { applicant.AddedDateTime = DateTime.Now; var uri = new Uri(string.Format(AppServerConstants.DriverApplicantsUrl, string.Empty)); HttpResponseMessage responseMessage = null; try { var json = JsonConvert.SerializeObject(applicant); var content = new StringContent(json, Encoding.UTF8, "application/json"); responseMessage = await client.PostAsync(uri, content); if (responseMessage.IsSuccessStatusCode) { Debug.WriteLine("POST {0} OK: DriverApplicant registration successful", responseMessage.StatusCode); return(true); } else { Debug.WriteLine(@"POST {0} NOT OK: DriverApplicant registration failed", responseMessage.StatusCode); } } catch (Exception ex) { Debug.WriteLine(@"ERROR: {0}", ex.Message); } return(false); }
// Private methods private async Task <bool> HideDriverAppllicant(int driverApplicantId) { DriverApplicant applicant = ViewDriverApplicant(driverApplicantId).Result; applicant.IsApproved = true; applicant.ApprovedDateTime = DateTime.Now; applicant.ApprovedByAdminId = 1; //applicant.IsHidden = true; //applicant.HiddenDateTime = DateTime.Now; var uri = new Uri(string.Format(AppServerConstants.DriverApplicantsUrl, driverApplicantId)); HttpResponseMessage response = null; try { var json = JsonConvert.SerializeObject(applicant); var content = new StringContent(json, Encoding.UTF8, "application/json"); response = await client.PutAsync(uri, content); if (response.IsSuccessStatusCode) { Debug.WriteLine(@"SUCCESS: DriverApplicant hidden!"); return(true); } } catch (Exception ex) { Debug.WriteLine(@"ERROR {0}: {1}", response.StatusCode, ex.Message); } return(false); }
public async Task <IActionResult> PutDriverApplicant([FromRoute] int id, [FromBody] DriverApplicant driverApplicant) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != driverApplicant.DriverApplicantId) { return(BadRequest()); } _context.Entry(driverApplicant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DriverApplicantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private async void NextButton_Clicked(object sender, EventArgs e) { if (!string.IsNullOrEmpty(emailEntry.Text) || !string.IsNullOrEmpty(matricsnoEntry.Text) || !string.IsNullOrEmpty(newPasswordAgainEntry.Text) || !string.IsNullOrEmpty(phonenumberEntry.Text) || !string.IsNullOrEmpty(firstNameEntry.Text) || !string.IsNullOrEmpty(lastNameEntry.Text) || genderPicker.SelectedIndex != -1 || MatricsCardPhotoCapture != null || MatricsCardPhotoCapture.Length != 0) { DriverApplicant applicant = new DriverApplicant() { EmailAddress = emailEntry.Text, MatricsNo = matricsnoEntry.Text, Password = newPasswordAgainEntry.Text, PhoneNumber = phonenumberEntry.Text, FirstName = firstNameEntry.Text, LastName = lastNameEntry.Text, Gender = Convert.ToChar((string)genderPicker.SelectedItem), DateOfBirth = dateOfBirthPicker.Date, MatricsCardPhoto = MatricsCardPhotoCapture }; await Navigation.PushAsync(new RegisterNewDriver_CarDetailsPage(applicant)); } }
public async Task <IActionResult> PostDriverApplicant([FromBody] DriverApplicant driverApplicant) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.DriverApplicants.Add(driverApplicant); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDriverApplicant", new { id = driverApplicant.DriverApplicantId }, driverApplicant)); }
public async Task <DriverApplicant> ViewDriverApplicant(int driverApplicantId) { DriverApplicant applicant = new DriverApplicant(); var uri = new Uri(string.Format(AppServerConstants.DriverApplicantsUrl, driverApplicantId)); try { var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); applicant = JsonConvert.DeserializeObject <DriverApplicant>(content); } } catch (Exception ex) { Debug.WriteLine(@"ERROR: {0}", ex.Message); } return(applicant); }
public Task <bool> RegisterDriver(DriverApplicant applicant) { return(credentialsService.RegisterDriver(applicant)); }
public RegisterNewDriver_CarDetailsPage(DriverApplicant applicant) { InitializeComponent(); driverApplicant = applicant; }