예제 #1
0
        public ActionResult Assignments()
        {
            //TODO: Zrobić lepiej [KD]
            var projects = _projectService.GetAllByUserId(User.Identity.GetUserId()).ToList();
            var assignmentsAssignedTo = new List <List <Assignment> >(projects.Count);
            var assignmentsOwnedBy    = new List <List <Assignment> >(projects.Count);

            for (int i = 0; i < projects.Count; i++)
            {
                assignmentsAssignedTo.Add(new List <Assignment>());
                assignmentsAssignedTo[i] = _assignmentService.GetAllByProjectId(projects[i].Id).Where(a => a.AssignedToId == User.Identity.GetUserId()).ToList();
            }
            for (int i = 0; i < projects.Count; i++)
            {
                assignmentsOwnedBy.Add(new List <Assignment>());
                assignmentsOwnedBy[i] = _assignmentService.GetAllByProjectId(projects[i].Id).Where(a => a.OwnerId == User.Identity.GetUserId()).ToList();
            }

            var model = new UserAssignmentsViewModel
            {
                Projects = projects,
                AssignmentsAssignedTo = assignmentsAssignedTo,
                AssignmentsOwnedBy    = assignmentsOwnedBy
            };

            return(View(model));
        }