コード例 #1
0
        //
        // GET: /Worktime/SearchWorktime

        public ActionResult SearchWorktime(int?searchYear = null, int?searchMonth = null, int?searchDay = null)
        {
            ICollection <Worktimes> worktimeList;

            //Get current user
            string      username = User.Identity.Name;
            UserProfile user     = _db.UserProfiles.First(u => u.UserName.Equals(username));

            worktimeList = user.Worktimes.OrderByDescending(r => r.Date).ToList();
            var worktimeLBD = new WorktimeListByDate(worktimeList, searchYear, searchMonth, searchDay);
            var model       = worktimeLBD.getWorktimeList();

            return(View(model));
        }
コード例 #2
0
        //
        // GET: /Admin/SearchWorktime

        public ActionResult SearchWorktime(int?userId = null, int?searchYear = null, int?searchMonth = null, int?searchDay = null)
        {
            ICollection <Worktimes> worktimeList;

            if (userId != null)
            {
                //Get the userprofile
                UserProfile user = _db.UserProfiles.First(u => u.UserId == userId);
                worktimeList = user.Worktimes.ToList();
            }
            else
            {
                //With .ToList make the db selection to ICollection<> type
                worktimeList = _db.Worktimes.Select(r => r).ToList();
            }

            var worktimeLBD = new WorktimeListByDate(worktimeList, searchYear, searchMonth, searchDay);
            var model       = worktimeLBD.getWorktimeList();

            return(View(model));
        }