Beispiel #1
0
        //Reject Post
        public static bool RejectPostedArticle(int post_id, string rejected_by, string poster_email, string reject_reason)
        {
            bool process_status = false;

            using (var db = new DBConnection())
            {
                PostReviewsModel reject = new PostReviewsModel
                {
                    PostID         = post_id,
                    ReviewedBy     = rejected_by,
                    AddressedBy    = poster_email,
                    ReviewComments = reject_reason,
                    ReviewStatus   = 0,
                    ReviewDate     = DateTime.Now
                };

                db.PostReviews.Add(reject);

                try
                {
                    db.SaveChanges();
                    process_status = true;
                }
                catch (Exception ex)
                {
                    // Log Error
                    SecurityFunctions.LogError(ex, rejected_by, "RejectPostedArticle", null);
                }
            }
            return(process_status);
        }
Beispiel #2
0
        //Add Review Comment
        public static bool AddReviewArticleComment(int post_review_id, string reviewer_comment)
        {
            bool process_status = false;

            using (var db = new DBConnection())
            {
                var query =
                    from review in db.PostReviews
                    where review.ID == post_review_id
                    select review;

                foreach (PostReviewsModel review_data in query)
                {
                    review_data.AddressedByComments = reviewer_comment;
                    review_data.ReviewStatus        = 1;
                }

                try
                {
                    db.SaveChanges();
                    process_status = true;
                }
                catch (Exception ex)
                {
                    // Log Error
                    SecurityFunctions.LogError(ex, null, "AddReviewArticleComment", null);
                }
            }
            return(process_status);
        }
Beispiel #3
0
        //Approve Post
        public static bool ApprovePostedArticle(int post_id, string approved_by)
        {
            bool process_status = false;

            using (var db = new DBConnection())
            {
                var query =
                    from post in db.NewsArticles
                    where post.ID == post_id
                    select post;

                foreach (NewsArticlesModel post_data in query)
                {
                    post_data.ReviewedBy   = approved_by;
                    post_data.ReviewStatus = 1;
                }

                try
                {
                    db.SaveChanges();
                    process_status = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    // Log Error
                    SecurityFunctions.LogError(ex, approved_by, "ApprovePostedArticle", null);
                }
            }
            return(process_status);
        }
Beispiel #4
0
        //Update media file
        public static bool UpdateMediaFile(int article_id, string file_type, string file_name, string file_caption)
        {
            bool process_status = false;

            using (var db = new DBConnection())
            {
                var query =
                    from media in db.ArticleMediaUploads
                    where media.ID == article_id
                    select media;
                foreach (ArticleMediaUploadsModel media_data in query)
                {
                    media_data.FileType    = file_type;
                    media_data.FileName    = file_name;
                    media_data.FileCaption = file_caption;
                }

                try
                {
                    db.SaveChanges();
                    process_status = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    // Log Error
                    SecurityFunctions.LogError(ex, null, "UpdateMediaFile", null);
                }
            }
            return(process_status);
        }
Beispiel #5
0
        //Add Medai File To DB
        public static bool AddMediaFile(int article_id, string file_type, string file_name, string file_caption)
        {
            bool process_status = false;

            using (var db = new DBConnection())
            {
                ArticleMediaUploadsModel media = new ArticleMediaUploadsModel
                {
                    ArticleID   = article_id,
                    FileType    = file_type,
                    FileName    = file_name,
                    FileCaption = file_caption,
                    DateAdded   = DateTime.Now
                };

                db.ArticleMediaUploads.Add(media);

                try
                {
                    db.SaveChanges();
                    process_status = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    // Log Error
                    SecurityFunctions.LogError(ex, null, "AddMediaFile", null);
                }
            }
            return(process_status);
        }
Beispiel #6
0
        //Add new subscriber
        public static bool AddNewSubscriber(string subscriber_email)
        {
            bool process_status = false;

            using (var db = new DBConnection())
            {
                // Create a new object.
                SubscribersModel subscriber = new SubscribersModel
                {
                    SubscriberEmail = subscriber_email,
                    Status          = 1
                                      // …
                };

                // Add the new object to the collection.
                db.Subcribers.Add(subscriber);

                // Submit the change to the database.
                try
                {
                    db.SaveChanges();
                    process_status = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    //Log error
                    SecurityFunctions.LogError(ex, subscriber_email, "AddNewSubscriber", null);
                }
            }
            return(process_status);
        }
