Ejemplo n.º 1
0
        public virtual async Task <DeleteResponse> DeleteAsync(int id)
        {
            var response = new DeleteResponse();

            try
            {
                using (var connection = ConnectionFactory.GetConnection())
                {
                    var sql     = GetDeleteStatement();
                    var trans   = connection.BeginTransaction();
                    var results = await connection.ExecuteAsync(sql, new { id }, trans);

                    trans.Commit();
                    response.Message = $@"{results} {typeof(TModel).Name} records were deleted.";
                }
            }
            catch (Exception e)
            {
                var message = $@"Error deleting {typeof(TModel).Name}";
                LogManager.LogError(e, message);
                response.AddError(e);
                Console.WriteLine(e);
            }

            return(response);
        }
Ejemplo n.º 2
0
        public async Task <DeleteResponse> DeleteAllAsync(int auditId, int entityId, int locationId)
        {
            var response = new DeleteResponse();

            try
            {
                using (var connection = ConnectionFactory.GetConnection())
                {
                    var sql     = GetDeleteAllStatement();
                    var trans   = connection.BeginTransaction();
                    var results = await connection.ExecuteAsync(sql, new { AuditId = auditId, EntityId = entityId, LocationId = locationId }, trans);

                    trans.Commit();
                    response.Message = $@"{results} {typeof(ISales).Name} records were deleted.";
                }
            }
            catch (Exception e)
            {
                var message = $@"Error deleting sales records";
                LogManager.LogError(e, message);
                response.AddError(e);
                Console.WriteLine(e);
            }

            return(response);
        }
Ejemplo n.º 3
0
        public override async Task <DeleteResponse> DeleteAsync(int id)
        {
            var response = new DeleteResponse();

            try
            {
                using (var connection = ConnectionFactory.GetConnection())
                {
                    var sql = $@"{GetWorkflowStepDeleteStatement()};
                                 {GetDeleteStatement()}";

                    var trans   = connection.BeginTransaction();
                    var results = await connection.ExecuteAsync(sql, new { id }, trans);

                    trans.Commit();
                    response.Message = $@"{results} Workflow records were deleted.";
                }
            }
            catch (Exception e)
            {
                var message = $@"Error deleting Workflow with id: {id}";
                LogManager.LogError(e, message);
                response.AddError(e);
                Console.WriteLine(e);
            }

            return(response);
        }
Ejemplo n.º 4
0
        public DeleteResponse Delete(string userIdentifier)
        {
            var response = new DeleteResponse();

            if (!Guid.TryParse(userIdentifier, out var userId))
            {
                response.AddError(new Error
                {
                    Code             = ErrorCodes.InvalidGuidProvided,
                    UserMessage      = "Something went wrong. Please try again later",
                    TechnicalMessage = $"Invalid User Identifier provided {userIdentifier}"
                });
                return(response);
            }

            var deleteUserResponse = _userRepository.DeleteUser(userId);

            if (deleteUserResponse.HasError)
            {
                response.AddError(deleteUserResponse.Error);
            }

            return(response);
        }
        public async Task <DeleteResponse> DeleteAsync(int id)
        {
            var deleteResponse = new DeleteResponse();

            try
            {
                deleteResponse = await _auditEventRepository.DeleteAsync(id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                deleteResponse.AddError(ex);
                _logManager.LogError(ex, "Unable to delete auditEvent");
            }

            return(deleteResponse);
        }
Ejemplo n.º 6
0
        public async Task <DeleteResponse> DeleteAllAsync(int auditId, int entityId, int locationId)
        {
            var deleteResponse = new DeleteResponse();

            try
            {
                deleteResponse = await _salesRepository.DeleteAllAsync(auditId, entityId, locationId);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                deleteResponse.AddError(ex);
                _logManager.LogError(ex, "Unable to delete sales");
            }

            return(deleteResponse);
        }
Ejemplo n.º 7
0
        public async Task <DeleteResponse> DeleteQcDataByAuditIdAsync(int auditId)
        {
            var response = new DeleteResponse();

            try
            {
                using (var connection = ConnectionFactory.GetConnection())
                {
                    var sql     = GetQcDataDeleteStatement();
                    var results = await connection.ExecuteAsync(sql, new { AuditId = auditId });

                    response.Message = $@"{results} Qc Data records were deleted.";
                }
            }
            catch (Exception e)
            {
                var message = $@"Error deleting Qc Data records";
                LogManager.LogError(e, message);
                response.AddError(e);
                Console.WriteLine(e);
            }

            return(response);
        }