public void DisplayContent(CustomerContent content) { Console.WriteLine($"FirstName: {content.FirstName}"); Console.WriteLine($"LastName: {content.LastName}"); Console.WriteLine($"Customer Type: {content.Type}"); Console.WriteLine($"Email Message: {content.Email}"); }
public void AddNewCustomer() { Console.Clear(); CustomerContent newContent = new CustomerContent(); Console.WriteLine("Please enter a first name."); newContent.FirstName = Console.ReadLine(); Console.WriteLine("Please enter a last name."); newContent.LastName = Console.ReadLine(); Console.WriteLine("Please enter a type for this customer.\n" + "1. Potential.\n" + "2. Current.\n" + "3. Past."); newContent.Type = Console.ReadLine(); Console.WriteLine("Please enter message to be sent to customer email.\n" + " A.We currently have the lowest rates on Helicopter Insurance!\n" + " B.Thank you for your work with us. We appreciate your loyalty. Here's a coupon.\n" + " C.It's been a long time since we've heard from you, we want you back"); newContent.Email = Console.ReadLine(); bool wasAdded = _repo.AddContentToDirectory(newContent); if (wasAdded == true) { Console.WriteLine("Your content was succesfully added."); } else { Console.WriteLine("Oops something went wrong. Your content was not added."); } }
public void DisplayContent(CustomerContent content) { Console.WriteLine($"Title: {content.FirstName}"); Console.WriteLine($"Description: {content.LastName}"); Console.WriteLine($"Star Rating: {content.Type}"); Console.WriteLine($"Maturity Rating: {content.Email}"); }
private void ApplyCustomerContentPart(IDictionary <string, object> model, CustomerContent content, MessageContext ctx) { model["CustomerId"] = content.CustomerId; model["IpAddress"] = content.IpAddress; model["CreatedOn"] = ToUserDate(content.CreatedOnUtc, ctx); model["UpdatedOn"] = ToUserDate(content.UpdatedOnUtc, ctx); }
private void UpdateCustomerContent() // UPDATE CUSTOMER INFO { Console.Clear(); ViewAllContent(); Console.WriteLine("\nEnter the full name of the customer to edit their profile:"); string oldName = Console.ReadLine().ToLower(); CustomerContent newContent = new CustomerContent(); Console.WriteLine("Enter customer first name:"); newContent.FirstName = Console.ReadLine(); Console.WriteLine("Enter customer last name:"); newContent.LastName = Console.ReadLine(); Console.WriteLine("Enter customer type (1-3):\n" + "1) Current\n" + "2) Past\n" + "3) Potential"); string typeAsString = Console.ReadLine(); int typeAsInt = int.Parse(typeAsString); newContent.TypeOfCustomer = (CustomerType)typeAsInt; Console.WriteLine("\nEmail text for this customer:"); if (typeAsInt == 1) { Console.WriteLine("Thank you for your work with us. We appreciate your loyalty. Here's a coupon."); newContent.Email = "Thank you for your work with us. We appreciate your loyalty. Here's a coupon."; } else if (typeAsInt == 2) { Console.WriteLine("It's been a long time since we've heard from you, we want you back."); newContent.Email = "It's been a long time since we've heard from you, we want you back."; } else if (typeAsInt == 3) { Console.WriteLine("We currently have the lowest rates on Helicopter Insurance!"); newContent.Email = "We currently have the lowest rates on Helicopter Insurance!"; } else { Console.WriteLine("Could not generate email text due to input error."); } _contentRepo.AddContentToList(newContent); bool wasUpdated = _contentRepo.UpdateCustomerContent(oldName, newContent); if (wasUpdated) { Console.WriteLine("\nCustomer profile successfully updated."); } else { Console.WriteLine("\nCould not update customer profile."); } }
public virtual void UpdateCustomerContent(CustomerContent content) { if (content == null) { throw new ArgumentNullException("content"); } _contentRepository.Update(content); }
public void AddToDirectory_ShouldGetCorrectBoolean() { CustomerContent content = new CustomerContent(); CustomerContent_Repo repository = new CustomerContent_Repo(); bool addResult = repository.AddContentToDirectory(content); Assert.IsTrue(addResult); }
private void SeedContentList() { CustomerContent jakeSmith = new CustomerContent("Jake", "Smith", CustomerType.Potential, "We currently have the lowest rates on Helicopter Insurance!", "Jake Smith"); CustomerContent jamesSmith = new CustomerContent("James", "Smith", CustomerType.Current, "Thank you for your work with us. We appreciate your loyalty. Here's a coupon.", "James Smith"); CustomerContent janeSmith = new CustomerContent("Jane", "Smith", CustomerType.Past, "It's been a long time since we've heard from you, we want you back.", "Jane Smith"); _contentRepo.AddContentToList(jakeSmith); _contentRepo.AddContentToList(jamesSmith); _contentRepo.AddContentToList(janeSmith); }
/// <summary> /// Deletes a customer content /// </summary> /// <param name="content">Customer content</param> public virtual void DeleteCustomerContent(CustomerContent content) { if (content == null) { throw new ArgumentNullException("content"); } _contentRepository.Delete(content); //event notification _eventPublisher.EntityDeleted(content); }
public void AddNewCustomer() { Console.Clear(); CustomerContent newContent = new CustomerContent(); Console.WriteLine("Please enter a first name."); newContent.FirstName = Console.ReadLine(); Console.WriteLine("Please enter a last name."); newContent.LastName = Console.ReadLine(); Console.WriteLine("Please enter a type for this customer."); newContent.Type = Console.ReadLine(); Console.WriteLine("Please enter message to be sent to customer email."); newContent.Email = Console.ReadLine(); }
public void GetDirectory_ShouldReturnCorrectCollection() { CustomerContent content = new CustomerContent(); CustomerContent_Repo repo = new CustomerContent_Repo(); repo.AddContentToDirectory(content); List <CustomerContent> contents = repo.GetContents(); bool directoryHasContent = contents.Contains(content); Assert.IsTrue(directoryHasContent); }
public void UpdateExistingContent() { Console.Clear(); Console.WriteLine("Enter the name of the person's data you'd like to update."); string firstName = Console.ReadLine(); CustomerContent oldItem = _repo.FindPersonByName(firstName); if (oldItem == null) { Console.WriteLine("Person not found, press any key to continue..."); Console.ReadKey(); return; } CustomerContent newItem = new CustomerContent( oldItem.FirstName, oldItem.LastName, oldItem.Type, oldItem.Email ); Console.WriteLine("Which property would you like to update:\n" + "1. First Name\n" + "2. Last Name\n" + "3. Type\n" + "4. Email Message\n" + "6. Nevermind"); string selection = Console.ReadLine(); switch (selection) { case "1": Console.WriteLine("Enter a new title"); string newFirstName = Console.ReadLine(); newItem.FirstName = newFirstName; bool wasSuccessful = _repo.UpdateExistingContent(firstName, newItem); if (wasSuccessful) { Console.WriteLine("Name successfully updated"); } else { Console.WriteLine($"Error: Could not update {firstName}"); } break; default: break; } }
public void GetByTitle_ShouldReturnCorrectContent() { //Arrange CustomerContent_Repo repo = new CustomerContent_Repo(); CustomerContent newContent = new CustomerContent("Toy Story", "Toys come to life", 10, Genre.Action, MaturityRating.PG); repo.AddContentToDirectory(newContent); string title = "Toy Story"; //Act CustomerContent searchResult = repo.GetContentByTitle(title); //Assert Assert.AreEqual(searchResult.Title, title); }
public void DeleteExistingContent_ShouldReturnTrue() { //Arrange CustomerContent_Repo repo = new CustomerContent_Repo(); CustomerContent content = new CustomerContent("Toy Story", "Toys come to life", 10, Genre.Action, MaturityRating.PG); repo.AddContentToDirectory(content); //Act CustomerContent oldcontent = repo.GetContentByTitle("Toy Story"); bool removeResult = repo.DeleteExistingContent(oldcontent); //Assert Assert.IsTrue(removeResult); }
public void UpdateExistingContent_ShouldReturnTrue() { //Arrange CustomerContent_Repo repo = new CustomerContent_Repo(); CustomerContent oldContent = new CustomerContent("Toy Story", "Toys come to life", 10, Genre.Action, MaturityRating.PG); repo.AddContentToDirectory(oldContent); CustomerContent newContent = new CustomerContent("Toy Story", "Toys come to life", 10, Genre.Action, MaturityRating.PG); //Act bool updateResult = repo.UpdateExistingContent("Toy Story", newContent); //Assert Assert.IsTrue(updateResult); }
public void DeleteCustomerByName() { Console.WriteLine("Enter the name of the person you would like to delete"); string firstNameToDelete = Console.ReadLine(); CustomerContent contentToDelete = _repo.FindPersonByName(firstNameToDelete); bool wasDeleted = _repo.DeleteCustomerByName(contentToDelete); if (wasDeleted) { Console.WriteLine("This content was successfully deleted"); } else { Console.WriteLine("Person could not be deleted"); } }
public void AddCustomerContentTest() // ADD CUSTOMER TO EMAIL LIST TEST { //ARRANGE CustomerContent content = new CustomerContent(); GreetingRepository repo = new GreetingRepository(); List <CustomerContent> localList = repo.GetContentList(); // ACT int beforeCount = localList.Count; repo.AddContentToList(content); int actual = localList.Count; int expected = beforeCount + 1; //Assert Assert.AreEqual(expected, actual); }
public void FindCustomerByName() { Console.Clear(); Console.WriteLine("Enter the name of the person you'd like to find."); string firstName = Console.ReadLine(); CustomerContent content = _repo.FindPersonByName(firstName); if (content != null) { DisplayContent(content); } else { Console.WriteLine("That person doesn't exist"); } }
public void UpdateCustomerContentTest() // EDIT CUSTOMER CONTENT TEST { // ARRANGE GreetingRepository repo = new GreetingRepository(); CustomerContent oldContent = new CustomerContent("Gandalf", "Thegrey", CustomerType.Potential, "We currently have the lowest rates on Helicopter Insurance!", "Gandalf Thegrey"); repo.AddContentToList(oldContent); CustomerContent updatedcontent = new CustomerContent("Tom", "Bombadill", CustomerType.Past, "It's been a long time since we've heard from you, we want you back.", "Tom Bombadill"); string name = "gandalf thegrey"; //ACT bool result = repo.UpdateCustomerContent(name, updatedcontent); //ASSERT Assert.IsTrue(result); }
private void ViewContentByName() // SEARCH CUSTOMER BY NAME { Console.Clear(); Console.WriteLine("\nEnter the full name of the customer to access their profile:"); string fullName = Console.ReadLine().ToLower(); CustomerContent content = _contentRepo.GetCustomerByName(fullName); if (content != null) { Console.WriteLine("{0,-10} {1, -10} {2, -10} {3, -20}", "FirstName", "LastName", "Type", "Email"); Console.WriteLine("{0,-10} {1, -10} {2, -10} {3, -20}", $"{content.FirstName}", $"{content.LastName}", $"{content.TypeOfCustomer}", $"{content.Email}"); } else { Console.WriteLine("No customer by that name."); } }
public void Can_save_and_load_customerContent() { var customerContent = new CustomerContent { IpAddress = "192.168.1.1", IsApproved = true, CreatedOnUtc = new DateTime(2010, 01, 01), UpdatedOnUtc = new DateTime(2010, 01, 02), Customer = GetTestCustomer() }; var fromDb = SaveAndLoadEntity(customerContent); fromDb.ShouldNotBeNull(); fromDb.IpAddress.ShouldEqual("192.168.1.1"); fromDb.IsApproved.ShouldEqual(true); fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01)); fromDb.UpdatedOnUtc.ShouldEqual(new DateTime(2010, 01, 02)); fromDb.Customer.ShouldNotBeNull(); }
private void CreateSingleEmail() { Console.Clear(); ViewAllContent(); Console.WriteLine("\nEnter the full name of the customer you wish to email:"); string fullName = Console.ReadLine().ToLower(); CustomerContent content = _contentRepo.GetCustomerByName(fullName); if (content != null) { Console.WriteLine("{0,-10} {1, -10} {2, -10} {3, -20}", "FirstName", "LastName", "Type", "Email"); Console.WriteLine("{0,-10} {1, -10} {2, -10} {3, -20}", $"{content.FirstName}", $"{content.LastName}", $"{content.TypeOfCustomer}", $"{content.Email}"); } else { Console.WriteLine("No customer by that name."); } Console.WriteLine("\nPress any key to send an email to the above customer..."); Console.ReadKey(); Console.WriteLine("\nError 482 - Komodo Insurance lacks the infrastructure to email customers as this time."); }
public virtual void UpdateCustomerContent(CustomerContent content) { Guard.NotNull(content, nameof(content)); _contentRepository.Update(content); }
public virtual void InsertCustomerContent(CustomerContent content) { Guard.NotNull(content, nameof(content)); _contentRepository.Insert(content); }