public async Task <Board> ReadOneAsync(string userId, string boardId)
        {
            var url   = $"{Host}api/todo/boards/{userId}/{boardId}";
            var board = await _communicationService.GetAsync <Board>(url);

            return(board);
        }
        public async Task <Card> ReadOneAsync(string boardId, string cardId)
        {
            var url  = $"{Host}api/todo/cards/{boardId}/{cardId}";
            var card = await _communicationService.GetAsync <Card>(url);

            return(card);
        }
Beispiel #3
0
        public async Task <IActionResult> List(BackLogViewModel model, Guid?teamId)
        {
            var urlParams = new Dictionary <string, string>
            {
                { "ownerOnly", "false" }
            };
            var teams          = (await _communicationService.GetAsync <IEnumerable <TeamApiModel> >("user/teams", urlParams, FormHeaders(JsonType), "teamapi")).ToList();
            var teamViewModels = Mapper.Map <IList <TeamViewModel> >(teams);

            var teamBoard = new TeamBoardViewModel {
                Teams = teamViewModels
            };

            if (teamId.HasValue && teamViewModels.Any(m => m.Id == teamId.Value))
            {
                teamBoard.SelectedTeam = teamViewModels.First(m => m.Id == teamId.Value);
            }
            else
            {
                teamBoard.SelectedTeam = teamViewModels.FirstOrDefault();
            }

            if (teamBoard.SelectedTeam != null)
            {
                var tickets = await GetTicketsForTeam(teamBoard.SelectedTeam.Id);

                foreach (var ticketViewModel in tickets)
                {
                    ticketViewModel.TeamId = teamBoard.SelectedTeam.Id;
                }
                var countTickets  = tickets.Count;
                var pageViewModel = new PageViewModel(countTickets, model.Page, model.PageSize);

                var backlogViewModel = new BackLogViewModel
                {
                    SelectedTeam       = teamViewModels.FirstOrDefault(),
                    Teams              = teamViewModels,
                    Tickets            = tickets,
                    SelectedStatuses   = model.SelectedStatuses,
                    SelectedPriorities = model.SelectedPriorities,
                    PageViewModel      = pageViewModel,
                    TeamId             = model.TeamId
                };

                return(View(backlogViewModel));
            }

            return(View(new BackLogViewModel()));
        }
        private async Task <UserApiModel> GetRemoteUserAsync(Guid userId)
        {
            var route = $"/api/users/{userId}";
            var user  = await _communicationService.GetAsync <UserApiModel>(route, null, FormHeaders("application/json"));

            return(user);
        }
Beispiel #5
0
        public async Task <User> ReadOneAsync(string userId)
        {
            var url  = $"{ReadHost}api/users/{userId}";
            var user = await _communicationService.GetAsync <User>(url);

            return(user);
        }
Beispiel #6
0
        public async Task <IActionResult> Dashboard()
        {
            const int defaultStatisticDays = 14;
            var       teams = await _communicationService
                              .GetAsync <IEnumerable <TeamApiModel> >("user/teams", null, FormHeaders(JsonType), "teamapi");

            if (!teams.Any())
            {
                return(RedirectToAction("Board", "Ticket"));
            }

            var model = new DashboardViewModel
            {
                Teams          = _mapper.Map <IEnumerable <TeamViewModel> >(teams),
                StartDate      = DateTime.UtcNow.AddDays(-defaultStatisticDays),
                SelectedTeamId = teams.FirstOrDefault().Id
            };

            return(View(model));
        }
