public QRCodeConfigResponse UpdateQRCodeRegerateTime(QRCodeConfigurationViewModel configInfo) { _logger.LogInfo("Trying to update configuration time"); try { //Get QR Code configuration based on id QRCodeConfiguration qrConfig = _configurationRepo.GetQRConfigurationById(configInfo.Id); //Throw exception if null if (qrConfig == null) { throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidQRConfiguration))); } //Updated Time qrConfig.RegenerationTimeInMin = configInfo.RegenerationTimeInMin; _configurationRepo.UpdateQRCodeRegerateTime(qrConfig); _logger.LogInfo("Updated configuration time"); QRCodeConfigResponse response = new QRCodeConfigResponse(true, "Successfully saved"); return(response); } catch (Exception ex) { _logger.LogInfo(ex.Message); return(new QRCodeConfigResponse(false, ex.Message)); } }
public ActionResult <QRCodeConfigResponse> UpdateQRCodeRegerateTime([FromBody] QRCodeConfigurationViewModel configInfo) { if (configInfo.Id <= 0) { return(BadRequest(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.ModelValidation), " Invalid configuration id"))); } var response = _configurationService.UpdateQRCodeRegerateTime(configInfo); return(Ok(response)); }
public QRCodeConfigurationViewModel GetQRConfiguration() { _logger.LogInfo("Trying to get active QR Code configuration"); try { QRCodeConfigurationViewModel qrConfig = _mapper.Map <QRCodeConfiguration, QRCodeConfigurationViewModel>(_configurationRepo.GetQRConfiguration()); _logger.LogInfo("Retrieved QR Code configuration information"); return(qrConfig); } catch (Exception ex) { _logger.LogInfo(ex.Message); return(null); } }