public async Task <IActionResult> CreateNotificationIncident([FromBody] IncidentsWrapper wrapper) { try { IncidentsWrapper incidents = new IncidentsWrapper() { incidents = await _dao.AddIncidents(wrapper.incidents) }; return(new OkObjectResult(incidents)); } catch (Exception e) { _logger.LogInformation($"Error creating notification incident. The error was: {e.Message}, stack trace was: {e.StackTrace}"); return(BadRequest($"Error creating notification incident. The error was: {e.Message}")); } }
public async Task CreateNotificationIncident() { //Arrange var controller = new IncidentNotificationController(_dao, _authService, new Microsoft.Extensions.Logging.LoggerFactory()); IncidentsWrapper wrapper = new IncidentsWrapper(); List <Incident> incidents = new List <Incident>(); wrapper.incidents = incidents; //Act var result = await controller.CreateNotificationIncident(wrapper); //Assert var viewResult = Assert.IsType <OkObjectResult>(result); }
public async Task <IActionResult> GetAllIncidents() { try { IncidentsWrapper wrapper = new IncidentsWrapper() { incidents = await _dao.GetAllIncidents() }; await _dao.GetSubscribersForIncidents(wrapper.incidents); return(new OkObjectResult(wrapper)); } catch (Exception e) { _logger.LogInformation($"Error getting all incidents. The error was: {e.Message}, stack trace was: {e.StackTrace}"); return(BadRequest($"Error getting all incidents. The error was: {e.Message}")); } }