public ActionResult Contact() { // Modèle. var model = new ContactViewModel(); if (User.Identity.IsAuthenticated) { model.Name = User.Identity.Name; // IMPORTANT: On doit vérifier si la session n'a pas disparue. // Cf. la remarque en début de la classe MemberSession. var session = MemberSession.Value; if (session != null) { model.Email = session.Email; } } // Ontologie. Ontology.Title = Strings.Home_Contact_Title; Ontology.Description = Strings.Home_Contact_Description; Ontology.Relationships.CanonicalUrl = SiteMap.Contact(); Ontology.SchemaOrg.ItemType = SchemaOrgType.ContactPage; // LayoutViewModel. LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Contact()); LayoutViewModel.MainHeading = Strings.Home_Contact_MainHeading; LayoutViewModel.MainMenuCssClass = "contact"; return(View(Constants.ViewName.Home.Contact, model)); }
public ActionResult Contact(ContactViewModel model) { Require.NotNull(model, "model"); // Ontologie. Ontology.Title = Strings.Home_Contact_Title; Ontology.Description = Strings.Home_Contact_Description; Ontology.Relationships.CanonicalUrl = SiteMap.Contact(); Ontology.SchemaOrg.ItemType = SchemaOrgType.ContactPage; // LayoutViewModel. LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Contact()); LayoutViewModel.MainHeading = Strings.Home_Contact_MainHeading; LayoutViewModel.MainMenuCssClass = "contact"; if (!ModelState.IsValid) { return(View(Constants.ViewName.Home.Contact, model)); } _messenger.Publish(new NewContactMessage { EmailAddress = new MailAddress(model.Email, model.Name), MessageContent = model.Message, }); return(RedirectToRoute(Constants.RouteName.Home.ContactSuccess)); }