Exemplo n.º 1
0
 public HomeModule()
 {
     Get ["/"]             = _ => View ["index.cshtml"];
     Get ["/contacts/new"] = _ => View ["contact_form.cshtml"];
     Post ["/contact"]     = _ => {
         Contact newContact = new Contact
                              (
             Request.Form ["first-name"],
             Request.Form ["last-name"],
             Request.Form ["phone-number"],
             Request.Form ["email-address"],
             Request.Form ["street-address"],
             Request.Form ["state-address"]
                              );
         return(View ["contact_created.cshtml", newContact]);
     };
     Get ["/contacts"] = _ => {
         List <Contact> newContactList = Contact.GetAll();
         return(View ["contacts.cshtml", newContactList]);
     };
     Get ["/contacts/{id}"] = parameters => {
         Contact newContact = Contact.Find(parameters.id);
         return(View ["/contact_created.cshtml", newContact]);
     };
     Post ["/contacts/deleted"] = _ => {
         Contact.DeleteAll();
         return(View ["contacts_deleted.cshtml"]);
     };
 }
Exemplo n.º 2
0
        public HomeModule()
        {
            Get["/"] = _ => {
                var contacts = Contact.GetAll();
                return(View["index.cshtml", contacts]);
            };

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

            Post["/contacts/new"] = _ => {
                var address = new Address(
                    Request.Form["street"],
                    Request.Form["city"],
                    Request.Form["state"],
                    Request.Form["zip"]
                    );
                var contact = new Contact(
                    Request.Form["name"],
                    Request.Form["phoneNumber"],
                    address
                    );
                Contact.Save(contact);
                return(View["contact-created.cshtml", contact]);
            };
            Get["/contacts/{id}"] = parameters => {
                Contact contact = Contact.Find(parameters.id);
                return(View["contact-details.cshtml", contact]);
            };
            Get["/contacts/deleteAll"] = _ => {
                var contacts = Contact.GetAll();
                return(View["delete-contacts-form.cshtml", contacts]);
            };

            Post["/contacts/deleteAll"] = _ => {
                Contact.DeleteAll();
                return(View["contacts-deleted.cshtml"]);
            };
        }
 public HomeModule()
 {
     Get["/"] = _ => {
         var contacts = Contact.GetAll();
         return(View["index.cshtml", contacts]);
     };
     Get["/contact/new"] = _ => {
         return(View["contact_form.cshtml"]);
     };
     Get["/contact/{id}"] = parameters => {
         var searchedContact = Contact.Find(parameters.id);
         return(View["contact.cshtml", searchedContact]);
     };
     Post["/contact/new"] = _ => {
         var newContact = new Contact(Request.Form["contact-name"], Request.Form["phone-number"], Request.Form["contact-address"]);
         return(View["new_contact.cshtml", newContact]);
     };
     Post["/contact/clear"] = _ => {
         Contact.DeleteAll();
         return(View["contacts_cleared.cshtml"]);
     };
 }
Exemplo n.º 4
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/contacts"] = _ => {
         var allContacts = Contact.GetAll();
         return(View["contacts.cshtml", allContacts]);
     };
     Get["/contacts/new"] = _ => {
         return(View["contact_form.cshtml"]);
     };
     Post["/contact_created"] = _ => {
         var newContact = new Contact(Request.Form["new-firstName"], Request.Form["new-lastName"], Request.Form["new-phoneNumber"], Request.Form["new-streetAddress"], Request.Form["new-city"], Request.Form["new-state"], Request.Form["new-zipCode"]);
         newContact.Save();
         var allContacts = Contact.GetAll();
         return(View["contact_created.cshtml", newContact]);
     };
     Post["/contacts_deleted"] = _ => {
         Contact.DeleteAll();
         return(View["contacts_deleted.cshtml"]);
     };
 }