public ActionResult Edit(int id)
 {
     using (var db = new FriendlyUrlEntities())
     {
         return View(db.FriendlyUrls.Find(id));
     }
 }
Beispiel #2
0
        public static FriendlyUrl GetFriendlyUrlByUrl(string friendlyUrl)
        {
            FriendlyUrl page = null;

            using (var ctx = new FriendlyUrlEntities())
            {
                page = ctx.FriendlyUrls.SingleOrDefault(c => c.FriendlyUrl1 == friendlyUrl);
            }

            return page;
        }
 public ActionResult Create(FriendlyUrl url)
 {
     try
     {
         using (var db = new FriendlyUrlEntities())
         {
             db.FriendlyUrls.Add(url);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
 public ActionResult Delete(int id, FriendlyUrl link)
 {
     try
     {
         using (var db = new FriendlyUrlEntities())
         {
             db.Entry(link).State = EntityState.Deleted;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }
 public ActionResult Index()
 {
     using (var db = new FriendlyUrlEntities())
     {
         return View(db.FriendlyUrls.ToList());
     }
 }