コード例 #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);
        }
コード例 #2
0
        //check on this date search piece
        public Generic <OrderInfo> GetByDate(DateTime OrderDate, bool IsComplete)
        {
            Generic <OrderInfo> response = new Generic <OrderInfo>();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    response.GenericClassList = ctx.OrderInfoes.Where(s => DbFunctions.TruncateTime(s.OrderSubmissionDate) == OrderDate && s.Completed == IsComplete).ToList();

                    if (response.GenericClassList != null && response.GenericClassList.Count > 0)
                    {
                        response.ResponseSuccess = true;
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to get Order Info by Order Date " + OrderDate;
                    }
                }
            }
            catch (Exception ex)
            {
                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} Order Date: {OrderDate} {Environment.NewLine} IsCompleted: {IsComplete.ToString()}";
                _applicationError.Log(ErrorMessage, string.Empty);

                response.ResponseMessage = "Unable to get Order Info by Order Date " + OrderDate;
            }

            return(response);
        }
コード例 #3
0
ファイル: OrderProduct.cs プロジェクト: stevancamp/SimpleCure
        public Generic <OrderInfo_Product> GetAllByOrderID(int OrderID)
        {
            Generic <OrderInfo_Product> response = new Generic <OrderInfo_Product>();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    response.GenericClassList = ctx.OrderInfo_Product.Where(s => s.OrderInfoID == OrderID).ToList();

                    if (response.GenericClassList != null && response.GenericClassList.Count > 0)
                    {
                        response.ResponseSuccess = true;
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to get Product Order Info by Order ID " + OrderID;
                    }
                }
            }
            catch (Exception ex)
            {
                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} Order ID: {OrderID}";
                _applicationError.Log(ErrorMessage, string.Empty);

                response.ResponseMessage = "Unable to get Product Order Info by Order ID " + OrderID;
            }

            return(response);
        }
コード例 #4
0
        public Generic <OrderInfo> SearchOrderInfo(string SearchTerm, bool IsCompleted)
        {
            Generic <OrderInfo> response = new Generic <OrderInfo>();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    response.GenericClassList = (from s in ctx.OrderInfoes
                                                 where
                                                 s.CompanyName.ToLower().Contains(SearchTerm.ToLower()) ||
                                                 s.ContactName.ToLower().Contains(SearchTerm.ToLower()) ||
                                                 s.OMMANumber.ToLower().Contains(SearchTerm.ToLower()) ||
                                                 s.EINNumber.ToLower().Contains(SearchTerm.ToLower()) ||
                                                 s.OBNDDNumber.ToLower().Contains(SearchTerm.ToLower()) ||
                                                 s.PhoneNumber.ToLower().Contains(SearchTerm.ToLower()) ||
                                                 s.EmailAddress.ToLower().Contains(SearchTerm.ToLower()) ||
                                                 s.StreetAddress.ToLower().Contains(SearchTerm.ToLower()) &&
                                                 s.Completed == IsCompleted
                                                 select s).ToList();
                    if (response.GenericClassList != null && response.GenericClassList.Count > 0)
                    {
                        response.ResponseSuccess = true;
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to find any Orders with the search term " + SearchTerm + " where is completed is " + IsCompleted.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                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} Search Term: {SearchTerm} {Environment.NewLine} IsCompleted {IsCompleted.ToString()}";
                _applicationError.Log(ErrorMessage, string.Empty);
                response.ResponseMessage = "Unable to find any Orders with the search term " + SearchTerm + " where is complted = " + IsCompleted.ToString();
            }

            return(response);
        }
コード例 #5
0
        public ResponseBase Update(OrderInfo Order)
        {
            ResponseBase response = new ResponseBase();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    ctx.Entry(Order).State = EntityState.Modified;
                    var updated = ctx.SaveChanges();

                    if (updated > 0)
                    {
                        response.ResponseSuccess = true;
                        response.ResponseInt     = Order.ID;
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to update Order Info for Order: " + Order;
                    }
                }
            }
            catch (Exception ex)
            {
                string obj          = JsonConvert.SerializeObject(Order);
                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} Object: {obj}";
                _applicationError.Log(ErrorMessage, string.Empty);

                response.ResponseMessage = "Unable to update Order Info for Order: " + Order;
            }

            return(response);
        }
