private async void newStaff(string staffFirstName, string staffLastName, string staffName, string StaffEmail, string StaffPhoneNumber, string StaffIdNumber, int DepartmentId, string StaffRole, string StaffPhotoString) { try { //Register new Staff StaffDataPayload staff = new StaffDataPayload(); staff.StaffFirstName = staffFirstName; staff.StaffLastName = staffLastName; staff.StaffName = staffName; staff.StaffEmail = StaffEmail; staff.StaffPhoneNumber = StaffPhoneNumber; staff.StaffIdNumber = StaffIdNumber; staff.DepartmentId = DepartmentId; staff.Role = StaffRole; staff.CompanyId = _activePage.CompanyId; staff.StaffPhoto = StaffPhotoString; staff.Description = "Added by " + _activePage.UserStaffName; staff.StaffStatus = StaffStatus.Active.ToString(); ResponseMessage msgExist = await service.CheckIfStaffExistService(staff); UserLoginDataPayLoad userDetail = new UserLoginDataPayLoad { username = await VisitorAppUserProcess.CreateUserName(StaffEmail) }; ResponseMessage msgUserExist = await service.CheckIfUserExistService(userDetail); if (msgExist.ResponseStatusCode == System.Net.HttpStatusCode.NotFound && msgUserExist.ResponseStatusCode == System.Net.HttpStatusCode.NotFound) { ResponseMessage msg = await service.RegisterNewStaff(staff); StaffId = msg.ResponseCode; if (msg.ResponseStatusCode == System.Net.HttpStatusCode.NotFound) { CreateBinding(); newUser(); ClearAddNewStaffields(); } } else { MessageDialog ms = new MessageDialog("Err: " + msgExist.Message + "\n" + msgUserExist.Message); await ms.ShowAsync(); } } catch (Exception ex) { checkInternet(); MessageDialog msg = new MessageDialog(ex.Message + " Void - newDepartment"); //await msg.ShowAsync(); } }
private async void newUser() { try { string userName = await VisitorAppUserProcess.CreateUserName(txtAdminEmail.Text); string password = txtAdminPassword.Password; UserLoginDataPayLoad userDetail = new UserLoginDataPayLoad(); userDetail.username = userName; userDetail.userPassword = password; userDetail.StaffId = StaffId; RemoteService service = new RemoteService(); ResponseMessage msg = await service.RegisterNewUser(userDetail); if (msg.ResponseStatusCode != System.Net.HttpStatusCode.NotFound) { MessageDialog mdd = new MessageDialog("Could not complete registration: " + msg.Message); await mdd.ShowAsync(); return; } MessageDialog md = new MessageDialog("Registration Complete"); await md.ShowAsync(); Clear(); this.Frame.Navigate(typeof(HubPage)); } catch (Exception ex) { MessageDialog msg = new MessageDialog(ex.Message + " Void - newUser"); checkInternet(); //msg.ShowAsync(); } }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// Page specific logic should be placed in event handlers for the /// <see cref="Common.NavigationHelper.LoadState"/> /// and <see cref="Common.NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </summary> #endregion private async void loginDetail() { try { string userName = await VisitorAppUserProcess.CreateUserName(txtUserName.Text); RemoteService service = new RemoteService(); UserLoginDataPayLoad userDetail = new UserLoginDataPayLoad { username = userName, userPassword = txtPassword.Password }; var response = await service.CheckIfUserExistService(userDetail); if (response.ResponseStatusCode == System.Net.HttpStatusCode.Found) { //MessageDialog Msg = new MessageDialog("User already exist"); //await Msg.ShowAsync(); //return; _activePage.UserStaffId = response.StaffId; var staffId = _activePage.UserStaffId; var ThisStaff = new List <StaffGlobal>(); #region MyRegion //RemoteService serviceThisStaff = new RemoteService(); //StaffDataPayload ThisStaffPayLoad = new StaffDataPayload() //{ // StaffId = staffId //}; //var responseThisStaff = service.GetThisStaffControllerService(ThisStaffPayLoad); //ThisStaff = responseThisStaff.StaffList; #endregion var responseThisStaff = GetDataFromDB.GetDataThisStaff(staffId).Result; ThisStaff = responseThisStaff.StaffList; string staffStatus = ""; foreach (var item in ThisStaff) { _activePage.UserStaffId = item.StaffId; _activePage.UserStaffRole = item.Roles; _activePage.UserStaffName = item.StaffName; _activePage.UserStaffPhotoString = item.StaffPhoto; _activePage.CompanyId = item.CompanyId; _activePage.UserDepartmentId = item.DepartmentId; _activePage.UserStaffIdNumber = item.StaffIdNumber; _activePage.UserStaffPhoneNumber = item.StaffPhoneNumber; _activePage.UserStaffPhoto = await VisitorAppHelper.Base64StringToBitmap(item.StaffPhoto); staffStatus = item.StaffStatus; } if (staffStatus.ToUpper() == StaffStatus.Suspended.ToString().ToUpper()) { MessageDialog msh = new MessageDialog("You are suspended and cannot currently access this application", "Alert!"); await msh.ShowAsync(); return; } var CompanyId = _activePage.CompanyId; var ThisCompany = new List <CompanyGlobal>(); #region MyRegion ////RemoteService serviceThisCompany = new RemoteService(); //CompanyDataPayLoad ThisCompanyPayLoad = new CompanyDataPayLoad() //{ // CompanyId = CompanyId //}; #endregion var responseThisCompany = GetDataFromDB.GetDataThisCompany(CompanyId).Result; ThisCompany = responseThisCompany.CompanyList; foreach (var item in ThisCompany) { _activePage.CompanyName = item.CompanyName; _activePage.CompanyLogoString = item.CompanyLogo; _activePage.CompanyLogo = await VisitorAppHelper.Base64StringToBitmap(item.CompanyLogo); _activePage.CompanyPhoneNumber = item.CompanyPhoneNumber; _activePage.CompanyAddress = item.CompanyAddress; _activePage.CompanyEmail = item.CompanyEmailAddress; _activePage.CompanyStatus = item.CompanyStatus; } if (_activePage.CompanyStatus.ToUpper() == CompanyStatus.Suspend.ToString().ToUpper()) { MessageDialog msgComp = new MessageDialog("Company License is not found.\n" + "Contact +234-XXX", "Alert!!!"); msgComp.ShowAsync(); return; } if (_activePage.CompanyStatus.ToUpper() == CompanyStatus.Deleted.ToString().ToUpper()) { MessageDialog msgComp = new MessageDialog("Company is not registered", "Alert!!!"); msgComp.Commands.Add(new UICommand("Register Company") { Id = 0 }); msgComp.Commands.Add(new UICommand("Cancel") { Id = 1 }); msgComp.CancelCommandIndex = 1; var result = await msgComp.ShowAsync(); if (Convert.ToInt32(result.Id) == 0) { this.Frame.Navigate(typeof(RegisterNewCompany)); } } var DepartmentId = _activePage.UserDepartmentId; var ThisDepartment = new List <DepartmentGlobal>(); #region MyRegion //RemoteService serviceThisDepartment = new RemoteService(); //DepartmentDataPayload ThisDepartmentPayLoad = new DepartmentDataPayload() //{ // DepartmentId = DepartmentId //}; #endregion var responseThisDepartment = GetDataFromDB.GetDataThisDepartment(DepartmentId).Result; ThisDepartment = responseThisDepartment.DepartmentList; foreach (var item in ThisDepartment) { _activePage.UserDepartmentName = item.DepartmentName; //_activePage.de = item.CompanyLogo; } if (_activePage.UserStaffRole.ToUpper() == StaffRoles.Staff.ToString().ToUpper()) { this.Frame.Navigate(typeof(Appointment), _activePage); } else { this.Frame.Navigate(typeof(FrontDeskHome), _activePage); //this.Frame.Navigate(typeof(CheckInWithInvitationPage), _activePage); } } else { MessageDialog msg = new MessageDialog("Details not Correct"); await msg.ShowAsync(); //this.Frame.Navigate(typeof(RegisterNewCompany)); } } catch (Exception ex) { MessageDialog msgd = new MessageDialog(ex.Message); MessageDialog msg = new MessageDialog("Try Again", "Hello"); await msg.ShowAsync(); } }