Ejemplo n.º 1
0
        public IActionResult User(int projectID, int userID)
        {
            ViewData["Message"] = "The main screen with user info and metrics.";
            TimeTrackerEntityContext db = HttpContext.RequestServices.GetService(typeof(TimeTrackerEntityContext)) as TimeTrackerEntityContext;

            #region Get the Group ID, given the userID and projectID
            List <int> allGroupsForProject = db.GetGroups().FindAll(g => g.ProjectId == projectID).ConvertAll(g => g.GroupId);
            List <int> allGroupsForUser    = db.GetUserProjects().FindAll(u => u.UserId == userID).ConvertAll(g => g.GroupId);
            int        groupID             = 0;
            foreach (int g in allGroupsForUser)
            {
                foreach (int g2 in allGroupsForProject)
                {
                    if (g == g2)
                    {
                        groupID = g;
                    }
                }
            }
            #endregion

            // Populate the viewModel and return a view using it
            UserViewModel viewModel = new UserViewModel()
            {
                selectedUser  = db.GetUsers().Find(u => u.UserId == userID),
                selectedGroup = db.GetGroups().Find(g => g.GroupId == groupID),
                allGroups     = db.GetGroups(),
                timeEntries   = db.GetTimeEntries().FindAll(te => te.UserId == userID && te.GroupId == groupID)
            };
            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public IActionResult endTrack(DateTime timeStop, int timeEntryId)
        {
            TimeTrackerEntityContext db = HttpContext.RequestServices.GetService(typeof(TimeTrackerEntityContext)) as TimeTrackerEntityContext;
            TimeEntry existingEntry     = db.GetTimeEntries().Find(te => te.TimeEntryId == timeEntryId);

            existingEntry.TimeStop = timeStop;
            db.updateTimeEntry(existingEntry);
            return(RedirectToAction("TrackTime"));
        }
Ejemplo n.º 3
0
        public IActionResult TrackTime()
        {
            int?id = (int?)(HttpContext.Session.GetInt32("userId")) ?? -1;

            if (id == -1)
            {
                return(RedirectToAction("Login"));
            }

            TimeTrackerEntityContext db = HttpContext.RequestServices.GetService(typeof(TimeTrackerEntityContext)) as TimeTrackerEntityContext;
            var entrys = db.GetTimeEntries().Where(tt => tt.UserId == id && tt.TimeStop == null);

            return(View(entrys.FirstOrDefault()));
        }