コード例 #6
0
        public ResponseBase Add(OrderInfo Order)
        {
            ResponseBase response = new ResponseBase();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    var Added = ctx.OrderInfoes.Add(Order);

                    if (Added.ID > 0)
                    {
                        response.ResponseSuccess = true;
                        //confirm if they want this or not and if so change it to a PDF attachement that is sent which means we will have to conver the Order just received into a pdf then stream it to the email message piece as a attachment
                        _emailMessage.SendMessage(ConfigurationManager.AppSettings["EmailAddress"], "New Order Created", "A new order has been created.");
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to add Order: " + Order;
                    }
                }
            }
            catch (Exception ex)
            {
                string obj          = JsonConvert.SerializeObject(Order);
                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} Object: {obj}";
                _applicationError.Log(ErrorMessage, string.Empty);

                response.ResponseMessage = "Unable to add Order: " + Order;
            }

            return(response);
        }
コード例 #7
0
ファイル: OrderProduct.cs プロジェクト: stevancamp/SimpleCure
        public ResponseBase Add(OrderInfo_Product Product)
        {
            ResponseBase response = new ResponseBase();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    var Added = ctx.OrderInfo_Product.Add(Product);

                    if (Added.ID > 0)
                    {
                        response.ResponseSuccess = true;
                        //confirm if this is needed or not
                        _emailMessage.SendMessage(ConfigurationManager.AppSettings["EmailAddress"], "Product added to Order", "A product has been added to a order.");
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to add Products to Order with Product Info: " + Product;
                    }
                }
            }
            catch (Exception ex)
            {
                string obj          = JsonConvert.SerializeObject(Product);
                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} Object: {obj}";
                _applicationError.Log(ErrorMessage, string.Empty);

                response.ResponseMessage = "Unable to add Products to Order with Product Info: " + Product;
            }

            return(response);
        }
コード例 #8
0
        public ResponseBase Log(string ErrorMessage, string IPAddress)
        {
            ResponseBase response = new ResponseBase();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    AppError error = new AppError();

                    error.ErrorMessage = ErrorMessage;
                    error.ErrorTime    = DateTime.Now;
                    error.IP_Address   = IPAddress;

                    var Logged = ctx.AppErrors.Add(error);

                    if (Logged.ID > 0)
                    {
                        response.ResponseSuccess = true;
                    }
                    else
                    {
                        _emailMessage.SendMessage(ConfigurationManager.AppSettings["DeveloperEmail"], "Simple Cure Failure To Log", $"At {DateTime.Now} the Simple Cure application was unable to log error message {ErrorMessage} for IPAddress {IPAddress}");
                        response.ResponseMessage = "Failed to log error message!";
                    }
                }
            }
            catch (Exception ex)
            {
                _emailMessage.SendMessage(ConfigurationManager.AppSettings["DeveloperEmail"], "Simple Cure Failure To Log", $"At {DateTime.Now} the Simple Cure application was unable to log error message {ErrorMessage} for IPAddress {IPAddress} Catch exception is {ex.ToString()}");

                response.ResponseMessage = ex.ToString();
                throw;
            }

            return(response);
        }
コード例 #9
0
ファイル: OrderProduct.cs プロジェクト: stevancamp/SimpleCure
        public ResponseBase Delete(OrderInfo_Product Product)
        {
            ResponseBase response = new ResponseBase();

            try
            {
                using (var ctx = new SimpleCureEntities())
                {
                    ctx.OrderInfo_Product.Remove(Product);
                    var Deleted = ctx.SaveChanges();

                    if (Deleted > 0)
                    {
                        response.ResponseSuccess = true;
                    }
                    else
                    {
                        response.ResponseMessage = "Unable to Delete Product Order with ID " + Product.ID;
                    }
                }
            }
            catch (Exception ex)
            {
                string obj          = JsonConvert.SerializeObject(Product);
                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} Object: {obj}";
                _applicationError.Log(ErrorMessage, string.Empty);

                response.ResponseMessage = "Unable to Delete Product Order with ID " + Product.ID;
            }

            return(response);
        }
コード例 #10
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);
        }