public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (SelectedRole.Equals("Buyer")) { yield return(new ValidationResult( $"For Buyer role, a manager must be selected.", new[] { nameof(SelectedManager) })); } }
private async Task RegisterUserAsync() { if (Nid == null || Nid.Equals("")) { UserTittle = "Ingrese Nid"; _textBoxNid.Focus(FocusState.Programmatic); } else { if (Name == null || Name.Equals("")) { UserTittle = "Ingrese el nombre"; _textBoxName.Focus(FocusState.Programmatic); } else { if (LastName == null || LastName.Equals("")) { UserTittle = "Ingrese el apellido"; _textBoxLastName.Focus(FocusState.Programmatic); } else { if (Telephone == null || Telephone.Equals("")) { UserTittle = "Ingrese el Numero de telefono"; _textBoxTelephone.Focus(FocusState.Programmatic); } else { if (Email == null || Email.Equals("")) { UserTittle = "Ingrese el email"; _textBoxEmail.Focus(FocusState.Programmatic); } else { if (TextBoxEvent.IsValidEmail(Email)) { if (Password == null || Password.Equals("")) { UserTittle = "Ingrese la contrseƱa"; _textBoxPass.Focus(FocusState.Programmatic); } else { if (User == null || User.Equals("")) { UserTittle = "Ingrese el usuario"; _textBoxUser.Focus(FocusState.Programmatic); } else { if (SelectedRole == null || SelectedRole.Equals("")) { UserTittle = "Seleccione un rol"; } else { await SaveDataAsync(); } } } } else { UserTittle = "el Email no es valido"; _textBoxEmail.Focus(FocusState.Programmatic); } } } } } } }
public async Task checkLogin(bool isLDap) { try { string userType = string.Empty; if (SelectedRole.Equals("Select Role")) { userType = "Select Role"; } else if (SelectedRole.Equals("Nurse")) { userType = "N"; } else if (SelectedRole.Equals("FSA")) { userType = "F"; } else { userType = "NF"; } IsPageEnabled = true; String method = "UserLogin"; var obj = new login(); obj.Name = UserName; obj.pass = Password; obj.roleType = userType; if (isLDap) { obj.isLDap = 1; } var stringPayload = await Task.Run(() => JsonConvert.SerializeObject(obj)); var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json"); using (var httpClient = new System.Net.Http.HttpClient()) { var response = await httpClient.PostAsync(Library.URL + "/" + Library.METHODE_USERLOGIN, httpContent); if (response.ReasonPhrase == "Bad Request") { IsPageEnabled = false; ErrorText = "Invalid user name or password."; EnableSubmitButton = false; return; } else if (response.ReasonPhrase == "Not Found") { IsPageEnabled = false; ErrorText = "Invalid user name or password."; EnableSubmitButton = false; return; } if (response.Content != null) { var data = await response.Content.ReadAsStringAsync(); JArray jarray = JArray.Parse(data); string status = jarray[0].Value <string>("status"); string expireday = jarray[0].Value <string>("expireday"); bool isLogin = Convert.ToBoolean(jarray[0].Value <string>("is_login")); if (status == "Fail") { IsPageEnabled = false; EnableSubmitButton = true; ErrorText = "Invalid user name or password."; return; } for (int i = 0; i < jarray.Count; i++) { JObject row = JObject.Parse(jarray[i].ToString()); string id = row["ID"].ToString(); if (id != "0") { // Storing user's detail in application data locally Library.KEY_USER_ID = id; Library.KEY_USER_FIRST_NAME = row["FirstName"].ToString(); Library.KEY_USER_LAST_NAME = row["LastName"].ToString(); Library.KEY_ROLL_TYPE = row["RoleType"].ToString(); Library.KEY_USER_ROLE = row["UserRole"].ToString(); Library.KEY_USER_STATUS = row["status"].ToString(); Library.KEY_USER_SiteCode = row["SiteCode"].ToString(); Library.KEY_USER_ccode = row["country_id"].ToString(); Library.KEY_USER_regcode = row["region_id"].ToString(); Library.KEY_USER_siteid = row["site_id"].ToString(); Library.KEY_USER_roleid = row["role_Id"].ToString(); Library.KEY_USER_feedback_link = row["feedback_link"].ToString(); Library.KEY_USER_language_id = row["language_id"].ToString(); Library.KEY_USER_payment_mode_ids = row["payment_mode_ids"].ToString(); Library.KEY_USER_currency = row["country_currency"].ToString(); Library.KEY_USER_adjusttime = row["AdjustsiteTime"].ToString(); if (Library.KEY_USER_ROLE == "FSA" || Library.KEY_USER_ROLE == "Nurse" || Library.KEY_USER_ROLE == "Nurse+FSA") { CreateDB(); if (expireday == "") { await NavigateToHome(Library.URL, httpClient, id); } else if (expireday == "100") { await PageDialog.DisplayAlertAsync("Alert!!", "Password will expire in one day", "ok"); await NavigateToHome(Library.URL, httpClient, id); } else if (expireday == "200") { await PageDialog.DisplayAlertAsync("Alert!!", "Password will expire in two days", "OK"); await NavigateToHome(Library.URL, httpClient, id); } else if (expireday == "300") { await PageDialog.DisplayAlertAsync("Alert!!", "Password will expire in three days", "OK"); await NavigateToHome(Library.URL, httpClient, id); } else if (expireday == "400") { var termsPopup = new TermsConditionPopup(); termsPopup.Disappearing += async(s, e) => { if (termsPopup.isAccepted) { IsPageEnabled = true; dynamic p = new JObject(); p.UserId = Library.KEY_USER_ID; var Payload = JsonConvert.SerializeObject(p); var httpMSgClient = new System.Net.Http.HttpClient(); // Wrap our JSON inside a StringContent which then can be used by the HttpClient class var Content = new StringContent(Payload, Encoding.UTF8, "application/json"); var msgResponse = await httpMSgClient.PostAsync(Library.URL + "/" + "TermsConditions", Content); await NavigateToHome(Library.URL, httpMSgClient, id); IsPageEnabled = false; } }; await navigation.PushPopupAsync(termsPopup, true); } else if (expireday == "500") { //this.Frame.Navigate(typeof(PatientSearch), null); await PageDialog.DisplayAlertAsync("Alert!!", "Password is Expired.", "OK"); } else if (expireday == "600") { //this.Frame.Navigate(typeof(PatientSearch), null); await PageDialog.DisplayAlertAsync("Alert!!", "This User Is Deactivated, Kindly Contact Admin.", "OK"); } else { await PageDialog.DisplayAlertAsync("Alert!!", "Unknown Error.", "OK"); } } else { ErrorText = "Only FSA and Nurse can login in tablet."; } } else { ErrorText = "Invalid user name or password."; } } } } IsPageEnabled = false; } catch (Exception excp) { IsPageEnabled = false; await PageDialog.DisplayAlertAsync("Alert!!", excp.Message, "OK"); } }
private async void DoAssignTans(object obj) { try { WorkInProgress = true; var list = BatchTansView; var filteredItems = BatchTansView.Cast <BatchTanVM>(); BatchTans = new ObservableCollection <BatchTanVM>(); if (SelectedCurator != null) { if (!string.IsNullOrEmpty(CommentText)) { if (SelectedTans != null && SelectedTans.Count > 0) { var invalidTans = new List <object>(); TanState?tanstateToCheck = null; if (SelectedCurator.Role == Role.Curator) { tanstateToCheck = TanState.Not_Assigned; } else if (SelectedCurator.Role == Role.Reviewer) { tanstateToCheck = TanState.Curation_Submitted; } else if (SelectedCurator.Role == Role.QC) { tanstateToCheck = TanState.Review_Accepted; } if (tanstateToCheck != null) { invalidTans = SelectedTans.Where(st => ((st as BatchTanVM).CurrentRole != 0 && (st as BatchTanVM).CurrentRole != SelectedCurator.Role) || ((st as BatchTanVM).CurrentRole == 0 && (st as BatchTanVM).TanState != tanstateToCheck)).ToList(); if (!invalidTans.Any()) { var result = await RestHub.AssignTans(SelectedTans.Select(tan => (tan as BatchTanVM).Id).ToList(), SelectedCurator.UserId, U.RoleId, CommentText, SelectedRole.Equals("Curator")?Role.Curator : SelectedRole.Equals("Reviewer")?Role.Reviewer : Role.QC); if (result.UserObject != null) { AppInfoBox.ShowInfoMessage($"Tans Assigned to {SelectedRole} Successfully"); SearchTans.Execute(null); } else { AppErrorBox.ShowErrorMessage("Can't Assign TANs . .", result.StatusMessage); } } else { AppInfoBox.ShowInfoMessage($"In selected tans {string.Join(",", invalidTans.Select(tan => (tan as BatchTanVM).TanNumber + " - " + (tan as BatchTanVM).CurrentRole).ToList())} are allocated to other roles"); } } else { AppInfoBox.ShowInfoMessage("Please select Role"); } } else { AppInfoBox.ShowInfoMessage("Please select atleast One TAN From the below list to Assign TANs"); } } else { AppInfoBox.ShowInfoMessage("Please enter comment to Assign Selected TANs"); } } else { AppInfoBox.ShowInfoMessage("Please Select User to assign TANs"); } } catch (Exception ex) { Log.This(ex); } WorkInProgress = false; }