Пример #1
0
        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));
        }
Пример #2
0
        public ActionResult Register(string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToHome());
            }

#if SHOWCASE
            return(Redirect("~/go?targetUrl=" + returnUrl));
#else
            // Modèle.
            var model = new RegisterViewModel {
                ReturnUrl = returnUrl,
            };

            // Ontologie.
            Ontology.Title       = Strings.Account_Register_Title;
            Ontology.Description = Strings.Account_Register_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.Register();

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Register());
            LayoutViewModel.MainHeading      = Strings.Account_Register_MainHeading;
            LayoutViewModel.MainMenuCssClass = "register";

            return(View(Constants.ViewName.Account.Register, model));
#endif
        }
Пример #3
0
        public ActionResult Index()
        {
            // Modèle.
            var designers = _queries.ListDesigners(CultureInfo.CurrentUICulture);
            var patterns  = _queries.ListShowcasedPatterns();
            var model     = (from p in patterns
                             join d in designers on p.DesignerKey equals d.Key
                             select PatternViewItem.Of(p, d.DisplayName)).ToList();

            ShuffleList_(model);

            // Ontologie.
            Ontology.Title       = Strings.Home_Index_Title;
            Ontology.Description = Strings.Home_Index_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.Home();

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Home());
            if (User.Identity.IsAuthenticated)
            {
                LayoutViewModel.MainHeading = Strings.Home_Index_MainHeading;
            }

            LayoutViewModel.MainMenuCssClass = "index";

            return(View(Constants.ViewName.Home.Index, model));
        }
Пример #4
0
        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));
        }
Пример #5
0
        public ActionResult ContactSuccess()
        {
            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Contact());
            LayoutViewModel.MainHeading      = Strings.Home_ContactSuccess_MainHeading;
            LayoutViewModel.MainMenuCssClass = "contact";

            return(View(Constants.ViewName.Home.ContactSuccess));
        }
Пример #6
0
        public ActionResult Register(RegisterViewModel model)
        {
            Require.NotNull(model, "model");

            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToHome());
            }

            // Ontologie.
            Ontology.Title       = Strings.Account_Register_Title;
            Ontology.Description = Strings.Account_Register_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.Register();

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Register());
            LayoutViewModel.MainMenuCssClass = "register";
            LayoutViewModel.MainHeading      = Strings.Account_Register_MainHeading;

            if (!ModelState.IsValid)
            {
                return(View(Constants.ViewName.Account.Register, model));
            }

            _memberService.MemberCreated += (sender, e) =>
            {
                new AuthenticationService(HttpContext).SignIn(e.Member);
            };

            var result = _memberService.RegisterMember(new RegisterMemberRequest {
                CompanyName       = model.CompanyName,
                Email             = model.Email,
                FirstName         = model.FirstName,
                LastName          = model.LastName,
                NewsletterChecked = IsCheckBoxOn_(model.Newsletter),
            });

            if (result.IsBreak)
            {
                return(View(
                           Constants.ViewName.Account.RegisterFailure,
                           new RegisterFailureViewModel {
                    Message = result.Reason
                }));
            }

            string returnUrl = (from _ in ParseTo.Uri(model.ReturnUrl, UriKind.Relative) select _.ToString())
                               .ValueOrElse(String.Empty);

            return(RedirectToRoute(Constants.RouteName.Account.RegisterSuccess, new { returnUrl = returnUrl }));
        }