Beispiel #7
0
        public async Task <IActionResult> TeamDashboard(Guid?teamId)
        {
            var urlParams = new Dictionary <string, string>
            {
                { "ownerOnly", "false" }
            };
            var teams = (await _communicationService.GetAsync <IEnumerable <TeamApiModel> >("user/teams", urlParams, FormHeaders(JsonType), "teamapi")).ToList();

            if (teams.Count == 0)
            {
                return(View(new ParticipantsViewModel()));
            }

            var teamViewModels = Mapper.Map <IList <TeamViewModel> >(teams);
            var team           = teamViewModels.FirstOrDefault();

            if (teamId != null)
            {
                team = teamViewModels.FirstOrDefault(t => t.Id == teamId);
            }

            var model = new ParticipantsViewModel
            {
                SelectedTeam = team,
                Teams        = teamViewModels
            };

            if (User.GetUserId() == team.Owner.Id)
            {
                var participants = await _communicationService.GetAsync <IEnumerable <UserApiModel> >(
                    $"user/teams/{team.Id}/participants",
                    null,
                    FormHeaders(JsonType),
                    "teamapi");

                model.Participants = _mapper.Map <IEnumerable <UserViewModel> >(participants);
            }

            return(View(model));
        }
        public async Task <IActionResult> Add([FromBody] CommentViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var comment = _mapper.Map <CommentApiModel>(model);

            comment.User = await _communicationService.GetAsync <UserApiModel>($"users/{User.GetUserId()}", null, FormHeaders(JsonType), "userapi");

            await _communicationService
            .PostAsync($"user/teams/{model.TeamId}/tickets/{model.TicketId}/comments", comment, FormHeaders(JsonType), "ticketapi");

            return(Ok());
        }
        public async Task <IActionResult> Assign(Guid teamId, Guid?ticketId, Guid?userId)
        {
            if (!ticketId.HasValue || !userId.HasValue)
            {
                return(BadRequest());
            }

            var ticketDto = await _ticketService.GetAsync(teamId, ticketId.Value);

            var user = await _communicationService.GetAsync <UserApiModel>(
                $"api/users/{userId.Value}", null, FormHeaders("application/json"), "UserService");

            ticketDto.Assignee = _mapper.Map <UserDto>(user);

            await _ticketService.UpdateAsync(teamId, ticketDto);

            _logger.LogInformation($"Ticket {ticketId} was assigned to user {userId}");

            var newTicketDto = await _ticketService.GetAsync(teamId, ticketId.Value);

            var newTicketApiModel = _mapper.Map <TicketApiModel>(newTicketDto);

            var notificationApiModel = new NotificationInfoApiModel
            {
                OldTicket        = _mapper.Map <TicketApiModel>(ticketDto),
                NewTicket        = newTicketApiModel,
                NotificationType = NotificationType.AssigneeChanged
            };

            try
            {
                await _communicationService.PostAsync <string, NotificationInfoApiModel>(
                    $"api/user/teams/{teamId}/tickets/{ticketDto.Id}/notify",
                    notificationApiModel,
                    FormHeaders("application/json"),
                    "NotificationService");
            }
            catch (ServiceCommunicationException)
            {
                _logger.LogError($"Ticket assign notification with id: {ticketDto.Id} was not sent. User id: {user.Id}!");
            }

            return(Ok());
        }
Beispiel #10
0
        public async Task <IActionResult> GetStatistic(Guid teamId, DateTime startDate)
        {
            var tickets = await _communicationService.GetAsync <IEnumerable <TicketApiModel> >($"api/user/teams/{teamId}/tickets", null, Request.Headers);

            _logger.LogInformation("Team data were successfully received from communication service");

            var ticketsDto   = _mapper.Map <List <TicketDto> >(tickets);
            var statistic    = _statisticService.GetStatisticFiltered(startDate, ticketsDto);
            var jsonSettings = new JsonSerializerSettings
            {
                DateFormatString = "dd/MM/yyy",
                Formatting       = Formatting.Indented,
                Converters       = new List <JsonConverter> {
                    new StringEnumConverter()
                }
            };

            var modelJson = JsonConvert.SerializeObject(statistic, jsonSettings);

            return(Json(modelJson));
        }
Beispiel #11
0
        public async Task <IActionResult> Board(Guid?teamId)
        {
            var urlParams = new Dictionary <string, string>
            {
                { "ownerOnly", "false" }
            };
            var teams          = (await _communicationService.GetAsync <IEnumerable <TeamApiModel> >("user/teams", urlParams, FormHeaders(JsonType), "teamapi")).ToList();
            var teamViewModels = Mapper.Map <IList <TeamViewModel> >(teams);

            var teamBoard = new TeamBoardViewModel {
                Teams = teamViewModels
            };

            if (teamId.HasValue && teamViewModels.Any(model => model.Id == teamId.Value))
            {
                teamBoard.SelectedTeam = teamViewModels.First(model => model.Id == teamId.Value);
            }
            else
            {
                teamBoard.SelectedTeam = teamViewModels.FirstOrDefault();
            }

            if (teamBoard.SelectedTeam != null)
            {
                var ticketBoard = await GetTicketsForTeam(teamBoard.SelectedTeam.Id);

                teamBoard.SelectedTeamTickets = ticketBoard;
            }

            return(View(teamBoard));
        }