// GET: Home/Details public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } Models.Contact contact = await _context.Contact .FirstOrDefaultAsync(m => m.Id == id); if (contact == null) { return(NotFound()); } return(View(contact)); }
private async Task AddContactCommandExecute() { if (!AddContactCommandCanExecute()) { DependencyService.Get <IMessage>().ShortAlert(AppResources.InvalidValues); return; } var contact = new Models.Contact { Text = ContactText, ContactTypeId = ContactType.ContactTypeId }; await _teamService.PostTeamContact(Team.TeamId, contact); await LoadContacts(); }
public void Add(Models.Contact contact) { var stringBuilder = new StringBuilder(); context.Log = new StringWriter(stringBuilder); Contact contactEntity = new Contact(); contactEntity.Id = Guid.NewGuid(); contactEntity.Name = contact.Name; contactEntity.Phone = contact.Phone; contactEntity.Address = contact.Address; context.Contacts.InsertOnSubmit(contactEntity); var sqlQuery = stringBuilder.ToString(); }
public void DeleteUserContact(Models.Contact contact, Guid userId) { using (ContactEntities db = new ContactEntities()) { IQueryable <User> userQuery = db.Users.Where(users => users.id == userId); User userData = userQuery.First(); IQueryable <ContactDAL.Contact> contactQuery = db.Contacts.Where(contactLocation => contactLocation.userId == userData.id && contactLocation.id == contact.Id); ContactDAL.Contact contactData = contactQuery.First(); db.Addresses.RemoveRange(contactData.Addresses); db.Emails.RemoveRange(contactData.Emails); db.Images.RemoveRange(contactData.Images); db.PhoneNumbers.RemoveRange(contactData.PhoneNumbers); db.Contacts.Remove(contactData); db.SaveChanges(); } }
public IActionResult Post( [FromBody] Models.NewContact value) { if (!base.ModelState.IsValid) { return(base.BadRequest(base.ModelState)); } var id = Guid.NewGuid(); var contact = new Models.Contact { Id = id, Name = value.Name, MobileNumber = value.MobileNumber }; this._logger.LogInformation($"Creating new contact with Id {id}"); this._repository.Save(contact); return(base.CreatedAtRoute("Get", new { id = contact.Id }, contact)); }
public IActionResult Put( Guid id, [FromBody] Models.Contact value) { if (!base.ModelState.IsValid) { return(base.BadRequest(base.ModelState)); } if (id != value.Id) { return(BadRequest(new { Id = "Id must match the body entity Id" })); } this._logger.LogInformation($"Updating contact with Id {id}"); this._repository.Save(value); return(base.Ok(value)); }
// GET: Contact public ActionResult Index() { var contacts = db.GetContacts(); foreach (var contact in contacts) { c = new Models.Contact(); c.Name = contact.GetName(contact.FirstName, contact.MiddleName, contact.LastName); c.Mobile = contact.Mobile; c.HomePhone = contact.HomePhone; c.Num++; c.Email = contact.Email; c.Id = contact.Id; contactList.Add(c); } return(View(contactList)); }
public async Task <ActionResult <Models.Contact> > SaveContact([FromBody] Models.Contact contact) { var UserId = this.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value; if (contact.Id > 0) { await contactManager.UpdateContact(contact); } else { contact.IsActive = true; contact.CreatedBy = UserId; contact.CreatedOn = DateTime.Now; contact.UserId = UserId; await contactManager.AddContact(contact); } return(Ok(new { ReturnMessage = "Contact saved successfully", IsSuccess = true, Data = contact })); }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here Models.Contact contact = db.Contacts.SingleOrDefault(c => c.contact_id == id); contact.info = collection["info"]; contact.type = collection["type"]; db.SaveChanges(); return(RedirectToAction("Index", new { id = contact.person_id })); } catch { return(View()); } }
public async Task <ActionResult> ContactAjax(Models.Contact task) { if (ModelState.IsValid) { var data1 = task.Name + ", " + task.Email; var bRet = task.SendEmail(); TempData["Status"] = "emailSent"; return(PartialView("contactResult", task)); } else { TempData["Status"] = "Message err from controller"; return(PartialView("ContactAjax", task)); //return PartialView("contactResult", task); } }
public ActionResult Contact(FormCollection form) { Contact contact = new Models.Contact(); contact.Yourname = Request.Form["name"]; contact.Yourlogin = Request.Form["login"]; contact.YourPhoneNumber = Request.Form["phonenumber"]; contact.State = 1; contact.Messages = Request.Form["message"]; int count = 0; int raznisa = contact.Yourlogin.Length; raznisa = 10 - raznisa; for (int i = 0; i < raznisa; i++) { contact.Yourlogin += " "; } foreach (var item in db.Users) { if (item.Username.Equals(contact.Yourlogin)) { count++; } } if (count > 0) { contact.UserID = db.Users.FirstOrDefault(x => x.Username.Equals(contact.Yourlogin)).id; } else { contact.UserID = 0; } contact.Date = DateTime.Now; db.Contacts.Add(contact); db.SaveChanges(); ViewBag.afterRegister = "Ваши сообщения успешно отправлены!!"; return(View()); }
public async Task <IActionResult> Contact(Models.Contact args) { ViewData["Title"] = "Contact"; if (!ModelState.IsValid) { return(View("Index")); } var smtpSettings = (ViewBag.Settings as List <EF.Setting>).Where(x => x.Group == "Smtp"); var smtpDisplayName = smtpSettings.First(x => x.Key == "Smtp display name").Value; var smtpDisplayEmail = smtpSettings.First(x => x.Key == "Smtp display email").Value; var smtpServer = smtpSettings.First(x => x.Key == "Smtp server").Value; var smtpPort = smtpSettings.First(x => x.Key == "Smtp port").Value; var smtpUseSsl = smtpSettings.First(x => x.Key == "Smtp use ssl").Value; var smtpUser = smtpSettings.First(x => x.Key == "Smtp user").Value; var smtpPwd = smtpSettings.First(x => x.Key == "Smtp password").Value; // Send email re: password var msg = new MimeMessage(); msg.From.Add(new MailboxAddress(args.Name, args.Email)); msg.To.Add(new MailboxAddress("", smtpUser)); msg.Subject = args.Subject; var bodyBuilder = new BodyBuilder(); bodyBuilder.HtmlBody = args.Message; msg.Body = bodyBuilder.ToMessageBody(); using (var client = new SmtpClient()) { await client.ConnectAsync(smtpServer, Convert.ToInt32(smtpPort), Convert.ToBoolean(smtpUseSsl)); // Note: only needed if the SMTP server requires authentication await client.AuthenticateAsync(smtpUser, smtpPwd); await client.SendAsync(msg); await client.DisconnectAsync(true); } TempData["notice"] = "Thank you for contacting us. We`ll review your message and get back to you soon."; return(Redirect("~/")); }
public async Task <bool> Update(int id, Models.Contact contact) { if (id <= 0) { throw new ArgumentException("Invalid Id"); } if (contact == null) { throw new ArgumentNullException(nameof(contact)); } return(await Task.Run(() => { contact.Id = id; return _contactDb.GetCollection <Models.Contact>(ContactCollection) .Update(contact); })); }
public async void DeleteContactAsync_Success() { // Setup var defaultAuthenticationProvider = new Providers.DefaultAuthenticationProvider(GetOrganizationId(), GetApiToken()); var tsClient = new TeamSupportServiceClient(SERVER_NAME, defaultAuthenticationProvider); var newContact = new Models.Contact() { Email = "*****@*****.**", FirstName = "Johnny", LastName = "Appleseed", IsPortalUser = true, Title = "API Generated User", OrganizationId = GetOrganizationId() }; var contact = await tsClient.Contacts.Request().AddAsync(newContact); // Execute await tsClient.Contacts[contact.Id].Request().DeleteAsync(); }
public async Task <ActionResult> ContactAjax(Models.Contact task) { if (ModelState.IsValid) { var data1 = task.Name + ", " + task.Email; var bRet = task.SendEmail(); TempData["Status"] = "emailSent";// itime request session object return(PartialView("ContactAjax", task)); //return RedirectToAction("ContactAjax", task);// the page will be opened with get } else { TempData["Status"] = "Message err from controller"; return(PartialView("ContactAjax", task)); //return PartialView("contactResult", task); } }
public ActionResult SubmitContactData(string Name = null, string MobileNo = null, string Email = null, string CompanyName = null, string ProductName = null, string Message = null) { string Status = ""; Models.Contact contact = new Models.Contact(); contact.CompanyName = CompanyName; contact.ContactDate = DateTime.Now; contact.Email = Email; contact.Message = Message; contact.MobileNo = MobileNo; contact.Name = Name; contact.ProductName = ProductName; db.Contact.Add(contact); db.SaveChanges(); ViewBag.Status = Status; return(Json(Status, JsonRequestBehavior.AllowGet)); }
public ActionResult Upload() { Models.Contact contact = GetContact(333); for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase file = Request.Files[i]; //Uploaded file //Use the following properties to get file's name, size and MIMEType int fileSize = file.ContentLength; string fileName = file.FileName; string mimeType = file.ContentType; System.IO.Stream fileContent = file.InputStream; //To save file, use SaveAs method file.SaveAs(Server.MapPath("~/") + fileName); //File will be saved in application root ViewBag.Message = "File uploaded"; } return(View()); }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here Models.Contact theContact = database.Contacts.SingleOrDefault(c => c.contact_id == id); theContact.information_type = collection["information_type"]; theContact.information = collection["information"]; database.SaveChanges(); return(RedirectToAction("Index", new { id = theContact.profile_id })); } catch { return(View()); } }
// GET: Contact/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(HttpNotFound()); } Models.Contact contact = _db.Get(id); if (contact == null) { return(HttpNotFound()); } SelectList sexes = new SelectList(Sexes.Get()); ViewBag.Sexes = sexes; return(View(contact)); }
public IActionResult UpdateContact([FromBody] Models.Contact contact) { if (!ModelState.IsValid) { return(BadRequest()); } var results = _contactService.GetContacts().FirstOrDefault(c => c.Name == contact.Name); if (results == null) { return(NotFound()); } results.Email = contact.Email; results.Company = contact.Company; results.PersonalPhoneNumber = contact.PersonalPhoneNumber; return(NoContent()); }
public async Task <IActionResult> SendFeedback(Models.Contact contact) { Models.Contact add_contact = new Models.Contact { Name = contact.Name, Email = contact.Email, Subject = contact.Subject, Message = contact.Message, SendingDate = DateTime.Now }; ContactVM contactVM = new ContactVM { Greeting = _db.ContactGreetings.FirstOrDefault() }; _db.Contacts.Add(add_contact); await _db.SaveChangesAsync(); return(View(contactVM)); }
private IEnumerable <Models.Contact> GetContacts(IEnumerable <ContactDTO> contacts, ICompanyKey companyKey) { var nextContactId = 1; foreach (var contact in contacts) { _loadCount.AddRead(EntityType.Contact); var newContact = new Models.Contact { CompanyId = companyKey.CompanyKey_Id, ContactId = nextContactId++, Name = contact.Contact_IA, PhoneNumber = contact.Phone_IA, EMailAddress = contact.EMailAddress_IA, OldContextID = contact.OldContextID }; newContact.Addresses = GetContactAddresses(contact.Addresses, newContact).ToList(); yield return(newContact); } }
public ActionResult Create(int id, FormCollection collection) { try { // TODO: Add insert logic here Models.Contact newContact = new Models.Contact() { person_id = id, type = collection["type"], info = collection["info"] }; db.Contacts.Add(newContact); db.SaveChanges(); return(RedirectToAction("Index", new { id = newContact.person_id })); } catch { return(View()); } }
public virtual ActionResult HamidJalalat(string text) { if (text != string.Empty) { try { Models.Contact contect = new Models.Contact(); contect.UserName = User.Identity.Name; contect.Text = text; db.Contacts.Add(contect); db.SaveChanges(); } catch (Exception) { } } var listContact = db.Contacts.OrderByDescending(C => C.Id).ToList(); return(View(listContact)); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { Models.Contact model = (Models.Contact)validationContext.ObjectInstance; if (value == null && model.TypeNumber == Models.Enums.TypeNumber.Residencial) { return(ValidationResult.Success); } string number = (value as string).Trim(); IContactRepository repository = (IContactRepository)validationContext.GetService(typeof(IContactRepository)); if (model.TypeNumber == Models.Enums.TypeNumber.Celular && number.Length != 9) { return(new ValidationResult("Número de celular invalido")); } if (model.TypeNumber == Models.Enums.TypeNumber.Residencial && number.Length != 8) { return(new ValidationResult("Número residencial invalido")); } return(ValidationResult.Success); }
public JsonResult GetAllContacts() { List <Models.Contact> contacts = new List <Models.Contact>(); try { List <ContactInfo> contactInfos = _repository.GetContacts(); if (contactInfos != null) { foreach (var contact in contactInfos) { Models.Contact contactObj = _mapper.Map <Models.Contact>(contact); contacts.Add(contactObj); } } } catch (Exception ex) { contacts = null; } return(new JsonResult(contacts)); }
public IActionResult GetProtectedDataForAdmin() { Contract.Ensures(Contract.Result <IActionResult>() != null); using (var context = new Database.LorikeetAppContext()) { List <Models.Contact> contactsToRest = new List <Models.Contact>(); var contacts = context.Contact.ToList(); foreach (var item in contacts) { var Contact = new Models.Contact(); Contact.ContactId = item.ContactId; Contact.MemberId = item.MemberId; Contact.ContactType = item.ContactType; Contact.ContactName = item.ContactName; Contact.ContactAddress = item.ContactAddress; Contact.ContactPhone = item.ContactPhone; contactsToRest.Add(Contact); } return(Ok(contactsToRest)); } }
public async void TestCreate() { String accessToken = this.RandomString(); Models.Contact contact = new Models.Contact(); contact.ContactData = new Models.ContactData(); contact.ContactData.Notes = this.RandomString(); CreateContactRequest req = new CreateContactRequest(); req.Contact = contact; MockAPI <Contacts> mock = this.MockFor <Contacts>( HttpMethod.Post, "/api/v1/contacts.create", m => m.WithContent(req.ToString()) .Respond("application/json", req.ToString()) ); APIResponse <ContactResponseBody> res = await mock.Instance.Create(accessToken, contact, null); mock.Handler.VerifyNoOutstandingExpectation(); Assert.Equal(contact.ContactData.Notes, res.Body.Contact.ContactData.Notes); }
private void SaveContactButton_Click(object sender, EventArgs e) { try { XMLHelper helper = new XMLHelper(); Mail_Client.Models.Contact NewContact = new Models.Contact(); NewContact.ID = helper.LastElementUniqueID(_location + "Contacts.xml", "Contact") + 1; NewContact.Name = NameTextbox.Text; NewContact.Email = EmailIDTextbox.Text; contactManager.Add(NewContact); MessageBox.Show("New Contact: " + NewContact.Name + " Added Successfully"); this.Close(); } catch (Exception ex) { MessageBox.Show("Some Unexpected error has occured while adding new contact. Please try again after sometime."); } }
public ActionResult Create(IFormCollection collection, Models.Contact contact) { Domain.Contact dmc = new Contact(); dmc.FirstName = contact.FirstName; dmc.MiddleName = contact.MiddleName; dmc.LastName = contact.LastName; dmc.Mobile = contact.Mobile; dmc.WorkPhone = contact.WorkPhone; dmc.HomePhone = contact.HomePhone; dmc.Email = contact.Email; try { db.Add(dmc); db.Save(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ContactViewModel(Models.Contact contact) { this.contact = contact; }
public async Task<ActionResult> Edit(string id) { var contactsCollection = RetreiveMongohqDb().GetCollection<BsonDocument>(CollectionName); FilterDefinition<BsonDocument> filter = new BsonDocument("_id", ObjectId.Parse(id)); var contactToEdit = await contactsCollection.Find(filter).FirstOrDefaultAsync(); if (contactToEdit == null) return View("Index"); var contact = new Models.Contact { Id = contactToEdit["_id"].AsObjectId, FirstName = contactToEdit["firstname"].AsString, Surname = contactToEdit["surname"].AsString }; return View(contact); }
private IEnumerable<Models.Contact> ProcessExchangeContacts(List<Item> listItems) { Log(string.Format("ProcessExchangeContacts: {0}", listItems.Count)); List<Models.Contact> list = new List<Models.Contact>(); foreach (Item item in listItems) { Microsoft.Exchange.WebServices.Data.Contact eContact = item as Microsoft.Exchange.WebServices.Data.Contact; if (eContact != null) { Models.Contact contact = new Models.Contact(); contact.FirstName = eContact.GivenName != null ? eContact.GivenName : string.Empty; contact.MiddleName = eContact.MiddleName != null ? eContact.MiddleName : string.Empty; contact.LastName = eContact.Surname != null ? eContact.Surname : string.Empty; // add list email List<Email> listEmail = new List<Email>(); EmailAddressDictionary emailCollection = eContact.EmailAddresses; // email 1 EmailAddress emailAddr; emailCollection.TryGetValue(EmailAddressKey.EmailAddress1, out emailAddr); string email = emailAddr != null ? emailAddr.Address : null; if (!String.IsNullOrEmpty(email)) { Email emailDB = new Email(); emailDB.Value = email; EmailType emailType = new EmailType(); emailType.Name = EmailTypeDB.OFFICE365_EMAIL_TYPE_EMAIL_1_STRING; emailType.AccountType = new AccountType { Name = TYPE_OFFICE365_STRING }; emailDB.EmailType = emailType; listEmail.Add(emailDB); } // email 2 emailCollection.TryGetValue(EmailAddressKey.EmailAddress2, out emailAddr); email = emailAddr != null ? emailAddr.Address : null; if (!string.IsNullOrEmpty(email)) { Email emailDB = new Email(); emailDB.Value = email; EmailType emailType = new EmailType(); emailType.Name = EmailTypeDB.OFFICE365_EMAIL_TYPE_EMAIL_2_STRING; emailType.AccountType = new AccountType { Name = TYPE_OFFICE365_STRING }; emailDB.EmailType = emailType; listEmail.Add(emailDB); } // email 3 emailCollection.TryGetValue(EmailAddressKey.EmailAddress3, out emailAddr); email = emailAddr != null ? emailAddr.Address : null; if (!String.IsNullOrEmpty(email)) { Email emailDB = new Email(); emailDB.Value = email; EmailType emailType = new EmailType(); emailType.Name = EmailTypeDB.OFFICE365_EMAIL_TYPE_EMAIL_3_STRING; emailType.AccountType = new AccountType { Name = TYPE_OFFICE365_STRING }; emailDB.EmailType = emailType; listEmail.Add(emailDB); } contact.Emails = listEmail; // add list fax List<Fax> listFax = new List<Fax>(); PhoneNumberDictionary phoneDictionary = eContact.PhoneNumbers; // home fax string fax; phoneDictionary.TryGetValue(PhoneNumberKey.HomeFax, out fax); if (!String.IsNullOrEmpty(fax)) { Fax faxDB = new Fax(); faxDB.Value = fax; FaxType faxType = new FaxType(); faxType.Name = FaxTypeDB.OFFICE365_FAX_TYPE_HOME_STRING; faxType.AccountType = new AccountType { Name = TYPE_OFFICE365_STRING }; faxDB.FaxType = faxType; listFax.Add(faxDB); } // work fax phoneDictionary.TryGetValue(PhoneNumberKey.BusinessFax, out fax); if (!String.IsNullOrEmpty(fax)) { Fax faxDB = new Fax(); faxDB.Value = fax; FaxType faxType = new FaxType(); faxType.Name = FaxTypeDB.OFFICE365_FAX_TYPE_WORK_STRING; faxType.AccountType = new AccountType { Name = TYPE_OFFICE365_STRING }; faxDB.FaxType = faxType; listFax.Add(faxDB); } // other fax phoneDictionary.TryGetValue(PhoneNumberKey.OtherFax, out fax); if (!String.IsNullOrEmpty(fax)) { Fax faxDB = new Fax(); faxDB.Value = fax; FaxType faxType = new FaxType(); faxType.Name = FaxTypeDB.OFFICE365_FAX_TYPE_OTHER_STRING; faxType.AccountType = new AccountType { Name = TYPE_OFFICE365_STRING }; faxDB.FaxType = faxType; listFax.Add(faxDB); } contact.Faxes = listFax; list.Add(contact); } } return list; }