private async void btnSubmit_Click(object sender, RoutedEventArgs e) { try { if (txtCompanyName.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Company full name"); await md.ShowAsync(); return; } else if (txtCompanyPhoneNumber.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Company phone Number"); await md.ShowAsync(); return; } else if (txtCompanyAddress.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Company Address"); await md.ShowAsync(); return; } else if (logoString == "") { MessageDialog md = new MessageDialog("Please Select Company Logo"); await md.ShowAsync(); return; } else if (txtCompanyEmail.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Company Email"); await md.ShowAsync(); return; } else if (!txtCompanyEmail.Text.Contains('@') || !txtCompanyEmail.Text.Contains('.')) { MessageDialog md = new MessageDialog("Please Enter a Valid Company Email"); await md.ShowAsync(); return; } else if (txtAdminName.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Admin name"); await md.ShowAsync(); return; } else if (txtAdminPhoneNumber.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Admin phone Number"); await md.ShowAsync(); return; } else if (txtAdminStaffIdNumber.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Admin Staff ID Number"); await md.ShowAsync(); return; } else if (txtAdminEmail.Text.Trim() == "") { MessageDialog md = new MessageDialog("Please enter Admin Email"); await md.ShowAsync(); return; } else if (!txtAdminEmail.Text.Contains('@') || !txtAdminEmail.Text.Contains('.')) { MessageDialog md = new MessageDialog("Please Enter a Valid Admin Email"); await md.ShowAsync(); return; } else { companyName = txtCompanyName.Text; companyEmail = txtCompanyEmail.Text; companyAddress = txtCompanyAddress.Text; companyPhoneNumber = txtCompanyPhoneNumber.Text; staffName = txtAdminName.Text; StaffIdNumber = txtAdminStaffIdNumber.Text; StaffPhoneNumber = txtAdminPhoneNumber.Text; StaffEmail = txtAdminEmail.Text; RemoteService service = new RemoteService(); CompanyDataPayLoad company = new CompanyDataPayLoad { CompanyName = companyName }; StaffDataPayload staff = new StaffDataPayload { StaffPhoneNumber = StaffPhoneNumber }; var response = await service.CheckIfCompanyExistService(company); var response2 = await service.CheckIfStaffExistService(staff); if (response.ResponseStatusCode == System.Net.HttpStatusCode.Found) { MessageDialog CompanyRegMsg = new MessageDialog("Company already exist"); await CompanyRegMsg.ShowAsync(); return; } else if (response2.ResponseStatusCode == System.Net.HttpStatusCode.Found) { MessageDialog AdminRegMsg = new MessageDialog("Admin already exist"); await AdminRegMsg.ShowAsync(); return; } else if (response.ResponseStatusCode == System.Net.HttpStatusCode.NotFound && response2.ResponseStatusCode == System.Net.HttpStatusCode.NotFound) { //Send to Registration DB newCompany(); } else { ResponseMessage msg = await service.RegisterNewCompany(company); MessageDialog checkInMsg = new MessageDialog("Server error"); checkInMsg.ShowAsync(); } } //After Registration //clearContents(); } catch (Exception ex) { MessageDialog msg = new MessageDialog(ex.Message + " Void - btnSubmit_Click"); checkInternet(); //await msg.ShowAsync(); } }
private async void btnUpdate_Click(object sender, RoutedEventArgs e) { try { if (imgCompanyLogo.Source == null) { MessageDialog msg = new MessageDialog("Select Company Logo", "Alert - Empty Field!"); await msg.ShowAsync(); } else if (string.IsNullOrEmpty(txtCompanyAddress.Text.Trim())) { MessageDialog msg = new MessageDialog("Add Company Address", "Alert - Empty Field!"); await msg.ShowAsync(); } else if (string.IsNullOrEmpty(txtCompanyEmail.Text.Trim())) { MessageDialog msg = new MessageDialog("Add Company Email", "Alert - Empty Field!"); await msg.ShowAsync(); } else if (string.IsNullOrEmpty(txtCompanyName.Text.Trim())) { MessageDialog msg = new MessageDialog("Add Company Name", "Alert - Empty Field!"); await msg.ShowAsync(); } else if (string.IsNullOrEmpty(txtCompanyPhoneNum.Text.Trim())) { MessageDialog msg = new MessageDialog("Add Company Phone Number", "Alert - Empty Field!"); await msg.ShowAsync(); } else { companyName = txtCompanyName.Text.Trim(); companyAddress = txtCompanyAddress.Text.Trim(); companyPhoneNumber = txtCompanyPhoneNum.Text.Trim(); companyEmailAddress = txtCompanyEmail.Text.Trim(); CompanyDataPayLoad company = new CompanyDataPayLoad(); company.CompanyName = companyName; company.CompanyId = CompId; company.CompanyAddress = companyAddress; company.CompanyEmailAddress = companyEmailAddress; company.CompanyPhoneNumber = companyPhoneNumber; company.CompanyLogo = companyLogoString; company.Description = "Company Profile updated by " + _activePage.UserStaffName + " | " + _activePage.UserStaffId; ResponseMessage msgExist = await service.CheckIfCompanyExistService(company); if (msgExist.ResponseStatusCode == System.Net.HttpStatusCode.Found) { ResponseMessage msgComp = await service.UpdateThisCompanyControllerService(company); if (msgComp.ResponseStatusCode == System.Net.HttpStatusCode.NotFound) { _activePage.CompanyName = companyName; _activePage.CompanyId = CompId; _activePage.CompanyAddress = companyAddress; _activePage.CompanyEmail = companyEmailAddress; _activePage.CompanyPhoneNumber = companyPhoneNumber; _activePage.CompanyLogoString = companyLogoString; _activePage.CompanyLogo = await VisitorAppHelper.Base64StringToBitmap(_activePage.CompanyLogoString); MessageDialog ms = new MessageDialog("Update Successful"); await ms.ShowAsync(); } else { MessageDialog ms = new MessageDialog(msgComp.Message, "Err: "); await ms.ShowAsync(); } } else { MessageDialog ms = new MessageDialog(msgExist.Message, "Err: "); await ms.ShowAsync(); } } } catch (Exception ex) { checkInternet(); MessageDialog msgErr = new MessageDialog(ex.Message, "Error - btnUpdate_Click"); //msgErr.ShowAsync(); } }