public void UpdateEntities(EntityChangeRequest <T> request) { EntitiesChangedResponse <T> response = null; var result = false; //Use generic data accessor using (var dataAccessor = new DataAccessor <T>(request.User)) { try { dataAccessor.BeginTransaction(); dataAccessor.InsertOrUpdate(request.Entities); dataAccessor.SaveChanges(); dataAccessor.CommitTransaction(); dataAccessor.RefreshEntities(request.Entities); result = true; } catch (Exception ex) { dataAccessor.RollbackTransaction(); _logger.Log(LogLevel.Error, ex, string.Format("UpdateEntities request Id {0} failed.", request.Id)); result = false; response = new EntitiesChangedResponse <T> { Errors = new string[] { ex.Message }.ToList(), EntitiesUpdated = new List <T>(), Id = request.Id, Status = ResponseStatus.Failure }; } } if (result) { _logger.Log(LogLevel.Info, string.Format("UpdateEntities request Id {0} completed successfully.", request.Id)); response = new EntitiesChangedResponse <T> { EntitiesUpdated = request.Entities.ToList(), Id = request.Id, Status = ResponseStatus.Success }; } EntitiesUpdated(response, request.PrivateResponseRequested); }