예제 #1
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();
     }
 }
예제 #2
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();
         }
     }
 }
예제 #3
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();
            }
        }
예제 #4
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();
         }
     }
 }
예제 #5
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();
            }
        }