public ActionResult Frontpage(RenderModel model)
        {
            IPublishedContent page = model.Content;
            FrontpageRenderModel newModel = new FrontpageRenderModel(page);

            newModel.Header = page.GetPropertyValue<string>("header");
            newModel.Bodytext = page.GetPropertyValue<IHtmlString>("bodyText");
            newModel.CreateReviewUserForm = new CreateReviewUserForm();

            var slideFolder = Umbraco.TypedMedia(page.GetPropertyValue<int>("slideFolder"));

            if (slideFolder != null)
            {
                List<Slide> slides = new List<Slide>();

                foreach (var image in slideFolder.Children)
                {
                    Slide s = new Slide();

                    s.ImageUrl = image.Url;
                    slides.Add(s);
                }
                newModel.Slides = slides;
            }

            //Do some stuff here, then return the base method
            return View(newModel);
        }
Esempio n. 2
0
        public override ActionResult Index(RenderModel model)
        {
            if (model.Content.TemplateId.Equals(Template.GetTemplateIdFromAlias("ProjectCreate")))
            {
                var member = Member.GetCurrentMember();
                if (member != null)
                {
                    if (Request.HttpMethod.Equals("GET"))
                        return CurrentTemplate(model);

                    var project = CreateProject(member);
                    if (project != null) return this.Redirect(umbraco.library.NiceUrl(project.Id));
                }

                return this.Redirect(Request.UrlReferrer.AbsoluteUri);
            }
            else
            {
                var id = Convert.ToInt32(Request.Params["id"]);
                var project = new Document(id);

                var member = Member.GetCurrentMember();
                var authorId = project.getProperty("author").Value;
                if (member != null && member.Id.Equals(authorId))
                {
                    if (Request.HttpMethod.Equals("GET"))
                        return base.View(model);

                    SaveProject(project, member);
                }

                return this.Redirect(umbraco.library.NiceUrl(id));
            }
        }
        /// <summary>
        /// The index <see cref="ActionResult"/>.
        /// </summary>
        /// <param name="model">
        /// The current render model.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public override ActionResult Index(RenderModel model)
        {
            // Create the viewmodel
            var viewModel = ViewModelFactory.CreateProduct(model);

            return this.View(viewModel.ThemeViewPath("Product"), viewModel);
        }
        public ActionResult Fruit(RenderModel model, string slug)
        {
            if (string.IsNullOrEmpty(slug))
            {
                return null;
            }
            else
            {
                foreach (var node in model.Content.Children)
                {
                    var potentialUrls = new List<string>();

                    var v = new VortoApiController();
                    var langs = (List<Our.Umbraco.Vorto.Models.Language>)v.GetInstalledLanguages();

                    foreach (var lang in langs)
                    {
                        var vortoValue = node.GetVortoValue<string>("fruitName", lang.IsoCode);
                        if (!string.IsNullOrEmpty(vortoValue))
                        {
                            potentialUrls.Add(vortoValue.ToUrlSegment());
                        }
                    }

                    if (potentialUrls.Contains(slug))
                    {
                        // match
                        return this.View("~/Views/Fruit.cshtml", this.CreateRenderModel(node));
                    }
                }
                return this.HttpNotFound();
            }
        }
        //
        // GET: /Home/

        public override ActionResult Index(RenderModel model)
        {
            HomeModel customModel = new HomeModel(model);
            customModel.Message = "Hello world from HomeController";
            //customModel.SearchTerm = string.Empty;
            return CurrentTemplate(customModel);
        }
 //
 // GET: /Movies/
 public override ActionResult Index(RenderModel model)
 {
     INode currentNode = Node.GetCurrent();
     var newsItem = ModelFactory.CreateModel<MoviesRazor.Models.NewsItem>(currentNode);
     newsItem.DisplayDate = newsItem.Date.ToString("dd MMMM yyyy");
     return CurrentTemplate(newsItem);
 }
        //
        // Note:
        //  the Index method handles the inital page GET request and the Ajax POST request
        //  on which a filtered result is returned. It is a simple approach to handle an Ajax
        //  request with little effort. A better option might be to use a SurfaceController.
        //  However, this example is about to show the Umbraco Code Generation possibilities
        //  and is not about showing the best practices using Umbraco MVC.
        //
        public override ActionResult Index(RenderModel model)
        {
            if (Request.HttpMethod.Equals("GET"))
            {
                INode currentNode = Node.GetCurrent();
                var moviesPage = new MoviesPage();

                moviesPage.Movies = ModelFactory.CreateModel<MoviesRazor.Models.Movies>(currentNode);

                INode genresNode = Node.GetNodeByXpath("//Genres");
                moviesPage.Genres = ModelFactory.CreateModel<Genres>(genresNode);

                return CurrentTemplate(moviesPage);
            }
            else
            {
                int genreId = int.Parse(Request.QueryString["genreId"]);
                INode currentNode = Node.GetCurrent();
                var movies = ModelFactory.CreateModel<MoviesRazor.Models.Movies>(currentNode);

                movies.MovieListItems = movies.MovieListItems.Where(l => l.Genre.NodeId == genreId).ToList();

                return PartialView("MoviesList", movies);
            }
        }
        public override ActionResult Index(RenderModel model)
        {
            ContactOperationStatus operationStatus = _contactService.GetContact();
            ContactViewModel viewContact = new ContactViewModel(model);
            if (operationStatus.Status)
            {

                viewContact.InjectFrom(operationStatus.Contact);
                viewContact.ExistingUserName = operationStatus.Contact.UserName;
                viewContact.ExistingEmail = operationStatus.Contact.Email;
                if (!String.IsNullOrEmpty(Request["url"]))
                {
                    viewContact.Url = Request["url"];
                }
                if (!String.IsNullOrEmpty(Umbraco.Field("checkoutPage").ToString()))
                    viewContact.Url = Umbraco.Field("checkoutPage").ToString();

                viewContact.Titles = GetContactTitles();
                viewContact.Countries = GetCountries();
                viewContact.Status = operationStatus.Status;
                viewContact.Message = operationStatus.Message;
                return CurrentTemplate(viewContact);
            }
            return ReturnErrorView(operationStatus, model);
        }
        public ActionResult Index(RenderModel model, long p = 1)
        {
            var typedModel = model.Content.As<TextPageViewModel>();
            typedModel.Title = "[Overwritten] " + typedModel.Title;

            return CurrentView(typedModel);
        }
        public override ActionResult Index(RenderModel model)
        {
            var products = model.Content.Children();
            var viewModel = new ProductFolderViewModel();
            
            foreach (var productContent in products)
            {
                var productModel = new ProductViewModel();

                productModel.Content= productContent.GetPropertyValue<string>("bodyText")
                    .ScrubHtml()
                    .Truncate(200, true, true);

                productModel.UrlName = productContent.UrlName;
                productModel.Title = productContent.Name;
                productModel.NumberOfComments = productContent.Descendants("Comment").Count();
                viewModel.Products.Add(productModel);
            }

            if (Request.IsAjaxRequest())
            {
                return Json(viewModel);
            }

            ViewBag.Model = viewModel;
            
            //Do some stuff here, then return the base method
            return base.Index(model);
        }
        public override ActionResult Index(RenderModel model)
        {
            INode currentNode = Node.GetCurrent();
            var cinemas = ModelFactory.CreateModel<Cinemas>(currentNode);

            return CurrentTemplate(cinemas);
        }
 public ActionResult SubMenu(RenderModel model)
 {
     var contentSubMenu = model.Content.Children.FirstOrDefault(node => node.DocumentTypeAlias.Equals("ContentSubMenu"));
     if (contentSubMenu == null)
         return base.Index(model);
     return Redirect(contentSubMenu.Url);
 }
 //
 // GET: /Movies/
 public override ActionResult Index(RenderModel model)
 {
     INode currentNode = Node.GetCurrent();
     var news = ModelFactory.CreateModel<MoviesRazor.Models.NewsPage>(currentNode);
     FormatDates(news.NewsListItems);
     return CurrentTemplate(news);
 }
        /// <summary>
        /// Used to render the Members profile (virtual node)
        /// </summary>
        /// <param name="model"></param>
        /// <param name="membername">
        /// The slug which we use to look up the member
        /// </param>
        /// <param name="p"></param>
        /// <returns></returns>
        public ActionResult Show(RenderModel model, string membername, int? p = null)
        {
            var memPage = model.Content as DialogueVirtualPage;
            if (memPage == null)
            {
                throw new InvalidOperationException("The RenderModel.Content instance must be of type " + typeof(DialogueVirtualPage));
            }

            if (string.IsNullOrEmpty(membername))
            {
                return ErrorToHomePage(Lang("Errors.GenericMessage"));
            }

            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var member = ServiceFactory.MemberService.GetUserBySlug(membername, true);
                var loggedonId = UserIsAuthenticated ? CurrentMember.Id : 0;
                var viewModel = new ViewMemberViewModel(model.Content)
                {
                    User = member,
                    LoggedOnUserId = loggedonId,
                    PageTitle = string.Concat(member.UserName, Lang("Members.ProfileTitle")),
                    PostCount = member.PostCount
                };

                // Get the topic view slug
                return View(PathHelper.GetThemeViewPath("MemberProfile"), viewModel);
            }
        }
        public void Container__5Childs_PageSize4__Page2_Returns_1_Item()
        {
			//1. Arrange
			var mSite = new Mock<ISiteRepository>();

			var mController = new Mock<ContainerBaseController>(mSite.Object) { CallBase = true }; //abstract class callBase
			var mContent = Arrange.Content("lorem parent page",
			new List<IPublishedContent>()
				{
					{ Arrange.Content("Lorem child page 1").Object },
					{ Arrange.Content("Ipsum child page 2").Object },
					{ Arrange.Content("Dolor child page 3").Object },
					{ Arrange.Content("Sit child page 4").Object },
					{ Arrange.Content("Consectetur child page 5").Object }
				});

			var renderModel = new RenderModel(mContent.Object, CultureInfo.InvariantCulture);

			//2.Act
			var result = mController.Object.Container(renderModel,
				p: 2,
				s: 4) as ViewResult;

			//3. Assert.
			Assert.IsTrue((result.Model as DynamicCollectionModel).TotalResults == 5, "Total results does not contain 5 items");
			Assert.IsTrue((result.Model as DynamicCollectionModel).Results.Count() == 1, "Resultset for page 2 does not contain the correct amount of items");
        }
		public virtual ActionResult Index(RenderModel model) //Template name, default is Index
		{
			var ret =  new DynamicModel(model.Content, Repository);
            //todo: multiple cultures?
            return View(ret);


		}
        /// <summary>
        /// Used to render the tag listing (virtual node)
        /// </summary>
        /// <param name="model"></param>
        /// <param name="tag">The tag to display if supplied</param>
        /// <param name="p"></param>
        /// <returns></returns>
        public ActionResult Tags(RenderModel model, string tag, int? p)
        {
            var tagurlName = model.Content.GetPropertyValue<string>("tagsUrlName");

            return tag.IsNullOrWhiteSpace()
                ? RenderTagsOrCategories(model, "ArticulateTags", tagurlName) 
                : RenderByTagOrCategory(model, p, "ArticulateTags", tagurlName);
        }
        public override ActionResult Index(RenderModel model)
        {
            // use Ditto to get strongly typed model
            model = new RenderModel(model.Content.As<EventPage>());

            // pass model to template/view
            return base.Index(model);
        }
        /// <summary>
        /// The index.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public override ActionResult Index(RenderModel model)
        {            
            var viewModel = ViewModelFactory.CreateProductCollection(model);

            viewModel.SpecifyCulture(UmbracoContext.PublishedContentRequest.Culture);            

            return this.View(viewModel.ThemeViewPath("ProductCollection"), viewModel);
        }
 /// <summary>
 /// The index <see cref="ActionResult"/>.
 /// </summary>
 /// <param name="model">
 /// The current render model.
 /// </param>
 /// <returns>
 /// The <see cref="ActionResult"/>.
 /// </returns>
 public override ActionResult Index(RenderModel model)
 {
     var invoices = _merchello.Query.Invoice.GetByCustomerKey(CurrentCustomer.Key);
     //// TODO currency codes need to be determined by invoice as they no longer should be assoicated with the global setting
     var viewModel = ViewModelFactory.CreateAccountHistory(model, invoices);
     
     return this.View(viewModel.ThemeAccountPath("History"), viewModel);
 }
        /// <summary>
        /// The index.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public override ActionResult Index(RenderModel model)
        {
            var theme = BazaarContentHelper.GetStoreTheme();

            ((IProductContent)model.Content).SpecifyCulture(UmbracoContext.PublishedContentRequest.Culture);

            return this.View(PathHelper.GetThemeViewPath(theme, "ProductContent"), model.Content);
        }
