//! WARNING - DEBUG ONLY
 public static void ClearDatabase()
 {
     using (var db = new CopypastaContext())
     {
         db.Copypastas.RemoveRange(db.Copypastas);
         db.SaveChanges();
     }
 }
        public static void DeleteCopypasta(Copypasta copypasta)
        {
            // Delete the given copypasta from the database

            using (var db = new CopypastaContext())
            {
                var pasta = (from c in db.Copypastas where c.Id == copypasta.Id select c).SingleOrDefault();

                db.Copypastas.Remove(pasta);
                db.SaveChanges();
            }
        }
        public static void AddToDatabase(Copypasta copypasta)
        {
            //First check if this pasta is already there (title doesn't matter because it isn't key anyway, it can appear multiple times)

            using (var db = new CopypastaContext())
            {
                var query = from c in db.Copypastas where c.Content.Contains(copypasta.Content) select c;
                if (query.Any())
                {
                    //this copypasta has already been added
                    return;
                }

                db.Copypastas.Add(copypasta);
                db.SaveChanges();
            }
        }
        // Updates a given Copypasta - we assume the Id stays the same and other parameters can be chagned
        public static void UpdateCopypasta(Copypasta newPasta)
        {
            using (var db = new CopypastaContext())
            {
                var result = (from c in db.Copypastas where c.Id == newPasta.Id select c).SingleOrDefault();
                if (result != null)
                {
                    result.Title       = newPasta.Title;
                    result.Content     = newPasta.Content;
                    result.DateAdded   = newPasta.DateAdded;
                    result.IsFavourite = newPasta.IsFavourite;
                    result.ChannelFrom = newPasta.ChannelFrom;

                    db.SaveChanges();
                }
            }
        }
        // Returns the amount of pastas added
        public static int UpdateDatabaseFromList(List <Copypasta> copypastas)
        {
            int amount = 0;

            using (var db = new CopypastaContext())
            {
                for (int i = 0; i < copypastas.Count; i++)
                {
                    //first check if the copypasta is not blacklisted
                    if (Blacklist.BlacklistedMessages.Contains(copypastas[i].Content))
                    {
                        continue;
                    }

                    //check for copypastas that have already are in the database
                    var  dbCopypastas = db.Copypastas.ToList();
                    bool found        = false;

                    foreach (var dbCopypasta in dbCopypastas)
                    {
                        if (dbCopypasta.Content == copypastas[i].Content)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        db.Copypastas.Add(copypastas[i]);
                        amount++;
                    }
                }

                db.SaveChanges();
            }

            return(amount);
        }