public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/contacts"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["contacts.cshtml", allContacts]);
     };
     Get["/contacts/new"] = _ => {
         return(View["contact_form.cshtml"]);
     };
     Get["/contacts/{id}"] = parameters => {
         Contact contact = Contact.Find(parameters.id);
         return(View["/contact.cshtml", contact]);
     };
     Post["/contacts"] = _ => {
         Contact        newContact  = new Contact(Request.Form["contact-name"], Request.Form["contact-address"], Request.Form["contact-phone"]);
         List <Contact> allContacts = Contact.GetAll();
         return(View["contacts.cshtml", allContacts]);
     };
     Post["/contacts/clear"] = _ => {
         Contact.ClearAll();
         return(View["contacts_cleared.cshtml"]);
     };
 }
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.html"]);
            };

            Get["/contacts"] = _ => {
                List <Contact> allContacts = Contact.GetAll();
                return(View["contacts.cshtml", allContacts]);
            };

            Get["/contacts/new"] = _ => {
                return(View["add_new_contact"]);
            };

            Post["/contacts/added"] = _ => {
                Contact newContact = new Contact((Request.Form["name"]), (Request.Form["phoneNumber"]), (Request.Form["address"]));
                return(View["contact_created.cshtml", newContact]);
            };

            Get["/contacts/{id}"] = parameters => {
                Contact selectedContact = Contact.Find(parameters.id);
                return(View["contact_details.cshtml", selectedContact]);
            };

            Get["/contacts/cleared"] = _ => {
                Contact.ClearAll();
                return(View["contacts_deleted.cshtml"]);
            };
        }
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/add_new_contact"] = _ => {
         return(View["add_new_contact.cshtml"]);
     };
     Post["/added"] = _ => {
         string  name        = (Request.Form["name"]);
         string  phonenumber = (Request.Form["phonenumber"]);
         string  address     = (Request.Form["address"]);
         Contact newContact  = new Contact(name, phonenumber, address);
         newContact.Save();
         return(View["contact_created.cshtml", newContact]);
     };
     Get["/view_all_contacts"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["view_all_contacts.cshtml", allContacts]);
     };
     Post["/contacts_deleted"] = _ => {
         Contact.ClearAll();
         return(View["contacts_deleted.cshtml"]);
     };
 }
Beispiel #4
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["index.cshtml", allContacts]);
     };
     Get["/contact_details/{id}"] = parameters => {
         Contact contact = Contact.Find(parameters.id);
         return(View["contact_details.cshtml", contact]);
     };
     Get["/contact_form"] = _ => {
         return(View["contact_form.cshtml"]);
     };
     Get["/view_all_contacts"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["view_all_contacts.cshtml", allContacts]);
     };
     Post["/contact_added"] = _ => {
         Contact newContact = new Contact(Request.Form["new-name"], Request.Form["new-phone"], Request.Form["new-address-street"], Request.Form["new-city-state"]);
         return(View["contact_added.cshtml", newContact]);
     };
     Post["/contacts_cleared"] = _ => {
         Contact.ClearAll();
         return(View["contacts_cleared.cshtml"]);
     };
 }
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                List <Contact> allContacts = Contact.GetAll();
                return(View["index.cshtml", allContacts]);
            };

            Get["/contact/detail"] = _ => View["contact-detail.cshtml"];

            Get["/contact/form"] = _ => View["contact-form.cshtml"];

            Post["/contact/new"] = _ =>
            {
                Contact contact = new Contact(Request.Form["name"], Request.Form["phone"], Request.Form["address"]);
                return(View["new-contact.cshtml", contact]);
            };

            Get["/contact/{id}"] = parameters =>
            {
                Contact person = Contact.Find(parameters.id);
                return(View["contact-detail.cshtml", person]);
            };

            Post["/contacts/clear"] = _ =>
            {
                Contact.ClearAll();
                return(View["clear-all.cshtml"]);
            };
        }
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["index.cshtml", allContacts]);
     };
     Get["/contact"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["contact.cshtml", allContacts]);
     };
     Get["/contact/new"] = _ => {
         return(View["contact_new_form.cshtml"]);
     };
     Get["/contact/{id}"] = parameters => {
         Contact contact = Contact.Find(parameters.id);
         return(View["contact.cshtml", contact]);
     };
     Get["/contact/contact_search"] = _ => {
         return(View["contact_search.cshtml"]);
     };
     Post["/contact/contact_search_form"] = _ => {
         string         searchContact    = Request.Form["searched_contact"];
         List <Contact> allContacts      = Contact.GetAll();
         List <int>     returnedContacts = Contact.ContactExists(searchContact);
         if (returnedContacts.Count > 0)
         {
             List <Contact> foundContact = Contact.SearchContacts(searchContact);
             return(View["contact_search_result.cshtml", foundContact]);
         }
         else
         {
             return(View["no_contacts.cshtml"]);
         }
     };
     Get["/contact/clear"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         Contact.ClearAll();
         return(View["index.cshtml", allContacts]);
     };
     Get["/deletecontact/{id}"] = parameters => {
         Contact contact = Contact.Find(parameters.id);
         Contact.DeleteContact(contact);
         List <Contact> allContacts = Contact.GetAll();
         return(View["index.cshtml", allContacts]);
     };
     Post["/contact"] = _ => {
         string  newName    = Request.Form["new_contact_name"];
         string  newPhone   = Request.Form["new_phone_number"];
         string  newEmail   = Request.Form["new_email"];
         string  newAddress = Request.Form["new_address"];
         Contact newContact = new Contact(newName, newPhone, newEmail, newAddress);
         return(View["contact.cshtml", newContact]);
     };
 }
