예제 #1
0
 public static MvcHtmlString PageLinks(this HtmlHelper html, LogEntryViewModel LogModel, Func<int, string> pageUrl)
 {
     StringBuilder result = new StringBuilder();
     for (int i = 1; i <= LogModel.TotalPages; i++)
     {
         TagBuilder tag = new TagBuilder("a");
         tag.MergeAttribute("href", pageUrl(i));
         tag.InnerHtml = i.ToString();
         if (i == LogModel.CurrentPage)
             tag.AddCssClass("active");
         result.Append(tag.ToString());
     }
     return MvcHtmlString.Create(result.ToString());
 }
        //
        // GET: /Log/
        public ActionResult Index(int page = 1)
        {
            UserDTO user = (UserDTO)Session["User"];
            LogEntryViewModel LogModel = new LogEntryViewModel();
            //setup paging variables
            LogModel.CurrentPage = page;
            LogModel.ItemsPerPage = PageSize;
            LogModel.TotalItems = runningLogService.GetCountOfUserLogEntries(user);

            //get activity types and their names
            LogModel.ActivityNames = new Dictionary<int, string>();
            IList<ActivityTypesDTO> activityTypes = runningLogService.ActivityTypes();
            foreach(ActivityTypesDTO activity in activityTypes)
            {
                LogModel.ActivityNames[activity.Id] = activity.ActivityType_Name;
            }

            LogModel.UserLogEntries = runningLogService.GetUserRunningLogEntries(user, page);
            return View(LogModel);
        }