Esempio n. 1
0
        public virtual void DeleteRedirect(Guid redirectEntryId)
        {
            using (RedirectorDbContext db = new RedirectorDbContext())
            {
                var redirect = GetRedirect(redirectEntryId);
                if (redirect != null)
                {
                    db.RedirectEntries.Attach(redirect);
                    db.RedirectEntries.Remove(redirect);
                    db.SaveChanges();
                }

            }
        }
Esempio n. 2
0
        public virtual void CreateRedirect(string site, string oldPath, ID itemId, string queryString)
        {
            DeleteRedirect(site, oldPath);

            using (RedirectorDbContext db = new RedirectorDbContext())
            {
                var redirect = new RedirectEntry()
                {
                    RedirectEntryId = Guid.NewGuid(),
                    Site = site,
                    OldPath = oldPath,
                    ItemID = itemId.ToGuid(),
                    QueryString = queryString
                };

                db.RedirectEntries.Add(redirect);

                db.SaveChanges();
            }
        }
Esempio n. 3
0
 public virtual void DeleteRedirect(string site, string oldPath)
 {
     using (RedirectorDbContext db = new RedirectorDbContext())
     {
         var redirect = GetRedirect(site, oldPath);
         if (redirect != null)
         {
             db.RedirectEntries.Attach(redirect);
             db.RedirectEntries.Remove(redirect);
             db.SaveChanges();
         }
     }
 }
Esempio n. 4
0
 public virtual void UpdateRedirect(RedirectEntry entry)
 {
     using (RedirectorDbContext db = new RedirectorDbContext())
     {
         db.RedirectEntries.Attach(entry);
         db.Entry<RedirectEntry>(entry).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 5
0
 public virtual IQueryable<RedirectEntry> GetRedirects()
 {
     RedirectorDbContext db = new RedirectorDbContext();
     return db.RedirectEntries.OrderBy(r => r.ItemID);
 }
Esempio n. 6
0
 public virtual IQueryable<RedirectEntry> GetRedirects(string site)
 {
     RedirectorDbContext db = new RedirectorDbContext();
     return db.RedirectEntries.Where(r => r.Site.Equals(site, StringComparison.CurrentCultureIgnoreCase)).OrderBy(r => r.ItemID);
 }
Esempio n. 7
0
 public virtual IEnumerable<RedirectEntry> GetRedirects(ID itemId)
 {
     using (RedirectorDbContext db = new RedirectorDbContext())
     {
         return db.RedirectEntries.Where(r => r.ItemID == itemId.ToGuid()).OrderBy(r => r.ItemID);
     }
 }
Esempio n. 8
0
 public virtual RedirectEntry GetRedirect(Guid redirectEntryId)
 {
     using (RedirectorDbContext db = new RedirectorDbContext())
     {
         return db.RedirectEntries.Find(redirectEntryId);
     }
 }
Esempio n. 9
0
        public virtual void DeleteSiteRedirects(string site)
        {
            using (RedirectorDbContext db = new RedirectorDbContext())
            {
                var redirects = GetRedirects(site);

                foreach (var redirect in redirects)
                {
                    db.RedirectEntries.Remove(redirect);
                }
                db.SaveChanges();
            }
        }