public async Task <IActionResult> AddIncidentDevice([FromForm] DTOIncidentDevice incdev) { bool success = await _service.AddIncidentDevice(incdev); if (success) { return(Ok()); } else { return(BadRequest()); } }
/* * public async Task<bool> AddIncidentDevice(List<DTOIncidentDevice> incidentDevices) * { * bool success = true; * foreach (DTOIncidentDevice IC in incidentDevices) * { * IncidentDevice mapIncidentCall = _mapper.Map<IncidentDevice>(IC); * _repository.Add(mapIncidentCall); * } * try * { * await _repository.SaveChanges(); * } * catch * { * success = false; * } * * return success; * } */ public async Task <bool> AddIncidentDevice(DTOIncidentDevice incdev) { bool success = true; IncidentDevice mapIncidentCall = _mapper.Map <IncidentDevice>(incdev); _repository.Add(mapIncidentCall); try { await _repository.SaveChanges(); } catch { success = false; } return(success); }