Beispiel #7
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Contact> allContacts = Contact.GetAll();
                return(View["index.cshtml", allContacts]);
            };
            Get["/contacts/new"] = _ => {
                return(View["new_contact_form.cshtml"]);
            };
            Post["/contacts/added"] = _ => {
                string inputFirstName   = Request.Form["name-first"];
                string inputLastName    = Request.Form["name-last"];
                string inputPhoneNumber = Request.Form["phone-number"];

                string inputAddressStreet = Request.Form["address-street"];
                string inputAddressCity   = Request.Form["address-city"];
                string inputAddressState  = Request.Form["address-state"];
                string inputAddressZip    = Request.Form["address-zip"];

                Address newContactAddress = new Address(inputAddressStreet, inputAddressCity, inputAddressState, inputAddressZip);
                Contact newContact        = new Contact(inputFirstName, inputLastName, inputPhoneNumber, newContactAddress);

                return(View["contact_added.cshtml", newContact]);
            };
            Get["/contacts/{id}"] = parameters => {
                Contact selectedContact = Contact.FindById(parameters.id);
                return(View["contact.cshtml", selectedContact]);
            };
            Get["/contacts/all"] = _ => {
                List <Contact> allContacts = Contact.GetAll();
                return(View["contacts_all.cshtml", allContacts]);
            };
            Post["/"] = _ => {
                Contact.ClearAll();
                List <Contact> allContacts = Contact.GetAll();
                return(View["index.cshtml", allContacts]);
            };
            Post["/contacts/deleted"] = _ => {
                int     targetId        = int.Parse(Request.Form["delete"]);
                Contact selectedContact = Contact.FindById(targetId);
                selectedContact.DeleteContact();
                Contact.ResetIds();
                return(View["contact_removed.cshtml"]);
            };
            Get["contacts/search"] = _ => {
                return(View["contacts_search.cshtml"]);
            };
            Get["contacts/search-results"] = _ => {
                string         searchInput      = Request.Query["search-input"];
                string         searchInputLower = searchInput.ToLower();
                List <Contact> searchResults    = Contact.SearchFor(searchInputLower);
                return(View["search_results.cshtml", searchResults]);
            };
        }
Beispiel #8
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml", Contact.GetAll()]);
            };

            Get["/contact/new"] = _ => {
                return(View["contact_form.cshtml"]);
            };

            Post["/contact/new"] = _ => {
                if (Request.Form["name"] == "")
                {
                    string  noName     = "No Name";
                    Contact newContact = new Contact(noName, Request.Form["phone"], Request.Form["address"]);
                    return(View["new_contact.cshtml", newContact]);
                }
                else
                {
                    Contact newContact = new Contact(Request.Form["name"], Request.Form["phone"], Request.Form["address"]);
                    return(View["new_contact.cshtml", newContact]);
                }
            };

            Get["/contact/{id}"] = parameters => {
                var currentContact = Contact.FindId(parameters.id);
                return(View["contact.cshtml", currentContact]);
            };

            Post["/{action}"] = parameters => {
                if (parameters.action == "clear")
                {
                    Contact.ClearAll();
                }
                return(View["clear.cshtml"]);
            };

            Post["/contact/"] = _ => {
                int contactId = Request.Form["contact-id"];
                Contact.RemoveContact(contactId);
                return(View["removed.cshtml"]);
            };

            Get["/contact/search"] = _ => {
                return(View["search.cshtml"]);
            };

            Post["/contact/search_result"] = _ => {
                string searchName    = Request.Form["search"];
                var    searchResults = Contact.SearchContact(searchName);
                return(View["results.cshtml", searchResults]);
            };
        }
