//vult de registeredCustomer list met de bestaande customers in de Json file //dit omdat de Json file volledig overschreven wordt met alle customers die in deze list staan //wanneer een nieuwe registratie gemaakt wordt dmv de File.WriteAllText public static void fillRegisteredCustomerList() { string jsonText = File.ReadAllText("registered_customers.json"); using (JsonDocument document = JsonDocument.Parse(jsonText)) { JsonElement root = document.RootElement; JsonElement customerListElement = root; foreach (JsonElement customer in customerListElement.EnumerateArray()) { if (customer.TryGetProperty("CustomerName", out JsonElement CustomerNameElement) && customer.TryGetProperty("Birthday", out JsonElement BirthdayElement) && customer.TryGetProperty("Age", out JsonElement AgeElement) && customer.TryGetProperty("Email", out JsonElement EmailElement) && customer.TryGetProperty("CustomerPassword", out JsonElement CustomerPasswordElement) && customer.TryGetProperty("CustomerUserName", out JsonElement CustomerUserNameElement)) { string CustomerName = CustomerNameElement.GetString(); DateTime Birthday = BirthdayElement.GetDateTime(); int Age = AgeElement.GetInt32(); string Email = EmailElement.GetString(); string CustomerPassword = CustomerPasswordElement.GetString(); string CustomerUserName = CustomerUserNameElement.GetString(); Customer customer1 = new Customer(CustomerName, Birthday, Email); customer1.CustomerPassword = CustomerPassword; customer1.CustomerUserName = CustomerUserName; customer1.Age = Age; Program.registeredCustomers.Add(customer1); } } } }
//Methods // Creates a user given a set of details public static void CreateUser(string firstname, string lastname, string startdate, string email) { //Wait for First Name Box Helper.WaitForElement(By.XPath("/html/body/div/div/div/form/fieldset/label[1]/input")); //Enter First Name FirstNameElement.SendKeys(firstname); //Enter Last Name LastNameElement.SendKeys(lastname); //Enter Start Date StartDateElement.SendKeys(startdate); //Enter Email Address EmailElement.SendKeys(email); //Click Create Button Setup.cDriver.FindElement(AddButton).Click(); }
// Methods // Edits User to hold new values public static void UpdateUser(string firstname, string lastname, string startdate, string email) { //Wait for Email Box Helper.WaitForElement(By.CssSelector("body > div > div > div > form > fieldset > label:nth-child(6) > input")); //Enter First Name FirstNameElement.Clear(); FirstNameElement.SendKeys(firstname); //Enter Last Name LastNameElement.Clear(); LastNameElement.SendKeys(lastname); //Enter Start Date StartDateElement.Clear(); StartDateElement.SendKeys(startdate); //Enter Email Address EmailElement.Clear(); EmailElement.SendKeys(email); //Click update Button Setup.cDriver.FindElement(UpdateButton).Click(); }
/// <summary> /// Gets the email. /// </summary> /// <returns></returns> public virtual string GetEmail() { return(EmailElement.GetValue <string>()); }
/// <summary> /// Enters the email. /// </summary> /// <param name="email">The email.</param> /// <returns></returns> public virtual _CreateOrUpdateInfoComponent EnterEmail(string email) { EmailElement.SetValue(email); return(this); }
public WhatYouCouldEarnSection EnterEmail(string email) { EmailElement.SendKeys(email); return(this); }
/// <summary> /// Sets the email. /// </summary> /// <param name="email">The email.</param> /// <returns></returns> public virtual IAddressesCreateOrUpdatePage <T> SetEmail(string email) { EmailElement.SetValue(email); return(this); }
/// <summary> /// Searches using the search model. /// </summary> /// <param name="searchModel">The search model.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">searchModel</exception> public virtual IListPage Search(CustomerSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } EmailElement.SetValue(searchModel.Email); FirstNameElement.SetValue(searchModel.FirstName); LastNameElement.SetValue(searchModel.LastName); if (searchModel.DateOfBirth.HasValue) { DateOfBirthMonthElement.SelectByValue( searchModel.DateOfBirth.Value.Month.ToString()); DateOfBirthDayElement.SelectByValue( searchModel.DateOfBirth.Value.Day.ToString()); } else { DateOfBirthMonthElement.SelectByIndex(0); DateOfBirthDayElement.SelectByIndex(0); } CompanyElement.SetValue(searchModel.Company); IpAddressElement.SetValue(searchModel.IpAddress); var currentlySelectedItems = CustomerRoles.GetSelectedOptions(); if (searchModel.CustomerRoles != null) { foreach (var opt in currentlySelectedItems) { if (!searchModel.CustomerRoles?.Contains(opt) ?? true) { CustomerRoles.DeselectItem(opt); } // Check if there are items that have yet to be selected. if (searchModel.CustomerRoles?.Except(currentlySelectedItems).Any() ?? false) { foreach (var _opt in searchModel.CustomerRoles) { CustomerRoles.SelectItem(_opt); } } } } SearchElement.Click(); // Wait for the ajax indicator to toggle. WrappedDriver .Wait(TimeSpan.FromSeconds(10)) .TrySequentialWait( out var exception, d => IsAjaxBusy(), d => !IsAjaxBusy()); // Page should reload. Load(); return(this); }
/// <summary> /// Sets the email. /// </summary> /// <param name="email">The email.</param> /// <returns></returns> public virtual IInfoPage SetEmail(string email) { EmailElement.SetValue(email); return(this); }
public EmailService(EmailElement settings) { Settings = settings; }