示例#1
0
        public void View(string projectSlug, int issueId)
        {
            if (!string.IsNullOrEmpty(Request.UrlReferrer))
            {
                var referer    = new Uri(Request.UrlReferrer);
                var routeMatch = RoutingModuleEx.Engine.FindMatch(referer.AbsolutePath,
                                                                  new RouteContext(Request, null, "/", new Hashtable()));
                if (routeMatch.Name == "issues")
                {
                    PropertyBag.Add("referer", referer.PathAndQuery);
                }
            }

            var project = session.Query <Project>().FirstOrDefault(p => p.Slug == projectSlug);

            PropertyBag.Add("project", project);
            var item = session.Query <Issue>().FirstOrDefault(i => i.Number == issueId && i.Project == project);

            PropertyBag.Add("item", item);
            PropertyBag.Add("comments", item.Comments);
            PropertyBag.Add("days", DayHelper.GetPastDaysList());
            PropertyBag.Add("datetime", DateTime.Now);

            item.Touch(CurrentUser);
            foreach (var action in item.Actions)
            {
                action.Touch(CurrentUser);
            }
            using (var transaction = session.BeginTransaction())
            {
                session.SaveOrUpdate(item);
                transaction.Commit();
            }
        }