public void Can_add_contact() { var contact = GetTestContact(); repo.Add(contact); var fromDb = repo.GetById(contact.Id); Assert.NotNull(fromDb); Assert.AreEqual(fromDb.FirstName, contact.FirstName); Assert.AreEqual(fromDb.LastName, contact.LastName); }
public ActionResult SaveRecipient(int FilmSubmissionId, int CertificateMailingId, string FirstName, string LastName, string Suffix, string Title, string Company, string Address1, string Address2, string City, string State, string Zip, string Country, string Phone, string Fax, string Email, bool Original) { CertificateMailing cert = new CertificateMailing { FilmSubmissionId = FilmSubmissionId, CertificateMailingId = CertificateMailingId, FirstName = FirstName, LastName = LastName, Suffix = Suffix, Title = Title, Company = Company, Address1 = Address1, Address2 = Address2, City = City, State = State, Zip = Zip, Country = Country, Phone = Phone, Fax = Fax, Email = Email, Original = Original }; List <CertificateMailing> mailingList = new ContactsRepository().SaveMailingRecipient(cert, this.User.UserId); mailingList.Add(new CertificateMailing { CertificateMailingId = -1, FilmSubmissionId = FilmSubmissionId, Suffix = "" }); ViewBag.Message = "The Contact has been saved"; return(View("Contacts", mailingList)); }
public IHttpActionResult Create([FromBody] Contacts item) { if (item == null) { return(BadRequest("Contacts cannot be null")); } ContactsRepo.Add(item); return(CreatedAtRoute("GetById", new { id = item.MobilePhone }, item)); }
/// <summary> /// Retrieves the list of all Certificate Mailing (Right Holder) Recipients info by the film Id /// </summary> /// <param name="filmId"></param> /// <returns></returns> public ActionResult GetMailingList(int filmId) { List <CertificateMailing> mailingList = new ContactsRepository().GetMailingList(filmId); mailingList.Add(new CertificateMailing { CertificateMailingId = -1, FilmSubmissionId = filmId, Suffix = "" }); return(View("Contacts", mailingList)); }
private void Button_Click(object sender, RoutedEventArgs e) { var contact = new Contact() { FirstName = "New", LastName = "", PhoneNumber = "" }; contactListView.Items.Add(contact); repository.Add(contact); }
public ActionResult Create(Contact contact) { if (ModelState.IsValid) { repo.Add(contact); repo.SaveChanges(); return(RedirectToAction("Index")); } return(View(contact)); }
public ActionResult DeleteRecipient(int FilmSubmissionId, int CertificateMailingId) { CertificateMailing cert = new CertificateMailing { FilmSubmissionId = FilmSubmissionId, CertificateMailingId = CertificateMailingId }; List <CertificateMailing> mailingList = new ContactsRepository().DeleteMailingRecipient(cert, this.User.UserId); mailingList.Add(new CertificateMailing { CertificateMailingId = -1, FilmSubmissionId = cert.FilmSubmissionId, Suffix = "" }); ViewBag.Message = "The Contact has been deleted"; return(View("Contacts", mailingList)); }
public void Add() { //Arrange var streamCreator = new Mock <IContactsStreamCreator>(); streamCreator.Setup(creator => creator.OpenForRead()).Returns(new MemoryStream()); var contactsRepository = new ContactsRepository(streamCreator.Object); //Act contactsRepository.Add(new Contact()); //Asserts Assert.AreEqual(1, contactsRepository.GetCount()); }
static void Main(string[] args) { string key = "AKIA4K2QXU557RGJTE4F"; string secret = "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"; ContactsRepository repo = new ContactsRepository(key, secret); var contact = new Contact(); contact.MobileNumber = "084294738947289"; contact.OtherDetails = new System.Collections.Specialized.NameValueCollection(); contact.OtherDetails.Add("Name", "Jalaluddin"); contact.OtherDetails.Add("BirthDate", "2/2/2001"); repo.Add(contact); }
public async Task <ActionResult> AddContact(ContactModel contact) { try { if (ModelState.IsValid) { ContactsRepository contactRepo = new ContactsRepository(); if (await contactRepo.Add(contact)) { ViewBag.Message = "Contact details added successfully"; } } return(View()); } catch { return(View("Error")); } }
public void Show() { Console.WriteLine("[1] Change your password"); Console.WriteLine("[2] Delete your account"); Console.WriteLine("[3] Add contact"); int choice = Int32.Parse(Console.ReadLine()); UsersManagerOptions option = (UsersManagerOptions)choice; UserRepository userRepository = new UserRepository(); ContactsRepository contactRepository = new ContactsRepository(); switch (option) { case UsersManagerOptions.Update: { userRepository.Update(); } break; case UsersManagerOptions.Delete: { userRepository.Delete(); } break; case UsersManagerOptions.AddContact: { contactRepository.Add(); } break; default: Console.WriteLine("Invalid choice. Please try again! (Press any key to continue)"); Console.ReadKey(true); Console.Clear(); break; } }
public Contact Post([FromBody] AddContactDTO contact) { var addedUser = _contactsRepository.Add(contact); return(addedUser); }