public async Task <SaveResponse> UpdateAuditStatus(int auditId, AuditStatuses status, int userId) { var response = new SaveResponse(); try { response = await _auditRepository.UpdateAuditStatus(auditId, status, userId); } catch (Exception ex) { Console.WriteLine(ex); response.AddError(ex); _logManager.LogError(ex, "Error updating audit status"); } return(response); }
public async Task <SaveResponse> UpdateAuditStatus(int auditId, AuditStatuses status, int userId) { var response = new SaveResponse(); try { using (var connection = ConnectionFactory.GetConnection()) { var sql = @"UPDATE [dbo].[Audits] SET AuditStatus = @auditStatus WHERE AuditId = @Id; INSERT INTO AuditsStatusHistory (AuditID,AuditStatusID,ChangedDateTime,ChangedByID) VALUES (@Id,@auditStatus,GetDate(),@userId)"; var results = await connection.ExecuteAsync(sql, new { id = auditId, auditStatus = (int)status, userId = userId }); } } catch (Exception e) { var messaage = $@"Unable to audit status."; response.AddError(e); LogManager.LogError(e, messaage); Console.WriteLine(e); } return(response); }