private void AddNewContact(object sender, RoutedEventArgs e) { NewContact next = new NewContact(); next.Show(); this.Hide(); }
public async Task <IHttpActionResult> UpdateContactInfo(int id, NewContact newContact) { if (ModelState.IsValid) { var contact = await db.t_CRM_Contacts.FindAsync(id); if (contact != null) { contact.FistName = newContact.FirstName; contact.LastName = newContact.LastName; db.Entry(contact).State = EntityState.Modified; try { await db.SaveChangesAsync(); return(Ok(contact)); } catch (DbUpdateException ex) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex))); } } else { return(NotFound()); } } else { return(BadRequest(ModelState)); } }
public void SendContactMail([FromBody] NewContact newContact) { var message = new MimeMessage(); message.From.Add(new MailboxAddress("Aegis", "*****@*****.**")); message.To.Add(new MailboxAddress($"{newContact.firstName} {newContact.lastName}", newContact.email)); message.Subject = "Contact Us Aegis"; message.Body = new TextPart("plain") { Text = "This client wants to be in contact with us: " + "\nName: " + newContact.firstName + " " + newContact.lastName + "\nEmail: " + newContact.email + "\nMessage: " + newContact.message }; using (var client = new SmtpClient()) { // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS) client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Connect("smtp.gmail.com", 465, true); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); // Note: only needed if the SMTP server requires authentication client.Authenticate("*****@*****.**", "strongpassword2017"); client.Send(message); client.Disconnect(true); } }
private async Task SaveNewContactCommandAsync() { using (CompliXperAppContext context = new CompliXperAppContext()) { NewContact contact = await(from c in context.NewContacts where c.ContactId == newContact.ContactId select c).FirstOrDefaultAsync(); if (contact != null) { contact.Comments = newContact.Comments; contact.Company = newContact.Company; contact.CreatedDate = DateTime.Now; contact.Email = newContactEmail; contact.FirstName = newContact.FirstName; contact.LastName = newContact.LastName; contact.Phonenumber = newContact.Phonenumber; contact.Title = newContact.Title; context.NewContacts.Update(contact); try { await context.SaveChangesAsync(); } catch (DbUpdateException e) { Console.WriteLine(e.InnerException); } await App.Current.MainPage.Navigation.PopToRootAsync(); } } }
private NewContact GetFilledRandomNewContact(string OmitPropName) { NewContact newContact = new NewContact(); if (OmitPropName != "LoginEmail") { newContact.LoginEmail = GetRandomString("", 6); } if (OmitPropName != "FirstName") { newContact.FirstName = GetRandomString("", 6); } if (OmitPropName != "LastName") { newContact.LastName = GetRandomString("", 6); } if (OmitPropName != "Initial") { newContact.Initial = GetRandomString("", 5); } if (OmitPropName != "ContactTitle") { newContact.ContactTitle = (ContactTitleEnum)GetRandomEnumType(typeof(ContactTitleEnum)); } if (OmitPropName != "ContactTitleText") { newContact.ContactTitleText = GetRandomString("", 5); } return(newContact); }
private void showNewContact() { NewContact newContact = new NewContact(); newContact.DataContext = new NewContactViewModel(_dataService); newContact.Show(); }
public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,PhoneNumber,Email,Street,PostalCode,City,Country,UserID")] NewContact newContact) { if (id != newContact.ID) { return(NotFound()); } newContact.UserID = userId; if (ModelState.IsValid) { try { _context.Update(newContact); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewContactExists(newContact.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(newContact)); }
private async void Edit_Clicked(object sender, EventArgs e) { var vmNewContact = new NewContactViewModel(); vmNewContact.fillPerson(vm.person); var newContact = new NewContact(vmNewContact); await Navigation.PushAsync(newContact); }
public async Task <ActionResult <Contact> > PostContact([FromBody] NewContact newContact) { var contact = _mapper.Map <Contact>(newContact); using var db = new WeatherContext(); db.Contacts.Add(contact); await db.SaveChangesAsync(); return(CreatedAtAction(nameof(PostContact), new { id = contact.Id }, _mapper.Map <Contact>(contact))); }
private async void GetContactMasterAsync(NewContact contact) { ContactSelected = null; await App.Current.MainPage.Navigation.PushAsync(new CompliXpertAppMasterDetailPage() { Detail = new NavigationPage(new NewContactMaster()) }); MessagingCenter.Send <ContactListScreenViewModel, NewContact>(this, Message.NewContactLoaded, contact); }
public async Task <bool> CreateUserFromAsLogin(Guid signInId, string email, string givenName, string familyName) { var contact = new NewContact { Email = email, GivenName = givenName, FamilyName = familyName }; var result = await Post($"/Account/{signInId}", contact); return(result == HttpStatusCode.OK); }
public IActionResult CreateContact(NewContact viewModel) { if (ModelState.IsValid) { listService.AddContact(viewModel); return(RedirectToAction(nameof(Success))); } return(View(viewModel)); }
public async Task <ActionResult> CreateAccountFromAsLogin(Guid signInId, [FromBody] NewContact contact) { var successful = await _mediator.Send(new CreateAccountFromAsLoginRequest(signInId, contact.Email, contact.GivenName, contact.FamilyName)); if (!successful) { return(BadRequest()); } return(Ok()); }
public async Task <ActionResult> InviteUser([FromBody] NewContact newContact) { var successful = await _mediator.Send(new CreateAccountRequest(newContact.Email, newContact.GivenName, newContact.FamilyName)); if (!successful) { return(BadRequest()); } return(Ok()); }
public void AddContact(NewContact viewModel) { dbContext.Contacts.Add(new ContactList.Contact { Company = viewModel.Company, Name = viewModel.Name, PhoneNumber = viewModel.PhoneNumber, Email = viewModel.Email }); dbContext.SaveChanges(); }
public static DTO.ContactDTO ConvertContactToDTO(NewContact Contacts) { return(new DTO.ContactDTO { ContactName = Contacts.ContactName, PhoneNumber = Contacts.PhoneNumber, Email = Contacts.Email, Aboutme = Contacts.Aboutme, Country = Contacts.Country, CityCode = Contacts.CityCode }); }
public string Init() { NewContact x = new NewContact(); x.name = null; x.email = null; x.msg = null; x.response = new Mail.Response(); x.response.isSent = false; x.response.msg = null; return(JsonConvert.SerializeObject(x, Formatting.None)); }
public async void AddNewContact() { NewContact nc = new NewContact() { Name = "From WebApi", Type = "Person" }; string url = $"https://app.clio.com/api/v4/contacts.json"; // use httpclient to send post request }
public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,PhoneNumber,Email,Street,PostalCode,City,Country,UserID")] NewContact newContact) { newContact.UserID = userId; if (ModelState.IsValid) { _context.Add(newContact); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(newContact)); }
public string Send(NewContact x) { string subject = string.Format(@" <h3>Novi upit</h3> <p>Ime: {0}</p> <p>Email: {1}</p> <p>Poruka: {2}</p>", x.name, x.email, x.msg); Mail m = new Mail(); x.response = m.SendMail(G.email, "Novi upit", subject); return(JsonConvert.SerializeObject(x, Formatting.None)); }
public async Task <Contact> CreateContact(Registration newRegistration) { var newContact = new NewContact { FirstName = newRegistration.FirstName, LastName = newRegistration.LastName, Email = newRegistration.Email, Organization = newRegistration.Organization, Status = "Active", RecreateInvoice = false }; var contractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }; var newContactString = JsonConvert.SerializeObject(newContact, new JsonSerializerSettings { ContractResolver = contractResolver, }); var encodedContact = new StringContent(newContactString, Encoding.UTF8, "application/json"); var apiEventResource = $"accounts/{_accountId}/contacts"; HttpResponseMessage response; var token = await GetTokenAsync(); try { response = await WildApricotOps.PostRequest(apiEventResource, token, encodedContact); } catch (Exception e) { Console.WriteLine(e); throw new Exception(e.Message); } var content = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <NewContactResponse>(content); return(new Contact { FirstName = result.FirstName, LastName = result.LastName, Email = result.Email, Organization = result.Organization, Status = "Active", Id = result.Id }); }
private void Split() { string line; int counter = 0; int id = 0; System.IO.StreamReader file = new System.IO.StreamReader("..\\DadesClient.edi"); while ((line = file.ReadLine()) != null) { counter++; } string[] array = new string[counter]; int arrayCounter = 0; file = new System.IO.StreamReader("..\\DadesClients.edi"); while ((line = file.ReadLine()) != null) { array[arrayCounter] = line; arrayCounter++; } for (int i = 0; i < array.Length; i++) { string[] linea = array[i].Split('|'); if (linea[0] == "CON") { id++; NewContact c = new NewContact { Name = linea[1], BirthDate = linea[2] }; dataGridView1. } else { ContactSystem s = new ContactSystem { } } } }
public ActionResult add_contact(NewContact contact) { var error_message = new object(); if (string.IsNullOrWhiteSpace(contact.contactFirstName) || string.IsNullOrWhiteSpace(contact.contactLastName) || string.IsNullOrWhiteSpace(contact.contactIdNumber) || string.IsNullOrWhiteSpace(contact.contactGender) || string.IsNullOrWhiteSpace(contact.contactEmail) || string.IsNullOrWhiteSpace(contact.contactStatus) || string.IsNullOrWhiteSpace(contact.contactPhone) || string.IsNullOrWhiteSpace(contact.addressNumber) || string.IsNullOrWhiteSpace(contact.addressName) || string.IsNullOrWhiteSpace(contact.addressSuburb) || string.IsNullOrWhiteSpace(contact.addressPostalCode) || string.IsNullOrWhiteSpace(contact.contactCountry) || string.IsNullOrWhiteSpace(contact.contactProv) || string.IsNullOrWhiteSpace(contact.contactCiti)) { error_message = "error, please enter all fields"; return(Json(error_message, "application/json; charset=utf-8", Encoding.UTF8, JsonRequestBehavior.DenyGet)); } var countryId = Guid.Parse(contact.contactCountry); var provinceId = Guid.Parse(contact.contactProv); var cityId = Guid.Parse(contact.contactCiti); User user = new User { FirstName = contact.contactFirstName, LastName = contact.contactLastName, Gender = contact.contactGender, ID = contact.contactIdNumber, Phone = contact.contactPhone, Email = contact.contactEmail, Status = contact.contactStatus, }; if (contact.contactImage != null) { user.MimeType = contact.contactImage.ContentType; user.Avatar = new byte[contact.contactImage.ContentLength]; contact.contactImage.InputStream.Read(user.Avatar, 0, contact.contactImage.ContentLength); } Address address = new Address { AddressNumber = contact.addressNumber, StreetName = contact.addressName, CountryId = countryId, ProvinceId = provinceId, CityId = cityId, Surburb = contact.addressSuburb, PostalCode = contact.addressPostalCode }; ContactInformation information = new ContactInformation { Address = address, User = user }; //add new city bool flag = false; using (var api = new HttpClient()) { api.BaseAddress = new Uri("https://*****:*****@gmail.com", "*****@*****.**", "New contact added", email_message); message.IsBodyHtml = true; NetworkCredential credential = new NetworkCredential("bqunta79", "delete+92"); SmtpClient client = new SmtpClient(); client.UseDefaultCredentials = false; client.Host = "smtp.gmail.com"; client.Port = 587; client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.ServicePoint.MaxIdleTime = 2; client.Credentials = credential; //send email client.Send(message); error_message = Url.Action("home", "admin"); return(Json(error_message, "application/json; charset=utf-8", Encoding.UTF8, JsonRequestBehavior.DenyGet)); } }
public ActionResult InviteUserValidate([FromBody] NewContact newContact) { return(Ok()); }
public AddNewContactScreenViewModel() { NewContact = new NewContact(); AddNewContactCommand = new Command(async() => await AddNewContactAsync(), () => canAdd); }
public NewContactTest() { newContact = new NewContact(); }
//[HttpPost("v2")] //public void Post2() //{ // using var db = new WeatherContext(); // var rng = new Random(); // var forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast2 { Id = Guid.NewGuid()}).ToArray(); // db.Weathers2.AddRange(forecasts); // db.SaveChanges(); //} //[HttpGet("v2/saved")] //public IEnumerable<WeatherForecast2> GetSaved2() //{ // using var db = new WeatherContext(); // return db.Weathers2.ToArray(); //} private Contact MapFrom(NewContact contact) { return(new Contact(0, contact.FirstName, contact.LastName, contact.Age.Value)); }
private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType) { string retStr = ""; Enums enums = new Enums(LanguageRequest); NewContact newContact = validationContext.ObjectInstance as NewContact; newContact.HasErrors = false; if (string.IsNullOrWhiteSpace(newContact.LoginEmail)) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "LoginEmail"), new[] { "LoginEmail" })); } if (!string.IsNullOrWhiteSpace(newContact.LoginEmail) && (newContact.LoginEmail.Length < 1 || newContact.LoginEmail.Length > 200)) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "LoginEmail", "1", "200"), new[] { "LoginEmail" })); } if (string.IsNullOrWhiteSpace(newContact.FirstName)) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "FirstName"), new[] { "FirstName" })); } if (!string.IsNullOrWhiteSpace(newContact.FirstName) && (newContact.FirstName.Length < 1 || newContact.FirstName.Length > 200)) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "FirstName", "1", "200"), new[] { "FirstName" })); } if (string.IsNullOrWhiteSpace(newContact.LastName)) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "LastName"), new[] { "LastName" })); } if (!string.IsNullOrWhiteSpace(newContact.LastName) && (newContact.LastName.Length < 1 || newContact.LastName.Length > 200)) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "LastName", "1", "200"), new[] { "LastName" })); } if (!string.IsNullOrWhiteSpace(newContact.Initial) && newContact.Initial.Length > 50) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "Initial", "50"), new[] { "Initial" })); } if (newContact.ContactTitle != null) { retStr = enums.EnumTypeOK(typeof(ContactTitleEnum), (int?)newContact.ContactTitle); if (newContact.ContactTitle == null || !string.IsNullOrWhiteSpace(retStr)) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "ContactTitle"), new[] { "ContactTitle" })); } } if (!string.IsNullOrWhiteSpace(newContact.ContactTitleText) && newContact.ContactTitleText.Length > 100) { newContact.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "ContactTitleText", "100"), new[] { "ContactTitleText" })); } retStr = ""; // added to stop compiling CSSPError if (retStr != "") // will never be true { newContact.HasErrors = true; yield return(new ValidationResult("AAA", new[] { "AAA" })); } }
public async Task <IHttpActionResult> CreateContact(NewContact newContact) { if (ModelState.IsValid) { t_CRM_Contacts contact = new t_CRM_Contacts() { FistName = newContact.FirstName, LastName = newContact.LastName, UserUid = newContact.UserUid, CreatedDate = DateTime.Now }; db.t_CRM_Contacts.Add(contact); try { await db.SaveChangesAsync(); List <t_CRM_Phones> PhoneList = new List <t_CRM_Phones>(); foreach (NewPhoneNumber c in newContact.Phones) { t_CRM_Phones phone = new t_CRM_Phones() { PhoneNumber = c.Number, ContactId = contact.ContactId, CreatedDate = contact.CreatedDate }; PhoneList.Add(phone); } db.t_CRM_Phones.AddRange(PhoneList); await db.SaveChangesAsync(); Contact DTOContact = new Contact() { ContactId = contact.ContactId, FirstName = contact.FistName, LastName = contact.LastName, Phones = db.t_CRM_Phones .Where(x => x.ContactId == contact.ContactId) .Select(y => new PhoneNumber { PhoneId = y.PhoneId, ContactId = y.ContactId, Number = y.PhoneNumber, CreatedDate = y.CreatedDate, }).ToList(), CreatedDate = contact.CreatedDate, UserUid = contact.UserUid }; return(Ok(DTOContact)); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex))); } catch (DbUpdateException ex) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex))); } } else { return(BadRequest(ModelState)); } }
public async Task <IActionResult> AddContact([FromBody] NewContact request) { var contact = await _userService.AddContact(User.Identity.Name, request.ContactName, request.SymmetricKey, request.IV); return(Ok(contact)); }