Beispiel #9
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["index.cshtml", allContacts]);
     };
     Get["/contact/form"] = _ => View["contact_form.cshtml"];
     Post["/contact/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var           newContact          = new Contact(Request.Form["name"]);
         List <Number> contactNumbers      = newContact.GetNumbers();
         var           newNumber           = new Number(Request.Form["number"]);
         contactNumbers.Add(newNumber);
         List <Address> contactAddresses = newContact.GetAddresses();
         var            newAddress       = new Address(Request.Form["first-line"], Request.Form["city"], Request.Form["state"], Request.Form["zip"]);
         contactAddresses.Add(newAddress);
         model.Add("numbers", contactNumbers);
         model.Add("addresses", contactAddresses);
         model.Add("contact", newContact);
         return(View["contact.cshtml", model]);
     };
     //Search functionality does not work, but I would love it to.
     Get["/contacts/search"] = _ => {
         string  searchString        = (Request.Form["search-string"]);
         Contact searchResultContact = Contact.Search(searchString);
         return(View["search_results.cshtml", searchResultContact]);
     };
     Get["/contacts/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Contact        selectedContact    = Contact.Find(parameters.id);
         List <Number>  allNumbers         = selectedContact.GetNumbers();
         List <Address> allAddresses       = selectedContact.GetAddresses();
         model.Add("numbers", allNumbers);
         model.Add("addresses", allAddresses);
         model.Add("contact", selectedContact);
         return(View["contact.cshtml", model]);
     };
     Post["/contacts/clear"] = _ => {
         Contact.ClearAll();
         return(View["contacts_clear.cshtml"]);
     };
 }
Beispiel #10
0
        public HomeModule()
        {
            Get["/"] = _ => {
                var allContacts = Contact.GetAll();
                return(View["index.cshtml", allContacts]);
            };

            Post["/contact/success"] = _ => {
                var newContact = new Contact(Request.Form["contact-name"], Request.Form["contact-phone-number"], Request.Form["contact-address"]);
                newContact.SaveContact();
                return(View["contact_added.cshtml", newContact]);
            };

            Get["/contact/new"] = _ => {
                return(View["add_contact_form.cshtml"]);
            };

            Get["/contact/{id}"] = parameters => {
                Contact contact = Contact.Find(parameters.id);
                return(View["view_contact.cshtml", contact]);
            };

            Post["/contact/clear"] = _ => {
                Contact.ClearAll();
                return(View["contact_clear.cshtml"]);
            };

            Post["/contact/{id}/remove"] = parameters => {
                Contact contact = Contact.Find(parameters.id);
                contact.RemoveContact();
                return(View["remove_contact.cshtml"]);
            };

            Get["/search"] = _ => {
                return(View["search_form.cshtml"]);
            };

            Post["/search_results"] = _ => {
                Contact selectedContact = Contact.SearchContact(Request.Form["search"]);
                return(View["view_contact.cshtml", selectedContact]);
            };
        }
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["address_book.cshtml", allContacts]);
     };
     Get["/new_contact"]   = _ => View["contact.cshtml"];
     Get["/contacts/{id}"] = parameters => {
         Contact contact = Contact.Find(parameters.id);
         return(View["/view_contact.cshtml", contact]);
     };
     Post["/contact_added"] = _ => {
         Contact newContact = new Contact(Request.Form["firstname"], Request.Form["lastname"], Request.Form["phoneNumber"], Request.Form["address"]);
         return(View["contact_added.cshtml", newContact]);
     };
     Get["/contacts_cleared"] = _ => {
         Contact.ClearAll();
         return(View["contacts_cleared.cshtml"]);
     };
 }
