Exemplo n.º 1
0
        public IActionResult GetTaskboards(int userId)
        {
            var taskboardsForUser = _ninjaOrganizerRepository.GetTaskboardsForUser(userId);

            foreach (var taskboard in taskboardsForUser)
            {
                taskboard.Cards = _ninjaOrganizerRepository.GetCardsForTaskboard(taskboard.Id).ToList();
            }

            return(Ok(_mapper.Map <IEnumerable <TaskboardWithoutCardsDto> >(taskboardsForUser)));
        }
Exemplo n.º 2
0
        public IActionResult GetCards(int taskboardId, int userId)
        {
            var taskboardsForUsers = _ninjaOrganizerRepository.GetTaskboardsForUser(userId);

            if (taskboardsForUsers == null)
            {
                return(NotFound());
            }

            var taskboard = taskboardsForUsers.FirstOrDefault(t => t.Id == taskboardId);

            if (taskboard == null)
            {
                return(NotFound());
            }

            if (!_ninjaOrganizerRepository.TaskboardExists(taskboard.Id))
            {
                return(NotFound());
            }

            try
            {
                var cards = _ninjaOrganizerRepository.GetCardsForTaskboard(taskboard.Id);
                return(Ok(_mapper.Map <IEnumerable <CardDto> >(cards)));
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"Exception while getting cards for taskboard with id {taskboardId}.", ex);
                return(StatusCode(500, "A problem happened while handling your request."));
            }
        }