Пример #7
0
        public ActionResult Category(DesignerKey designerKey, string categoryKey, int p = 1)
        {
            // Modèle.
            var pagedList = _patternService.ListPreviews(designerKey, categoryKey, p, PreviewsPageSize_);

            if (pagedList == null)
            {
                return(new HttpNotFoundResult());
            }

            var designer = GetDesigner_(designerKey, categoryKey);
            var category = (from _ in designer.Categories where _.Key == categoryKey select _).Single();

            var model = new CategoryViewModel {
                Category    = category,
                Designer    = designer,
                IsFirstPage = pagedList.IsFirstPage,
                IsLastPage  = pagedList.IsLastPage,
                PageCount   = pagedList.PageCount,
                PageIndex   = pagedList.PageIndex,
                Previews    = from _ in pagedList.Previews select PatternViewItem.Of(_, designer.DisplayName)
            };

            // Ontologie.
            Ontology.Title = String.Format(
                CultureInfo.CurrentUICulture,
                Strings.Designer_Category_TitleFormat,
                model.Category.DisplayName,
                model.Designer.DisplayName);
            Ontology.Description = String.Format(
                CultureInfo.CurrentUICulture,
                Strings.Designer_Category_DescriptionFormat,
                model.Designer.DisplayName,
                model.Category.DisplayName);
            //Ontology.SchemaOrg.ItemType = SchemaOrgType.CollectionPage;
            Ontology.Relationships.CanonicalUrl = SiteMap.DesignerCategory(designerKey, categoryKey, p);

            var image = model.Previews.First();

            SetOpenGraphImage_(designerKey, image.Reference, image.Variant);

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.DesignerCategory(designerKey, categoryKey, p));
            LayoutViewModel.DesignerMenuCssClass = ViewUtility.DesignerClass(designerKey);
            LayoutViewModel.MainHeading          = category.DisplayName;

            return(View(Constants.ViewName.Designer.Category, model));
        }
Пример #8
0
        public ActionResult About()
        {
            // Modèle.
            var model = _queries.ListDesigners(CultureInfo.CurrentUICulture).OrderBy(_ => _.Nickname.ValueOrElse(_.LastName));

            // Ontologie.
            Ontology.Title       = Strings.Home_About_Title;
            Ontology.Description = Strings.Home_About_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.About();
            Ontology.SchemaOrg.ItemType         = SchemaOrgType.AboutPage;

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.About());
            LayoutViewModel.MainHeading      = Strings.Home_About_MainHeading;
            LayoutViewModel.MainMenuCssClass = "about";

            return(View(Constants.ViewName.Home.About, model));
        }
Пример #9
0
        public ActionResult RegisterSuccess(string returnUrl)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(Constants.RouteName.Account.Register));
            }

            string nextUrl = (from _ in ParseTo.Uri(returnUrl, UriKind.Relative) select _.ToString())
                             .ValueOrElse(Url.RouteUrl(Constants.RouteName.Home.Index));

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Register());
            LayoutViewModel.MainHeading      = Strings.Account_RegisterSuccess_MainHeading;
            LayoutViewModel.MainMenuCssClass = "register";

            return(View(Constants.ViewName.Account.RegisterSuccess, new RegisterSuccessViewModel {
                NextUrl = nextUrl
            }));
        }
Пример #10
0
        public ActionResult Index(DesignerKey designerKey, int p = 1)
        {
            // Modèle.
            var pagedList = _patternService.ListPreviews(designerKey, p, PreviewsPageSize_);

            if (pagedList == null)
            {
                return(new HttpNotFoundResult());
            }

            var designer = GetDesigner_(designerKey, AllCategoryKey);

            var model = new DesignerViewModel {
                Designer    = designer,
                IsFirstPage = pagedList.IsFirstPage,
                IsLastPage  = pagedList.IsLastPage,
                PageCount   = pagedList.PageCount,
                PageIndex   = pagedList.PageIndex,
                Previews    = from _ in pagedList.Previews select PatternViewItem.Of(_, designer.DisplayName)
            };

            // Ontologie.
            Ontology.Title = String.Format(
                CultureInfo.CurrentUICulture, Strings.Designer_Index_TitleFormat, model.Designer.DisplayName);
            Ontology.Description = String.Format(
                CultureInfo.CurrentUICulture, Strings.Designer_Index_DescriptionFormat, model.Designer.DisplayName);
            Ontology.Relationships.CanonicalUrl = SiteMap.Designer(designerKey, p);

            var image = model.Previews.First();

            SetOpenGraphImage_(designerKey, image.Reference, image.Variant);

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Designer(designerKey, p));
            LayoutViewModel.DesignerMenuCssClass = ViewUtility.DesignerClass(designerKey);

            return(View(Constants.ViewName.Designer.Index, model));
        }