// GET: api/Project      
        public IHttpActionResult Get()
        {
            try
            {
                GetProjectsByUserIdRequest request = new GetProjectsByUserIdRequest();
                request.UserId = 1;

                if (request == null)
                {
                    _logger.Log(String.Format("GetProjectsByUserIdRequest is null. Returning Bad Request."));
                    return BadRequest("GetProjectsByUserIdRequest is null");
                }

                _logger.Log(String.Format("Fetching projects for UserId '{0}'", request.UserId));

                GetProjectsByUserIdResponse response = _projectService.GetProjectsByUserId(request);

                _logger.Log(String.Format("Found {0} projects.", response.Projects.ToArray().Length));

                return Ok(response.Projects);
            }
            catch (Exception ex)
            {
                _logger.Log(String.Format("Failed to get projects: {0}", ex.Message));
                return InternalServerError(ex);
            }
        }
Exemple #2
0
        public GetProjectsByUserIdResponse GetProjectsByUserId(GetProjectsByUserIdRequest request)
        {
            GetProjectsByUserIdResponse response = new GetProjectsByUserIdResponse();

            response.Projects = _projectRepository.GetAll(request.UserId);

            return response;
        }