Esempio n. 22
0
 // GET: Home
 public ActionResult Index()
 {
     var rootNode = _umbracoContext.ContentCache.GetById(1059);
     var content = rootNode.GetPropertyValue<String>("SiteTitle");
     var model = new RenderModel(rootNode, Thread.CurrentThread.CurrentCulture);
     ViewBag.SiteTitle = content;
     return View(model);
 }
Esempio n. 23
0
        public override ActionResult Index(RenderModel model)
        {
            //Get profileURLtoCheck
            string profileURLtoCheck = Request.RequestContext.RouteData.Values["profileURLtoCheck"].ToString();

            //Create a view model
            ViewProfileViewModel profile = new ViewProfileViewModel();

            //Check we have a value in the URL
            if (!String.IsNullOrEmpty(profileURLtoCheck))
            {
                //Try and find member with the QueryString value ?profileURLtoCheck=warrenbuckley
                Member findMember = Member.GetAllAsList().FirstOrDefault(x => x.getProperty("profileURL").Value.ToString() == profileURLtoCheck);

                //Check if we found member
                if (findMember != null)
                {
                    //Increment profile view counter by one
                    int noOfProfileViews = 0;
                    int.TryParse(findMember.getProperty("numberOfProfileViews").Value.ToString(), out noOfProfileViews);

                    //Increment counter by one
                    findMember.getProperty("numberOfProfileViews").Value = noOfProfileViews + 1;

                    //Save it down to the member
                    findMember.Save();

                    //Got the member lets bind the data to the view model
                    profile.Name                    = findMember.Text;
                    profile.MemberID                = findMember.Id;
                    profile.EmailAddress            = findMember.Email;

                    profile.Description             = findMember.getProperty("description").Value.ToString();

                    profile.LinkedIn                = findMember.getProperty("linkedIn").Value.ToString();
                    profile.Skype                   = findMember.getProperty("skype").Value.ToString();
                    profile.Twitter                 = findMember.getProperty("twitter").Value.ToString();

                    profile.NumberOfLogins          = Convert.ToInt32(findMember.getProperty("numberOfLogins").Value.ToString());
                    profile.LastLoginDate           = DateTime.ParseExact(findMember.getProperty("lastLoggedIn").Value.ToString(), "dd/MM/yyyy @ HH:mm:ss", null);
                    profile.NumberOfProfileViews    = Convert.ToInt32(findMember.getProperty("numberOfProfileViews").Value.ToString());

                }
                else
                {
                    //Couldn't find the member return a 404
                    return new HttpNotFoundResult("The member profile does not exist");
                }
            }
            else
            {
                //Couldn't find the member return a 404
                return new HttpNotFoundResult("No profile URL parameter was provided");
            }

            //Return template with our profile model
            return CurrentTemplate(profile);
        }
        public override ActionResult Index(RenderModel model)
        {
            INode currentNode = Node.GetCurrent();
            var cinema = ModelFactory.CreateModel<Cinema>(currentNode);
            GetMovieImages(cinema);
            SetMovieTimes(cinema);

            return CurrentTemplate(cinema);
        }
