예제 #1
0
        public async Task <List <TaskStatusBasicModel> > GetTeamTaskStatuses([FromBody] UserTeamModel teamModel)
        {
            LoginUserViewModel details = new LoginUserViewModel
            {
                Email    = teamModel.UserLogin,
                Password = teamModel.Password
            };

            bool succeeded = await _userService.LoginAsync(details);

            if (succeeded)
            {
                USER user = await _userRepository.GetUserByEmail(details.Email);

                if (_teamRepository.IsTeamMember(user, teamModel.TeamId))
                {
                    var taskStatuses = _taskService.GetTaskStatusesForTeam(teamModel.TeamId);
                    if (taskStatuses != null && taskStatuses.TaskStatuses != null)
                    {
                        List <TaskStatusBasicModel> taskStatusesReturnModel = new List <TaskStatusBasicModel>();
                        foreach (var status in taskStatuses.TaskStatuses)
                        {
                            TaskStatusBasicModel taskStatus = new TaskStatusBasicModel
                            {
                                StatusId   = status.StatusId,
                                StatusName = status.StatusName
                            };
                            taskStatusesReturnModel.Add(taskStatus);
                        }
                        return(taskStatusesReturnModel);
                    }
                }
            }
            return(null);
        }
예제 #2
0
 public IActionResult Create(UserTeamModel item)
 {
     using (MySqlConnection connection = new MySqlConnection(defaultConnection))
     {
         IEnumerable <UserTeamModel> output = connection.Query <UserTeamModel>("INSERT INTO UserTeam (teamID, userID) VALUES ((@_teamID), (@_userID))", new { _teamID = item.teamID, _userID = item.userID });
         return(NoContent());
     }
 }
예제 #3
0
파일: Mapper.cs 프로젝트: xstudn00/VUT-FIT
 public static UserTeam MapUserTeamModelToUserTeamEntity(UserTeamModel model)
 {
     return(new UserTeam
     {
         TeamId = model.TeamId,
         Team = MapTeamModelToTeamEntityBase(model.Team),
         UserId = model.UserId,
         User = MapUserModelToUserEntityBase(model.User)
     });
 }
예제 #4
0
        public async Task <List <TasksWithStatusModel> > GetTasks([FromBody] UserTeamModel teamModel)
        {
            LoginUserViewModel details = new LoginUserViewModel
            {
                Email    = teamModel.UserLogin,
                Password = teamModel.Password
            };

            bool succeeded = await _userService.LoginAsync(details);

            if (succeeded)
            {
                USER user = await _userRepository.GetUserByEmail(details.Email);

                if (_teamRepository.IsTeamMember(user, teamModel.TeamId))
                {
                    var model = _taskService.TaskList(teamModel.TeamId, user);
                    if (model.TasksByStatus != null)
                    {
                        List <TasksWithStatusModel> retModel = new List <TasksWithStatusModel>();
                        foreach (var taskByStatus in model.TasksByStatus)
                        {
                            TasksWithStatusModel tasksWithStatus = new TasksWithStatusModel
                            {
                                TaskStatusId   = taskByStatus.TaskStatusId,
                                TaskStatusName = taskByStatus.TaskStatusName,
                                Tasks          = taskByStatus.Tasks.Select(x => new TaskModel
                                {
                                    TaskId          = x.ID,
                                    TaskDescription = x.DESCRIPTION,
                                    TaskTitle       = x.TITLE,
                                    Deathline       = x.DEATHLINE.ToString(),
                                    StartTime       = x.START_TIME.ToString(),
                                    EndTime         = x.END_TIME.ToString()
                                }).ToList()
                            };
                            retModel.Add(tasksWithStatus);
                        }
                        return(retModel);
                    }
                }
            }
            return(null);
        }
예제 #5
0
        public async Task <List <MemberViewModel> > GetMembers([FromBody] UserTeamModel teamModel)
        {
            LoginUserViewModel details = new LoginUserViewModel
            {
                Email    = teamModel.UserLogin,
                Password = teamModel.Password
            };

            bool succeeded = await _userService.LoginAsync(details);

            if (succeeded)
            {
                USER user = await _userRepository.GetUserByEmail(details.Email);

                if (_teamRepository.IsTeamMember(user, teamModel.TeamId))
                {
                    TeamMemberViewModel model = _teamService.GetTeamMembers(teamModel.TeamId);
                    return(model.Members);
                }
            }
            return(null);
        }