Ejemplo n.º 1
0
        private void InitializeViewModelsContainer()
        {
            TeamsViewModel teamsViewModel = new TeamsViewModel(this);

            teamsViewModel.TeamSelected += OnTeamSelected;

            AllTeamsViewModel allTeamsViewModel = new AllTeamsViewModel(this);
            // TODO: subscribe to AllTeamsViewModel events

            ProjectsViewModel projectsViewModel = new ProjectsViewModel(this);

            projectsViewModel.ProjectSelected += OnProjectSelected;

            ProductBacklogViewModel productBacklogViewModel = new ProductBacklogViewModel(this);
            SprintViewModel         sprintViewModel         = new SprintViewModel(this);
            AllUserTasksViewModel   allUserTasksViewModel   = new AllUserTasksViewModel(this);
            ReviewViewModel         reviewViewModel         = new ReviewViewModel(this);

            Logout.LogoutViewModel logoutViewModel = new Logout.LogoutViewModel(this);

            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterInstance(projectsViewModel);
            builder.RegisterInstance(teamsViewModel);
            builder.RegisterInstance(allTeamsViewModel);
            builder.RegisterInstance(productBacklogViewModel);
            builder.RegisterInstance(sprintViewModel);
            builder.RegisterInstance(allUserTasksViewModel);
            builder.RegisterInstance(reviewViewModel);
            builder.RegisterInstance(logoutViewModel);

            _viewModelsContainer = builder.Build();
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetAllTeams()
        {
            var teams = Mapper.Map <IEnumerable <TeamViewModel> >(_teamService.GetAll());
            var model = new AllTeamsViewModel()
            {
                MyTeams    = teams.Where(x => x.UserID == GetUserID()),
                OtherTeams = teams.Where(x => x.UserID != GetUserID())
            };

            return(Ok(model));
        }
        public AllTeamsViewModel GetAllTeams()
        {
            var dbTeams = this.DbContext.Teams
                          .Include(t => t.Drivers);

            var allTeams = dbTeams.Select(t => this.Mapper.Map <TeamViewModel>(t));

            var allTeamsViewModel = new AllTeamsViewModel {
                Teams = allTeams
            };

            return(allTeamsViewModel);
        }
        public IActionResult All(int?pageNumber)
        {
            var nextPage = pageNumber ?? GlobalConstants.NextPageValue;

            var teams = this.teamsService.AllTeams <TeamViewModel>().OrderBy(t => t.Name).ToList();

            var pagedteams = teams.ToPagedList(nextPage, GlobalConstants.MaxElementsOnPage);

            var teamViewModels = new AllTeamsViewModel
            {
                Teams = pagedteams
            };

            return(View(teamViewModels));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This method is used to return a model that contains all the teams currently stored in the databse.
        /// </summary>
        /// <returns></returns>
        public AllTeamsViewModel GetAllTeams()
        {
            var teams = context.Teams.Select(t => new Team()
            {
                Id        = t.Id,
                Name      = t.Name,
                ProjectId = t.ProjectId,
                Project   = t.Project,
                Users     = t.Users
            });

            var model = new AllTeamsViewModel()
            {
                Teams = teams
            };

            return(model);
        }
        public AllTeamsViewModel GetUserCreatedTeams(int id)
        {
            var teams = context.Teams.Select(t => new Team()
            {
                Id        = t.Id,
                Name      = t.Name,
                ProjectId = t.ProjectId,
                Project   = t.Project,
                Users     = t.Users
            });

            teams = teams.Where(t => t.Id == id);

            var model = new AllTeamsViewModel()
            {
                Teams = teams
            };

            return(model);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This method is used to retudn a model whith all the teams thet are
        /// created by the currently logged user (if the user is 'Team Lead' or 'CEO')
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AllTeamsViewModel GetUserCreatedTeams(int id)
        {
            List <Team> teams     = new List <Team>();
            User        takenUser = context.Users.FirstOrDefault(u => u.Id == id);

            //If the user is CEO the filtering is based on the CreatedBy property.
            //Otherwuse, the filtering is based on the TeamId of the currently logged user. (which is a team lead type of employee)
            if (takenUser.Role == "CEO")
            {
                teams = context.Teams.Where(t => t.CreatedBy == takenUser.Id).ToList();
            }
            else
            {
                teams = context.Teams.Where(t => t.Id == takenUser.TeamId).ToList();
            }

            var model = new AllTeamsViewModel()
            {
                Teams = teams
            };

            return(model);
        }