public List <ProjectDto> GetAllProjects()
        {
            var databaseResult = _db.Projects.Where(x => !x.Deleted).ToList();
            var dtoResutls     = new List <ProjectDto>();

            foreach (var item in databaseResult)
            {
                var aux = item.ToDto <Projects, ProjectDto>();
                if (aux != null)
                {
                    var assignedUsers = _userService.GetUsersByProjectId(item.Id);
                    var tasks         = _sharedService.GetTasksByProjectId(item.Id);
                    aux.AssingedUsers = assignedUsers;
                    aux.Tasks         = tasks;
                    dtoResutls.Add(aux);
                }
            }
            return(dtoResutls);
        }
        public IActionResult List(int projectId)
        {
            var model = new List <TaskViewModel>();

            var result = new List <TaskDto>();

            if (projectId == 0)
            {
                result = _taskService.GetAllTasks();
            }
            else
            {
                result = _sharedService.GetTasksByProjectId(projectId);
            }
            foreach (var item in result)
            {
                model.Add(new TaskViewModel(item));
            }
            return(PartialView("_TaskList", model));
        }
Example #3
0
        public ActionResult Details(int id)
        {
            var serviceResult = _projectService.GetProjectById(id);
            var model         = new ProjectDetailsViewModel(new ProjectViewModel(serviceResult));
            var users         = _userService.GetUsersByProjectId(serviceResult.Id);
            var assignedUsers = new List <UserViewModel>();

            foreach (var item in users)
            {
                assignedUsers.Add(new UserViewModel(item));
            }
            model.AssignedUsers = assignedUsers;
            var tasks   = new List <TaskViewModel>();
            var dbTasks = _sharedService.GetTasksByProjectId(id);

            foreach (var item in dbTasks)
            {
                tasks.Add(new TaskViewModel(item));
            }
            model.Tasks = tasks;
            return(View(model));
        }