public async Task <bool> UpdateIncident(DTOIncident incident) { Incident mapIncident = _mapper.Map <Incident>(incident); _incidentRepository.Update(mapIncident); bool success = true; try { await _incidentRepository.SaveChanges(); } catch { if (!_incidentRepository.IncidentExists(incident.ID)) { success = false; } else { throw; } } return(success); }
public async Task <ActionResult <DTOIncident> > GetIncident(int id) { DTOIncident incident = await _service.GetIncident(id); if (incident == null) { return(NotFound()); } return(incident); }
public async Task <IActionResult> UpdateIncident(DTOIncident incident) { bool success = await _service.UpdateIncident(incident); if (success) { return(Ok()); } else { return(NotFound()); } }
public async Task <ActionResult <DTOIncident> > AddIncident([FromForm] DTOIncident incident) { bool success = await _service.AddIncident(incident); if (success) { return(Ok()); } else { return(BadRequest()); } }
public async Task <bool> AddIncident(DTOIncident incident) { Incident mapIncident = _mapper.Map <Incident>(incident); _incidentRepository.Add(mapIncident); bool success = true; try { await _incidentRepository.SaveChanges(); } catch { success = false; } return(success); }