public static RenderPage Create(VDB db, string url, string title) { url = url.ToLower(); var current = db.WebPages.Where(p => p.Url == url).FirstOrDefault(); var page = CreateTree(db.WebPages.Where(p => p.Active).OrderBy(p=>p.Order).ToArray(), current); page.Title = title; return page; }
public static RenderPage Create(VDB db) { return CreateTree(db.WebPages.Where(p => p.Active).OrderBy(p=>p.Order).ToArray()); }
public ActionResult Edit(Product product, List<int> CategoryIds, List<int> TechnologyIds) { using (var mdb = new VDB()) { var mproduct = mdb.Products .Include(i => i.Categories).Include(i => i.Technologies) .Where(i => i.Id == product.Id) .Single(); mproduct.Categories.Clear(); foreach (var id in CategoryIds) { var category = mdb.ProductCategories.Find(id); if (category != null) mproduct.Categories.Add(category); } mproduct.Technologies.Clear(); if (TechnologyIds != null) { foreach (var id in TechnologyIds) { var technology = mdb.Technologies.Find(id); if (technology != null) mproduct.Technologies.Add(technology); } } mdb.Entry(mproduct).State = EntityState.Modified; mdb.SaveChanges(); } if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Categories = db.ProductCategories.ToList(); ViewBag.SelectedCategories = product.Categories; CreateFrame(title); return View(product); /* if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } CreateFrame(title); return View(product); */ }