Beispiel #7
0
        //Add Page Visit
        public static bool AddArticlePageVisitOld(int article_id)
        {
            bool   process_status = false;
            string user_email;

            user_email = (HttpContext.Current.Session["sessionEmail"] != null) ? HttpContext.Current.Session["sessionEmail"].ToString() : null;
            string ip_address  = HttpContext.Current.Request.UserHostAddress;
            string country     = RegionInfo.CurrentRegion.DisplayName;
            bool   device      = HttpContext.Current.Request.Browser.IsMobileDevice;
            string machineType = "Unknown";

            if (device)
            {
                machineType = "Mobile";
            }
            else if (device == false)
            {
                machineType = "Desktop";
            }
            string browser        = HttpContext.Current.Request.Browser.Type;
            string device_details = null;

            using (var db = new DBConnection())
            {
                PageVisitsModel visits = new PageVisitsModel
                {
                    ArticleID     = article_id,
                    UserEmail     = user_email,
                    IpAddress     = ip_address,
                    Country       = country,
                    Browser       = browser,
                    Device        = machineType,
                    VisitDate     = DateTime.Now,
                    DeviceDetails = device_details
                                    // …
                };

                db.PageVisits.Add(visits);

                try
                {
                    db.SaveChanges();
                    process_status = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    // Log Error
                    SecurityFunctions.LogError(ex, user_email, "AddArticlePageVisit", null);
                }
            }
            return(process_status);
        }
Beispiel #8
0
 //Delete File
 public static bool DeleteFile(string file_path)
 {
     // Delete a file by using File class static method...
     if (System.IO.File.Exists(file_path))
     {
         try
         {
             System.IO.File.Delete(file_path);
             return(true);
         }
         catch (Exception ex)
         {
             //Log Error
             SecurityFunctions.LogError(ex, null, "DeleteFile", null);
         }
     }
     return(false);
 }
Beispiel #9
0
        public static void SendEmail(string from_email, string from_name, string to_email, string to_name, string to_subject, string h1_text, string h2_text,
                                     string paragraph_1, string paragraph_2, string salutation, string sender_name, string sender_position, string sender_number, string sender_email)
        {
            string button_css = @"border: none;
                                color: white;
                                padding: 15px 32px;
                                text-align: center;
                                text-decoration: none;
                                display: inline-block;
                                font-size: 16px;
                                margin: 4px 2px;
                                cursor: pointer;";

            string dev_enviroment = Enviroment("Testing"); //Testing OR Production
            String todays_date    = DateTime.Now.ToString("yyyy.MM.dd");

            //Send Email
            GMailer.GmailUsername = GMailer.GetSMTPUserName();
            GMailer.GmailPassword = GMailer.GetSMTPPassword();

            GMailer mailer = new GMailer();

            mailer.ToEmail = to_email;
            mailer.Subject = to_subject;
            var message_body = "";

            message_body += "<table rules='all' cellpadding='10' border='1'  style='border:2px solid #FFEBCD; max-width:600px; '>";
            message_body += "<tr><td><a href='#' target='_blank'><div align='center' style='border:2px solid #f5deb3; background-color:#855927; color:white; '><img src='https://via.placeholder.com/728x90.png/09f/fff?text=Gambia+Review' alt='GambiaReview Logo'></div></a></td></tr>";
            //--//--//
            if (!string.IsNullOrEmpty(h1_text))
            {
                message_body += "<tr style='background: #f5f5f5;'><td colspan='2'> <h2 style='color:#000000; text-align: center;'>" + h1_text + "</h2> </td></tr>";
                message_body += "<br/> ";
            }
            //--//--//
            if (!string.IsNullOrEmpty(h2_text))
            {
                message_body += "<h4 style='color:#000000'>" + h2_text + "</h4>";
                message_body += "<br/> ";
            }
            //--//--//
            if (!string.IsNullOrEmpty(to_name))
            {
                message_body += "Dear <strong style='color:#000000'>" + to_name + ",</strong> ";
                message_body += "<br/><br/> ";
            }
            //--//--//
            if (!string.IsNullOrEmpty(paragraph_1))
            {
                message_body += "<p>" + paragraph_1 + "</p>";
                message_body += "<br/> ";
            }
            //--//--//
            if (!string.IsNullOrEmpty(paragraph_2))
            {
                message_body += "<p>" + paragraph_2 + "</p> ";
                message_body += "<br/> ";
            }
            //--//--//
            if (!string.IsNullOrEmpty(salutation))
            {
                message_body += "<p>" + salutation + "</p>";
            }
            else
            {
                message_body += "<p> Regards, <br/> Development Team</p>";
            }
            //--//--//
            if (!string.IsNullOrEmpty(sender_name))
            {
                message_body += "<p> Regards, <br/> " + sender_name + "</p>";
            }
            else
            {
                message_body += "<p>Gambia Review Team</p>";
            }
            //--//--//
            if (!string.IsNullOrEmpty(sender_position))
            {
                message_body += "<p>" + sender_position + "</p>";
            }
            //--//--//
            if (!string.IsNullOrEmpty(sender_number))
            {
                message_body += "<p> Tel. " + sender_number + "</p>";
            }
            else
            {
                message_body += "<p>Tel. +90 531 49 50226</p>";
            }
            //--//--//
            if (!string.IsNullOrEmpty(sender_email))
            {
                message_body += "<p> Tel. " + sender_email + "</p>";
            }
            else
            {
                message_body += "<p>Email. <a href='mailto:[email protected]?Subject=User%20Enquiry' target='_top'>[email protected]</a></p>";
            }
            message_body += "<p>Website. <a href='https://www.gambiareview.com' target='_blank'>https://www.gambiareview.com</a></p>";
            message_body += "<br/> ";
            message_body += "<br/> ";
            message_body += "<a href='#'><button style='" + button_css + " background-color: #3b5998;'>Facebook</button></a>";
            message_body += "<a href='#'><button style='" + button_css + " background-color: #c08d64;'>Instagram</button></a>";
            message_body += "</table>";
            message_body += "</body></html>";
            mailer.Body   = message_body;
            mailer.IsHtml = true;
            try
            {
                mailer.Send();
            }
            catch (Exception ex)
            {
                //Log Error
                SecurityFunctions.LogError(ex, from_email, "SendEmail", null);
            }
        }