Beispiel #12
0
 public HomeModule()
 {
     Get["/"] = _ => {
         var allContacts = Contact.GetAll();
         return(View["index.cshtml", allContacts]);
     };
     Get["/contacts/new"] = _ => {
         return(View["contact_form.cshtml"]);
     };
     Post["/contact"] = _ => {
         Address newAddress = new Address(Request.Form["street"], Request.Form["city"], Request.Form["state"], Request.Form["zip"]);
         Contact newContact = new Contact(Request.Form["first-name"], Request.Form["last-name"], Request.Form["phone"], newAddress);
         return(View["contact_added.cshtml", newContact]);
     };
     Get["/contacts/{id}"] = parameters => {
         Contact requestedContact = Contact.Find(parameters.id);
         return(View["contact.cshtml", requestedContact]);
     };
     Post["/contacts/clear"] = _ => {
         Contact.ClearAll();
         return(View["address_book_clear.cshtml"]);
     };
     Post["/contacts/search"] = _ => {
         var    allContacts      = Contact.GetAll();
         var    matchingContacts = new List <Contact>();
         string searchString     = Request.Form["search"];
         searchString = searchString.ToLower();
         foreach (var contact in allContacts)
         {
             string firstName = contact.GetFirstName();
             string lastName  = contact.GetLastName();
             lastName  = lastName.ToLower();
             firstName = firstName.ToLower();
             if (firstName.Contains(searchString) || lastName.Contains(searchString))
             {
                 matchingContacts.Add(contact);
             }
         }
         return(View["search_results.cshtml", matchingContacts]);
     };
 }
Beispiel #13
0
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                if (Contact.GetCounter() == 0)
                {
                    return(View["none.cshtml"]);
                }
                else
                {
                    return(View["index.cshtml", Contact.ContactList()]);
                }
            };

            Get["/contacts-view/{id}"] = parameters =>
            {
                Contact newContact = Contact.Find(parameters.id);
                return(View["view.cshtml", newContact]);
            };

            Post["/contacts-new"] = _ =>
            {
                Contact newContact = new Contact(Request.Form["contact-name"], Request.Form["contact-phone-number"], Request.Form["contact-address"]);
                return(View["new.cshtml"]);
            };

            Post["/contacts-clear"] = _ =>
            {
                int contactIndex = int.Parse(Request.Form["delete-button"]);
                Contact.DeleteContact(contactIndex);

                List <Contact> newList = Contact.ContactList();
                return(View["clear.cshtml", newList]);
            };

            Post["/contacts-clear-all"] = _ =>
            {
                Contact.ClearAll();
                return(View["clearall.cshtml"]);
            };
        }
Beispiel #14
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };
            Get["/add_new_friend"] = _ => {
                return(View["friend-form.cshtml"]);
            };

            Get["/friends_list"] = _ => {
                List <Contact> allContacts = Contact.GetAll();
                return(View["friend-list.cshtml", allContacts]);
            };

            Post["/contact_created"] = _ => {
                Contact newContact = new Contact(Request.Form["friend-name"], Request.Form["friend-desc"], Request.Form["friend-address"], Request.Form["friend-phone"], Request.Form["friend-email"]);
                return(View["friend.cshtml", newContact]);
            };

            Post["/friend/new"] = _ => {
                Contact        newContact  = new Contact(Request.Form["friend-name"], Request.Form["friend-desc"], Request.Form["friend-address"], Request.Form["friend-phone"], Request.Form["friend-email"]);
                List <Contact> allContacts = Contact.GetAll();
                return(View["friend-list.cshtml", allContacts]);
            };

            Get["/friend/{id}"] = parameters => {
                Contact selectedContact = Contact.Find(parameters.id);
                return(View["friend.cshtml", selectedContact]);
            };
            Get["/contacts_deleted"] = _ => {
                Contact.ClearAll();
                return(View["friends-cleared.cshtml"]);
            };
            Get["/clear_friend/{id}"] = parameters => {
                List <Contact> allContacts = Contact.GetAll();
                allContacts.RemoveAt(parameters.id - 1);
                Contact.RefreshIds(allContacts);
                return(View["friend-list.cshtml", allContacts]);
            };
        }
Beispiel #15
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["index.cshtml", allContacts]);
     };
     Get["/contact/add"] = _ => {
         return(View["add_contact.cshtml"]);
     };
     Post["/contact/add"] = _ => {
         Contact newContact = new Contact(Request.Form["add-contact"], Request.Form["add-phoneNumber"], Request.Form["add-address"]);
         return(View["new_contact_confirmation.cshtml", newContact]);
     };
     Get["/contacts/{id}"] = parameters => {
         Contact contact = Contact.Find(parameters.id);
         return(View["contact_info.cshtml", contact]);
     };
     Post["/contacts/clear"] = _ => {
         Contact.ClearAll();
         return(View["cleared.cshtml"]);
     };
 }
