private static string GetNew(ContactField field) { Console.Clear(); Console.WriteLine(GetNewContactFieldMessage(field)); return(CreateTextInput(field).Edit(string.Empty)); }
public bool EditContact(ContactDTO model) { try { using (var dbContext = new PhoneBookContext()) { var contact = new Contact(); contact.Id = model.Id; contact.Name = model.Name; foreach (var field in model.ContactFields) { var cf = new ContactField(); cf.Id = field.Id; cf.Field = field.Field; cf.Value = field.Value; cf.ContactId = field.ContactId; dbContext.ContactField.AddOrUpdate(cf); } dbContext.Contact.AddOrUpdate(contact); dbContext.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
private Action <object, EventArgs> TextChangedAction(string propertyName, int index) { return((sender, e) => { Entry entry = (Entry)sender; PropertyInfo property = _contact.GetType().GetProperty(propertyName); if (property != null) { object propertyValue = property.GetValue(_contact); if (propertyValue is ContactField) { property.SetValue(_contact, new ContactField(entry.Text, ((ContactField)propertyValue).Bounds)); } else if (propertyName == "Emails") { EmailField field = _contact.Emails[index]; field.Email = entry.Text; _contact.Emails[index] = field; } else if (propertyName == "PhoneNumbers") { PhoneField field = _contact.PhoneNumbers[index]; field.Number = entry.Text; _contact.PhoneNumbers[index] = field; } else if (propertyName == "Websites") { ContactField field = _contact.Websites[index]; field.Text = entry.Text; _contact.Websites[index] = field; } else if (propertyName == "Companies") { ContactField field = _contact.Companies[index]; field.Text = entry.Text; _contact.Companies[index] = field; } else if (propertyName == "JobTitles") { ContactField field = _contact.JobTitles[index]; field.Text = entry.Text; _contact.JobTitles[index] = field; } else if (propertyName == "Addresses") { ContactField field = _contact.Addresses[index]; field.Text = entry.Text; _contact.Addresses[index] = field; } _page.ContactModified = true; } }); }
private static TextInput CreateTextInput(ContactField field) { var charType = Contact.GetCharType(field); var maxLength = Contact.GetMaxLength(field); return(new TextInput(charType, maxLength)); }
private static float GetExplosionForce(GameObject obj, float z) { //scientific mathematical formulas for explosion float excessPressure = 808f * (1f + (Mathf.Pow(z / 4.5f, 2))) / (Mathf.Sqrt(1f + (Mathf.Pow(z / 0.048f, 2))) * Mathf.Sqrt(1f + (Mathf.Pow(z / 0.32f, 2))) * Mathf.Sqrt(1f + (Mathf.Pow(z / 1.35f, 2)))); excessPressure *= airPressure; //contact field ContactField cf = obj.GetComponent <ContactField>(); float contactField = 0; if (cf) { contactField = cf.CalcArea(); } else { contactField = obj.transform.localScale.x * 0.5f; contactField = Mathf.PI * contactField * contactField; } // return explosionForce; return(excessPressure * contactField); }
public void HelloWorld() { _db.Contacts.Local.CollectionChanged += ContactsChanged; Contact contact = ....; //< A contact from database. ContactField field = ....; ///< A new field
public void FillForm() { IsClickable(CompleteSelectField); CompleteSelectFieldOption.SelectByIndex(1); IsVisible(By.Id("ContactField")); ContactField.Clear(); SendData(ContactField, "1"); IsClickable(FollowupTypeField); FollowupTypeFieldOption.SelectByIndex(1); IsVisible(By.Id("FromDateField")); FromDateField.Clear(); SendData(FromDateField, "1"); IsClickable(LPOOwnerField); LPOOwnerFieldOption.SelectByIndex(1); IsVisible(By.Id("OrganizationField")); OrganizationField.Clear(); SendData(OrganizationField, "1"); IsVisible(By.Id("ToDateField")); ToDateField.Clear(); SendData(ToDateField, "1"); } // close FillForm
private static string Edit(Contact contact, ContactField field) { Console.Clear(); Console.WriteLine(EditContactFieldMessage(field)); return(CreateTextInput(field).Edit(contact.GetFieldValue(field))); }
public ActionResult sendQuery(ContactField contact) { //Pass the data to store the record into the table contact.sendMessage("insert into Contact(Name,Email,Message) values('" + contact.Name + "','" + contact.Email + "','" + contact.Message + "')"); return(View("submitted")); }
public void FillForm(ContactPageFactory contacts) { ContactField.SendKeys(contacts.Name); Telephone.SendKeys(contacts.RealTelepfoneNumber); Email.SendKeys(contacts.RealEmailAddress); TextArea.SendKeys(contacts.CommentBox); }
public static CharType GetCharType(ContactField field) { switch (field) { case ContactField.PhoneNumber: return(CharType.Digits); default: return(CharType.LettersAndDigits); } }
public async Task <IHttpActionResult> GetById(int id, ContactField fields, CancellationToken cancellationToken) { var contact = await _projectManager.GetContactByIdAsync(id, fields | ContactField.Project, cancellationToken); if (contact == null) { return(NotFound()); } await ApiSecurity.AuthorizeAsync(AccessObjectType.Project, contact.Project.Id, AccessPermission.CanView, cancellationToken); return(Ok(contact)); }
public void FillForm() { IsVisible(By.Id("ContactField")); ContactField.Clear(); SendData(ContactField, "1"); IsVisible(By.Id("OrganizationField")); OrganizationField.Clear(); SendData(OrganizationField, "1"); IsClickable(SectorField); SectorFieldOption.SelectByIndex(1); } // close FillForm
public void FillForm() { IsVisible(By.Id("ContactField")); ContactField.Clear(); SendData(ContactField, "1"); IsVisible(By.Id("OrganizationField")); OrganizationField.Clear(); SendData(OrganizationField, "1"); IsVisible(By.Id("SectorField")); SectorField.Clear(); SendData(SectorField, "1"); } // close FillForm
public void CreateSetField() { var contact = new ContactField { Id = Guid.NewGuid().ToString(), FirstName = "Jim", LastName = "Bob", }; var type = typeof(ContactField); var firstProperty = type.GetTypeInfo().GetField("FirstName"); Assert.NotNull(firstProperty); var firstDelegate = DynamicMethodFactory.CreateSet(firstProperty); Assert.NotNull(firstDelegate); firstDelegate(contact, "Jimmy"); Assert.Equal("Jimmy", contact.FirstName); }
public void CreateGetField() { var contact = new ContactField { Id = Guid.NewGuid().ToString(), FirstName = "Jim", LastName = "Bob", }; var type = typeof(ContactField); var firstField = type.GetTypeInfo().GetField("FirstName"); Assert.NotNull(firstField); var firstDelegate = ExpressionFactory.CreateGet(firstField); Assert.NotNull(firstDelegate); var firstName = firstDelegate(contact) as string; Assert.Equal(contact.FirstName, firstName); }
public static string GetFieldLabel(ContactField field) { switch (field) { case ContactField.FirstName: return(FIRST_NAME_LABEL); case ContactField.LastName: return(LAST_NAME_LABEL); case ContactField.MiddleName: return(MIDDLE_NAME_LABEL); case ContactField.PhoneNumber: return(PHONE_NUMBER_LABEL); case ContactField.Description: return(DESCRIPTION_LABEL); default: return(string.Empty); } }
public static int GetMaxLength(ContactField field) { switch (field) { case ContactField.FirstName: return(FIRST_NAME_MAX_LENGTH); case ContactField.LastName: return(LAST_NAME_MAX_LENGTH); case ContactField.MiddleName: return(MIDDLE_NAME_MAX_LENGTH); case ContactField.PhoneNumber: return(PHONE_NUMBER_MAX_LENGTH); case ContactField.Description: return(DESCRIPTION_MAX_LENGTH); default: return(Console.WindowWidth); } }
public string GetFieldValue(ContactField field) { switch (field) { case ContactField.FirstName: return(FirstName); case ContactField.LastName: return(LastName); case ContactField.MiddleName: return(MiddleName); case ContactField.PhoneNumber: return(PhoneNumber); case ContactField.Description: return(Description); default: return(string.Empty); } }
public static string EditContactFieldMessage(ContactField field) { return($"Edit {Contact.GetFieldLabel(field)} (max length - {Contact.GetMaxLength(field)} characters): "); }
private static bool ValidateFieldValue(string value, ContactField field) { return(!string.IsNullOrWhiteSpace(value) && ValidateFieldMaxLength(value, field) && ValidateFieldCharType(value, field)); }
private static bool ValidateFieldMaxLength(string value, ContactField field) { return(value.Length <= Contact.GetMaxLength(field)); }
private static bool ValidateFieldCharType(string value, ContactField field) { return(CharValidator.ValidateStringCharType(value, Contact.GetCharType(field))); }
/// <summary> /// Projects each product of a sequence into a new form. /// </summary> public static IQueryable <ContactItem> Select(this IQueryable <ProjectContact> query, IQueryable <ProjectBusinessTag> businessTagQuery, ContactField fields) { Expression <Func <ProjectContact, ContactItem> > selector = contact => new ContactItem { Id = contact.Id, FacebookId = contact.FacebookId, Email = contact.Email, FirstName = contact.FirstName, LastName = contact.LastName, NickName = contact.NickName, Gender = contact.Gender, Birthday = contact.Birthday, ModifiedDate = contact.ModifiedDate, Phones = contact.Phones, Comment = contact.Comment }; if (fields.HasFlag(ContactField.Project)) { selector = selector.Merge(contact => new ContactItem { Project = new UniqueItem { Id = contact.Project.Id, Name = contact.Project.Name } }); } if (fields.HasFlag(ContactField.Sponsor)) { selector = selector.Merge(contact => new ContactItem { Sponsor = contact.Sponsor == null ? null : new AccountItem { Id = contact.Sponsor.Id, Email = contact.Sponsor.Email, FirstName = contact.Sponsor.FirstName, LastName = contact.Sponsor.LastName, NickName = contact.Sponsor.NickName, Gender = contact.Sponsor.Gender, Birthday = contact.Sponsor.Birthday } }); } if (fields.HasFlag(ContactField.BusinessTags)) { selector = selector.Merge(contact => new ContactItem { BusinessTags = (from contactTag in contact.BusinessTags join businessTag in businessTagQuery on contactTag.BusinessTagId equals businessTag.Id orderby businessTag.Name select new BusinessTagItem { Id = businessTag.Id, Name = businessTag.Name, Color = businessTag.Color, CreatedDate = contactTag.CreatedDate }).ToList <UniqueItem>() }); } return(query.Select(selector)); }
/// <summary> /// Constructor for ApplePayContactInvalidError /// </summary> /// <param name="description">Localized description for the error</param> /// <param name="mailingAddressInputField">A field key from <see cref="MailingAddressInput"/> that represents the field that caused this error</param> /// <exception cref="ArgumentException">The value given for mailingAddressInputField does not have an equivalent representation as a ContactField</exception> public ApplePayContactInvalidError(string description, string mailingAddressInputField) : base(ErrorType.PaymentContactInvalid, description) { Field = ContactFieldFromMailingAddressInputField(mailingAddressInputField); }
/// <summary> /// Constructor for ApplePayContactInvalidError /// </summary> /// <param name="description">Localized description for the error</param> /// <param name="field">A <see cref="ContactField"/> that represents the field that caused this error</param> public ApplePayContactInvalidError(string description, ContactField field) : base(ErrorType.PaymentContactInvalid, description) { Field = field; }
public void FillForm() { IsVisible(By.Id("ContactField")); ContactField.Clear(); SendData(ContactField, "1"); IsVisible(By.Id("DailyEveryNDaysField")); DailyEveryNDaysField.Clear(); SendData(DailyEveryNDaysField, "1"); IsVisible(By.Id("DailyWeekdayOnlyField")); DailyWeekdayOnlyField.Clear(); SendData(DailyWeekdayOnlyField, "1"); IsVisible(By.Id("FollowupAllDayField")); FollowupAllDayField.Clear(); SendData(FollowupAllDayField, "1"); IsVisible(By.Id("FollowupEndField")); FollowupEndField.Clear(); SendData(FollowupEndField, "1"); IsVisible(By.Id("FollowupRecurrenceFieldGTCQVxZqURnpQmc43hunYrsSPw6161")); FollowupRecurrenceFieldGTCQVxZqURnpQmc43hunYrsSPw6161.Clear(); SendData(FollowupRecurrenceFieldGTCQVxZqURnpQmc43hunYrsSPw6161, "1"); IsVisible(By.Id("FollowupRecurrenceFieldGTCUn6DedTUYoYkAj2DhhBOzg6161")); FollowupRecurrenceFieldGTCUn6DedTUYoYkAj2DhhBOzg6161.Clear(); SendData(FollowupRecurrenceFieldGTCUn6DedTUYoYkAj2DhhBOzg6161, "1"); IsVisible(By.Id("FollowupRecurrenceFieldGTCbZf5Z47ikQdfFCaLS3lMYtA6161")); FollowupRecurrenceFieldGTCbZf5Z47ikQdfFCaLS3lMYtA6161.Clear(); SendData(FollowupRecurrenceFieldGTCbZf5Z47ikQdfFCaLS3lMYtA6161, "1"); IsVisible(By.Id("FollowupRecurrenceFieldGTCg6yLH436BQQ9C9QQzKBBBGw6161")); FollowupRecurrenceFieldGTCg6yLH436BQQ9C9QQzKBBBGw6161.Clear(); SendData(FollowupRecurrenceFieldGTCg6yLH436BQQ9C9QQzKBBBGw6161, "1"); IsVisible(By.Id("FollowupRecurrenceFieldGTCoR8of2mFXo47s6Nq0xHb8kA6161")); FollowupRecurrenceFieldGTCoR8of2mFXo47s6Nq0xHb8kA6161.Clear(); SendData(FollowupRecurrenceFieldGTCoR8of2mFXo47s6Nq0xHb8kA6161, "1"); IsVisible(By.Id("FollowupStartField")); FollowupStartField.Clear(); SendData(FollowupStartField, "1"); IsVisible(By.Id("FollowupSubjectField")); FollowupSubjectField.Clear(); SendData(FollowupSubjectField, "1"); IsClickable(FollowupTypeField); FollowupTypeFieldOption.SelectByIndex(1); IsVisible(By.Id("IsCompleteSwitchField")); IsCompleteSwitchField.Clear(); SendData(IsCompleteSwitchField, "1"); IsVisible(By.Id("MonthlyEveryNMonthsField")); MonthlyEveryNMonthsField.Clear(); SendData(MonthlyEveryNMonthsField, "1"); IsVisible(By.Id("OrganizationField")); OrganizationField.Clear(); SendData(OrganizationField, "1"); IsClickable(OwnerField); OwnerFieldOption.SelectByIndex(1); IsVisible(By.Id("WeeklyEveryNWeeksField")); WeeklyEveryNWeeksField.Clear(); SendData(WeeklyEveryNWeeksField, "1"); IsClickable(WeeklyWeekdayField); WeeklyWeekdayFieldOption.SelectByIndex(1); IsVisible(By.Id("YearlyEveryNYearsField")); YearlyEveryNYearsField.Clear(); SendData(YearlyEveryNYearsField, "1"); } // close FillForm
private Action <EventArgs> RowTappedAction(string header, string title, int index) { return(async(e) => { if (header == "Tel") { List <String> phoneList = new List <string>(); foreach (string name in Enum.GetNames(typeof(PhoneType))) { phoneList.Add(Helpers.PhoneTypeToString((PhoneType)Enum.Parse(typeof(PhoneType), name))); } string action = await _page.DisplayActionSheet("Change Phone Type", "Cancel", "Delete", phoneList.ToArray()); if (!String.IsNullOrEmpty(action) && !"Cancel".Equals(action)) { if (action == "Delete") { _contact.PhoneNumbers.RemoveAt(index); } else { _contact.PhoneNumbers[index] = new PhoneField(_contact.PhoneNumbers[index].Number, _contact.PhoneNumbers[index].Bounds, Helpers.PhoneStringToType(action)); } SetContact(); _page.ContactModified = true; } return; } else if (header == "Email") { string[] emailTypes = { "Personal Email", "Work Email" }; string action = await _page.DisplayActionSheet("Change Email Type", "Cancel", "Delete", emailTypes); if (!String.IsNullOrEmpty(action) && !"Cancel".Equals(action)) { if (action == "Delete") { _contact.Emails.RemoveAt(index); } else { _contact.Emails[index] = new EmailField(_contact.Emails[index].Email, _contact.Emails[index].Bounds, Helpers.EmailStringToType(action)); } SetContact(); _page.ContactModified = true; } return; } else if (title == "Website") { return; } string[] actions = { "Move", "Swap" }; string fieldAction = await _page.DisplayActionSheet("Action", "Cancel", title == "Name"?null : "Delete", actions); if (!String.IsNullOrEmpty(fieldAction) && !"Cancel".Equals(fieldAction)) { if (fieldAction == "Delete") { if (title == "Company") { _contact.Companies.RemoveAt(index); } else if (title == "Address") { _contact.Addresses.RemoveAt(index); } else if (title == "Job Title") { _contact.JobTitles.RemoveAt(index); } _page.ContactModified = true; SetContact(); return; } List <string> fieldsTypes = new List <string> { "Name", "Company", "Address", "Job Title" }; if (!HomePage.CurrentAppData.OptionalFields.Address) { fieldsTypes.Remove("Address"); } if (!HomePage.CurrentAppData.OptionalFields.Company) { fieldsTypes.Remove("Company"); } if (!HomePage.CurrentAppData.OptionalFields.JobTitle) { fieldsTypes.Remove("Job Title"); } switch (title) { case "Name": case "Company": case "Job Title": case "Address": fieldsTypes.Remove(title); if (fieldsTypes.Count <= 1) { return; } string actionTitle; if (fieldAction == "Move") { actionTitle = "Move To"; } else { actionTitle = "Swap With"; } string action = await _page.DisplayActionSheet(actionTitle, "Cancel", null, fieldsTypes.ToArray()); if (!String.IsNullOrEmpty(action) && !"Cancel".Equals(action)) { ContactField fieldToMove = new ContactField(); ContactField fieldToSwap = new ContactField(); if (title == "Name") { fieldToMove = _contact.Name; _contact.Name = new ContactField(); } else if (title == "Company") { fieldToMove = _contact.Companies[index]; _contact.Companies.RemoveAt(index); } else if (title == "Job Title") { fieldToMove = _contact.JobTitles[index]; _contact.JobTitles.RemoveAt(index); } else if (title == "Address") { fieldToMove = _contact.Addresses[index]; _contact.Addresses.RemoveAt(index); } if (fieldAction == "Move") { // Move to if (action == "Name") { _contact.Name = fieldToMove; } else if (action == "Company") { _contact.Companies.Add(fieldToMove); } else if (action == "Job Title") { _contact.JobTitles.Add(fieldToMove); } else if (action == "Address") { _contact.Addresses.Add(fieldToMove); } } else { // Swap with if (action == "Name") { fieldToSwap = _contact.Name; _contact.Name = fieldToMove; } else if (action == "Company") { if (_contact.Companies.Count > 0) { fieldToSwap = _contact.Companies[_contact.Companies.Count - 1]; _contact.Companies.Remove(fieldToSwap); } _contact.Companies.Add(fieldToMove); } else if (action == "Job Title") { if (_contact.JobTitles.Count > 0) { fieldToSwap = _contact.JobTitles[_contact.JobTitles.Count - 1]; _contact.JobTitles.Remove(fieldToSwap); } _contact.JobTitles.Add(fieldToMove); } else if (action == "Address") { if (_contact.Addresses.Count > 0) { fieldToSwap = _contact.Addresses[_contact.Addresses.Count - 1]; _contact.Addresses.Remove(fieldToSwap); } _contact.Addresses.Add(fieldToMove); } if (title == "Name") { _contact.Name = fieldToSwap; } else if (title == "Company") { _contact.Companies.Add(fieldToSwap); } else if (title == "Job Title") { _contact.JobTitles.Add(fieldToSwap); } else if (title == "Address") { _contact.Addresses.Add(fieldToSwap); } } SetContact(); _page.ContactModified = true; } break; default: break; } } }); }