Exemplo n.º 1
0
        public IndexModel(IndexModelOptions options, IPrincipal user = null, string blogusername = null)
            : base(blogusername)
        {
            PageTitle = "T G O'B Blog";

            if (options.HasTitle)
            {
                PageTitle += ": " + options.title;
            }
            else if (options.HasTag)
            {
                PageTitle += ": " + options.tag;
            }

            if (user != null)
            {
                BlogName = user.Identity.Name;
            }
            else if (!string.IsNullOrWhiteSpace(blogusername))
            {
                BlogName = blogusername;
            }

            Options = options;

            TagClause = options.tag;
            TitleClause = options.title;

            if (options.HasFullDate && options.day != 0)
            {
                DateClause = new DateTime(
                    options.year.Value, options.monthNum.Value, options.day.Value
                );
            }
            else if (options.HasPartialDate || options.day == 0)
            {
                MinDate = new DateTime(
                    options.year.Value, options.monthNum.Value, 1
                );
                MaxDate = new DateTime(
                    options.year.Value, options.monthNum.Value,
                    DateTime.DaysInMonth(options.year.Value, options.monthNum.Value)
                );
            }

            HasClause = options.HasClause;
        }
Exemplo n.º 2
0
        //
        // GET: /WebDev/Problems/
        public ActionResult Index(IndexModelOptions options, string blogusername = null)
        {
            IndexModel model;
            if (Request.IsAuthenticated && blogusername == null)
            {
                model = new IndexModel(options, user: User);
            }
            else if (blogusername != null)
            {
                model = new IndexModel(options, blogusername: blogusername);
            }
            else
            {
                model = new IndexModel(options, blogusername: "******");
            }

            model.Init();
            model.Load();
            return View(model);
        }