Esempio n. 25
0
        // GET: Article
        public ActionResult Index(RenderModel model)
        {
            var viewModel = new ViewModel<Article>
            {
                Content = model.As<Article>()
            };

               return CurrentTemplate(viewModel);
        }
        public ActionResult Tags(RenderModel model, string tag, int? maxItems)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (tag == null) throw new ArgumentNullException("tag");

            if (!maxItems.HasValue) maxItems = 25;

            return RenderTagsOrCategoriesRss(model, "ArticulateTags", "tags", maxItems.Value);
        }
Esempio n. 27
0
        //
        // GET: /FrontPage/
        public ActionResult TextPage(RenderModel renderModel)
        {
            var model = new TextPageModel() {
                Header = CurrentPage.GetPropertyValue<string>("header"),
                BodyText = CurrentPage.GetPropertyValue<IHtmlString>("bodyText")
            };

            return View(model);
        }
        public override ActionResult Index(RenderModel model)
        {
            var viewModel = new ViewModel<Home>
            {
                Content = model.As<Home>()
            };

            return CurrentTemplate(viewModel);
        }
        public ActionResult Index(RenderModel model, long p = 1)
        {
            RegisterValueResolverContext(new NewsResolverContext
            {
                CurrentPage = p
            });

            return CurrentView(model);
        }
Esempio n. 30
0
        //
        // GET: /FrontPage/
        public ActionResult NewsPage(RenderModel renderModel)
        {
            var model = new NewsPageModel() {
                NewsItems = NewsItemMapper.Map<NewsItem>(CurrentPage)

            };

            return View(model);
        }
 /// <summary>
 /// <para>Converts IPublishedContent instances to code-first strongly-typed models and returns them as the model to a view.
 /// If no suitable model exists the Umbraco RenderModel is passed through to the view, making it safe to mix code-first and manual
 /// document types.</para>
 /// </summary>
 public override ActionResult Index(Umbraco.Web.Models.RenderModel model)
 {
     if (model.Content == null)
     {
         return(base.Index(model));
     }
     else
     {
         return(CodeFirstTemplate(model.Content.ConvertToModel()));
     }
 }
Esempio n. 32
0
 public override ActionResult Index(Umbraco.Web.Models.RenderModel model)
 {
     return(CurrentTemplate(CurrentContent));
 }