public IActionResult DeleteProject(int id) { if (!_hoursApiRepository.ProjectExists(id)) { return(NotFound()); } var projectEntity = _hoursApiRepository.GetProject(id, false); if (projectEntity == null) { return(NotFound()); } _hoursApiRepository.DeleteProject(projectEntity); if (!_hoursApiRepository.Save()) { return(StatusCode(500, "A problem happened while handling your request.")); } return(NoContent()); }
public IActionResult GetWorkItems(int ProjectId) { try { if (!_HoursApiRepository.ProjectExists(ProjectId)) { _logger.LogInformation($"Project with id {ProjectId} wasn't found when accessing points of interest."); return(NotFound()); } var WorkItemsForProject = _HoursApiRepository.GetWorkItemsForProject(ProjectId); var WorkItemsForProjectResults = Mapper.Map <IEnumerable <WorkItemDto> >(WorkItemsForProject); return(Ok(WorkItemsForProjectResults)); } catch (Exception ex) { _logger.LogCritical($"Exception while getting points of interest for Project with id {ProjectId}.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }