Esempio n. 1
0
        public Generic <AppError> GetByID(int ID)
        {
            Generic <AppError> response = new Generic <AppError>();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    response.GenericClass = ctx.AppErrors.Where(s => s.ID == ID).FirstOrDefault();

                    if (response.GenericClass != null && response.GenericClass.ID > 0)
                    {
                        response.ResponseSuccess = true;
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to get Application Error Information for ID " + ID;
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationError errors       = new ApplicationError();
                string           methodName   = System.Reflection.MethodBase.GetCurrentMethod().Name;
                string           source       = ex.Source;
                string           stacktrace   = ex.StackTrace;
                string           targetsite   = ex.TargetSite.ToString();
                string           error        = ex.InnerException.ToString();
                string           ErrorMessage = $"There was an error at {DateTime.Now} {Environment.NewLine} Method: {methodName} {Environment.NewLine} Source: {source} {Environment.NewLine} StackTrace: {stacktrace} {Environment.NewLine} TargetSite: {targetsite} {Environment.NewLine} Error: {error}{Environment.NewLine} For Error ID: {ID} {Environment.NewLine}";
                errors.Log(ErrorMessage, string.Empty);
                response.ResponseMessage = "Unable to get Application Error Information for ID " + ID;
            }

            return(response);
        }
Esempio n. 2
0
        public Generic <AppError> GetAll()
        {
            Generic <AppError> response = new Generic <AppError>();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    response.GenericClassList = ctx.AppErrors.ToList();

                    if (response.GenericClassList != null && response.GenericClassList.Count > 0)
                    {
                        response.ResponseSuccess = true;
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to Get All Application Errors";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationError errors       = new ApplicationError();
                string           methodName   = System.Reflection.MethodBase.GetCurrentMethod().Name;
                string           source       = ex.Source;
                string           stacktrace   = ex.StackTrace;
                string           targetsite   = ex.TargetSite.ToString();
                string           error        = ex.InnerException.ToString();
                string           ErrorMessage = $"There was an error at {DateTime.Now} {Environment.NewLine} Method: {methodName} {Environment.NewLine} Source: {source} {Environment.NewLine} StackTrace: {stacktrace} {Environment.NewLine} TargetSite: {targetsite} {Environment.NewLine} Error: {error}{Environment.NewLine}";
                errors.Log(ErrorMessage, string.Empty);

                response.ResponseMessage = "Unable to Get All Application Errors";
            }

            return(response);
        }