Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateByForm([FromBody] VmTeamForm teamForm)
        {
            var currentUser = await _currentUserService.GetCurrentUser(User);

            await _teamsService.UpdateByForm(currentUser, teamForm);

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <VmTeam> > CreateByForm([FromBody] VmTeamForm teamForm)
        {
            var currentUser = await _currentUserService.GetCurrentUser(User);

            var result = await _teamsService.CreateByForm(currentUser, teamForm);

            return(Ok(result));
        }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public async Task UpdateByForm(ApplicationUser currentUser, VmTeamForm teamForm)
 {
     await UpdateTeams(currentUser, new[] { teamForm?.Team }, team =>
     {
         team.TeamProjects = teamForm?.ProjectIds?
                             .Select(pId => new ProjectTeam(pId, team.Id))
                             .ToList();
         team.TeamUsers = teamForm?.UserIds?
                          .Select(uId => new TeamUser(team.Id, uId))
                          .ToList();
     });
 }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public async Task <VmTeamForm> CreateByForm(ApplicationUser currentUser, VmTeamForm teamForm)
        {
            var model = await CreateTeam(currentUser, teamForm?.Team, team =>
            {
                team.TeamProjects = teamForm?.ProjectIds?
                                    .Select(pId => new ProjectTeam(pId, team.Id))
                                    .ToList();
                team.TeamUsers = teamForm?.UserIds?
                                 .Select(uId => new TeamUser(team.Id, uId))
                                 .ToList();
            });

            return(new VmTeamForm
            {
                Team = _vmConverter.ToViewModel(model),
                ProjectIds = teamForm?.ProjectIds,
                UserIds = teamForm?.UserIds
            });
        }
Ejemplo n.º 5
0
        public async Task CreateByFormTest(int id)
        {
            //Arrange
            var vmTeam = new VmTeam
            {
                Id        = id,
                Name      = "Team",
                IsRemoved = false
            };
            var userIds    = _testData.Users.Take(2).Select(u => u.Id).ToList();
            var projectIds = _testData.Projects.Take(3).Select(p => p.Id).ToList();

            //Act
            var vmForm     = new VmTeamForm(vmTeam, userIds, projectIds);
            var resultForm = await _service.CreateByForm(_currentUser, vmForm);


            //Assert
            Assert.IsNotNull(resultForm);
            Assert.Greater(resultForm.Team.Id, 0);
            Assert.AreEqual(vmTeam.Name, resultForm.Team.Name);
            Assert.AreEqual(userIds.Count, resultForm.UserIds.Count);
            Assert.AreEqual(projectIds.Count, resultForm.ProjectIds.Count);
        }