Beispiel #10
0
        //Add Page Visit
        public static bool AddArticlePageVisit(int article_id)
        {
            bool   process_status = false;
            string user_email;

            user_email = (HttpContext.Current.Session["sessionEmail"] != null) ? HttpContext.Current.Session["sessionEmail"].ToString() : null;
            string ip_address  = HttpContext.Current.Request.UserHostAddress;
            string country     = RegionInfo.CurrentRegion.DisplayName;
            bool   device      = HttpContext.Current.Request.Browser.IsMobileDevice;
            string machineType = "Unknown";

            if (device)
            {
                machineType = "Mobile";
            }
            else if (device == false)
            {
                machineType = "Desktop";
            }
            string browser        = HttpContext.Current.Request.Browser.Type;
            string device_details = null;


            string        connString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
            SqlConnection conn       = null;

            try
            {
                conn = new SqlConnection(connString);
                conn.Open();

                using (SqlCommand cmd = new SqlCommand())
                {
                    //Insert record to db
                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = @"INSERT INTO [PageVisits] ([ArticleID] ,[UserEmail] ,[IpAddress] ,[Country] ,[Browser] ,[Device] ,[VisitDate] ,[DeviceDetails]) 
									VALUES 
							(@var0, @var1, @var2, @var3, @var4, @var5, @var6, @var7)"                            ;
                    cmd.Parameters.AddWithValue("@var0", article_id);
                    cmd.Parameters.AddWithValue("@var1", ((object)user_email) ?? DBNull.Value);
                    cmd.Parameters.AddWithValue("@var2", ((object)ip_address) ?? DBNull.Value);
                    cmd.Parameters.AddWithValue("@var3", ((object)country) ?? DBNull.Value);
                    cmd.Parameters.AddWithValue("@var4", ((object)browser) ?? DBNull.Value);
                    cmd.Parameters.AddWithValue("@var5", ((object)machineType) ?? DBNull.Value);
                    cmd.Parameters.AddWithValue("@var6", DateTime.Now);
                    cmd.Parameters.AddWithValue("@var7", ((object)device_details) ?? DBNull.Value);
                    int rowsAffected = cmd.ExecuteNonQuery();
                    if (rowsAffected == 1)
                    {
                        process_status = true;
                    }
                    else
                    {
                        process_status = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                // Log Error
                SecurityFunctions.LogError(ex, user_email, "AddArticlePageVisit", null);
            }
            finally
            {
                if (conn != null)
                {
                    //cleanup connection i.e close
                    conn.Close();
                }
            }
            return(process_status);
        }