Beispiel #16
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["homepage.cshtml"]);
     };
     Get["/add_new_contact"] = _ => {
         return(View["add_new_contact.cshtml"]);
     };
     Post["/contact_created"] = _ => {
         Contact newContact = new Contact(Request.Form["new-name"], Request.Form["new-phoneNumber"], Request.Form["new-address"]);
         newContact.Save();
         return(View["contact_created.cshtml", newContact]);
     };
     Get["/view_all_contacts"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View ["view_all_contacts.cshtml", allContacts]);
     };
     Post["/all_contacts_deleted"] = _ => {
         Contact.ClearAll();
         return(View["all_contacts_deleted.cshtml"]);
     };
 }
Beispiel #17
0
 public HomeModule()
 {
     Get["/"] = _ => {
         var allContacts = Contact.GetAll();
         return(View["index.cshtml", allContacts]);
     };
     Get["contact/{id}"] = parameters => {
         var contact = Contact.Find(parameters.id);
         return(View["view_one_contact.cshtml", contact]);
     };
     Get["/contact/new_contact"] = _ => {
         return(View["contact_form.cshtml"]);
     };
     Post["/contact/view_new_contact"] = _ => {
         Contact        newContact  = new Contact(Request.Form["new-name"], Request.Form["new-number"], Request.Form["new-address"]);
         List <Contact> allContacts = Contact.GetAll();
         return(View["view_new_contact.cshtml", newContact]);
     };
     Post["/contact/clear_contacts"] = _ => {
         Contact.ClearAll();
         return(View["clear_contacts.cshtml"]);
     };
 }
Beispiel #18
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Contact> allContacts = Contact.GetAll();
         return(View["contacts.cshtml", allContacts]);
     };
     Get["/contacts/new"] = _ => {
         return(View["contact_form.cshtml"]);
     };
     Get["/contact/{id}"] = parameters => {
         Contact selectedContact = Contact.Find(parameters.id);
         return(View["contact.cshtml", selectedContact]);
     };
     Get["/contact/delete/{id}"] = parameters => {
         Contact.Delete(parameters.id);
         List <Contact> allContacts = Contact.GetAll();
         return(View["contacts.cshtml", allContacts]);
     };
     Get["/contacts/search_form"] = _ => {
         return(View["search_form.cshtml"]);
     };
     Get["/contacts/search/{suggestion}"] = parameters => {
         string         userQuery        = parameters.suggestion;
         List <Contact> searchedContacts = Contact.Search(userQuery);
         if (searchedContacts.Count > 0)
         {
             return(View["contacts_searched.cshtml", searchedContacts]);
         }
         else
         {
             List <string> searchSuggestions = Contact.SuggestSearch(userQuery);
             return(View["search_suggestions.cshtml", searchSuggestions]);
         }
     };
     Post["/contact/new"] = _ => {
         string  contactName  = Request.Form["contact-name"];
         string  contactPhone = Request.Form["contact-phone"];
         Contact newContact   = new Contact(contactName, contactPhone);
         return(View["contact_made.cshtml", newContact]);
     };
     Post["/contacts/new_address_or_not/{id}"] = parameters => {
         string  addressOrNot    = Request.Form["address-or-not"];
         Contact selectedContact = Contact.Find(parameters.id);
         Address noAddress       = new Address("No Address", "", "", "");
         selectedContact.SetAddress(noAddress);
         if (addressOrNot == "return")
         {
             List <Contact> allContacts = Contact.GetAll();
             return(View["contacts.cshtml", allContacts]);
         }
         else
         {
             return(View["contact_address_form.cshtml", selectedContact]);
         }
     };
     Post["/contact/new_address/{id}"] = parameters => {
         string  contactStreet = Request.Form["contact-street"];
         string  contactApt    = Request.Form["contact-apt"];
         string  contactCity   = Request.Form["contact-city"];
         string  contactState  = Request.Form["contact-state"];
         string  contactZip    = Request.Form["contact-zip"];
         Address newAddress    = new Address(contactStreet, contactCity, contactState, contactZip);
         newAddress.AddStreet(contactApt);
         Contact selectedContact = Contact.Find(parameters.id);
         selectedContact.SetAddress(newAddress);
         return(View["address-added.cshtml", selectedContact]);
     };
     Post["/contacts/clear"] = _ => {
         Contact.ClearAll();
         return(View["contacts_clear.cshtml"]);
     };
     Post["/contacts/search"] = _ => {
         string         userQuery        = Request.Form["user-query"];
         List <Contact> searchedContacts = Contact.Search(userQuery);
         if (searchedContacts.Count > 0)
         {
             return(View["contacts_searched.cshtml", searchedContacts]);
         }
         else
         {
             List <string> searchSuggestions = Contact.SuggestSearch(userQuery);
             return(View["search_suggestions.cshtml", searchSuggestions]);
         }
     };
 }