public async Task WriteSessionLogEvent(CreateSessionLogEventRequest request) { var session = await GetSession(); var events = await _cache.SessionEvents(); var eventItem = events.FirstOrDefault(e => e.Key == request.EventKey); if (eventItem == null) { // todo: log this return; } using (var uow = _uowFactory.GetUnitOfWork()) { await uow.SessionRepo.CreateSessionLogEvent(new Repositories.DatabaseRepos.SessionRepo.Models.CreateSessionLogEventRequest() { Session_Log_Id = session.SessionLogId, Event_Id = eventItem.Id, InfoDictionary_JSON = JsonConvert.SerializeObject(request.Info), Created_By = ApplicationConstants.SystemUserId });; uow.Commit(); } }
public async Task WriteSessionLogEvent(CreateSessionLogEventRequest request) { var session = await GetSession(); var events = await _cache.SessionEvents(); var eventItem = events.FirstOrDefault(e => e.Key == request.EventKey); if (eventItem == null) { // todo: rather log this than throw an exception throw new Exception($"Could not find session log event with key {request.EventKey}"); } using (var uow = _uowFactory.GetUnitOfWork()) { await uow.SessionRepo.CreateSessionLogEvent(new Infrastructure.Repositories.SessionRepo.Models.CreateSessionLogEventRequest() { Session_Log_Id = session.SessionLogId, Event_Id = eventItem.Id, Message = request.Message, Created_By = ApplicationConstants.SystemUserId }); uow.Commit(); } }
public async Task <int> CreateSessionLogEvent(CreateSessionLogEventRequest request) { var sqlStoredProc = "sp_session_log_event_create"; var response = await DapperAdapter.GetFromStoredProcAsync <int> ( storedProcedureName : sqlStoredProc, parameters : request, dbconnectionString : DefaultConnectionString, sqltimeout : DefaultTimeOut, dbconnection : _connection, dbtransaction : _transaction); if (response == null || response.FirstOrDefault() == 0) { throw new Exception("No items have been created"); } return(response.FirstOrDefault()); }