public async Task <IActionResult> CreateLog([FromBody] DeviceLogModel deviceLogModel) { DeviceLogDTO deviceLogDTO = _mapper.Map <DeviceLogDTO>(deviceLogModel); var actionResult = await _deviceLogService.AddLog(deviceLogDTO); return(Ok(actionResult)); }
public async Task <OperationDetails> AddLog(DeviceLogDTO logDTO) { if (logDTO == null) { throw new ValidationException("There is no information about target log.", "Empty input parameter."); } if (await _dataBase.DeviceLogRepository.CheckIfExist(logDTO.LogId)) { throw new ValidationException("Log with this id already exists.", logDTO.LogId.ToString()); } _dataBase.DeviceLogRepository.Create(_mapper.Map <DeviceLog>(logDTO)); await _dataBase.SaveAsync(); return(new OperationDetails(true, "Log created succesfully", logDTO.LogId.ToString())); }