Esempio n. 1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            RSNavigationItem rSNavigationItem = await db.Navigation.FindAsync(id);

            db.Navigation.Remove(rSNavigationItem);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public async Task <ActionResult> Create(RSNavigationItem rSNavigationItem)
        {
            if (ModelState.IsValid)
            {
                db.Navigation.Add(rSNavigationItem);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(rSNavigationItem));
        }
Esempio n. 3
0
        // GET: Navigation/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RSNavigationItem rSNavigationItem = await db.Navigation.FindAsync(id);

            if (rSNavigationItem == null)
            {
                return(HttpNotFound());
            }
            return(View(rSNavigationItem));
        }
Esempio n. 4
0
        public async Task <ActionResult> GetChildren(int id)
        {
            RSNavigationItem navigationItem = await db.Navigation.FindAsync(id);

            if (navigationItem != null)
            {
                //TODO Order by ChildrenOrder
                return(Json(navigationItem.OrderedChildren().Select(s => new { title = s.Title, id = s.Id }), JsonRequestBehavior.AllowGet));
            }
            else
            {
                throw new HttpException(400, "Error fetching items");
            }
        }
Esempio n. 5
0
        // GET: Navigation/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RSNavigationItem rSNavigationItem = await db.Navigation.Include("ProductLink").SingleOrDefaultAsync(i => i.Id == id);

            if (rSNavigationItem == null)
            {
                return(HttpNotFound());
            }
            return(View(rSNavigationItem));
        }
Esempio n. 6
0
        public async Task <ActionResult> Edit(RSNavigationItem rSNavigationItem, int productid)
        {
            if (ModelState.IsValid)
            {
                db.Entry(rSNavigationItem).State = EntityState.Modified;
                await db.SaveChangesAsync();

                rSNavigationItem             = db.Navigation.Find(rSNavigationItem.Id);
                rSNavigationItem.ProductLink = await db.Products.FindAsync(productid);

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(rSNavigationItem));
        }
Esempio n. 7
0
        public async Task <ActionResult> RemoveChild(int id, int childId)
        {
            RSNavigationItem child = await db.Navigation.FindAsync(childId);

            RSNavigationItem navigationItem = await db.Navigation.FindAsync(id);

            if (child != null && navigationItem != null)
            {
                if (navigationItem.Children.Remove(child))
                {
                    await db.SaveChangesAsync();

                    return(Json(true));
                }
            }
            throw new HttpException(400, "Error removing item");
        }
Esempio n. 8
0
        public async Task <ActionResult> AddChild(int id, int childId)
        {
            RSNavigationItem child = await db.Navigation.FindAsync(childId);

            RSNavigationItem navigationItem = await db.Navigation.FindAsync(id);

            if (child != null && navigationItem != null)
            {
                navigationItem.Children.Add(child);
                await db.SaveChangesAsync();

                return(Json(true));
            }
            else
            {
                throw new HttpException(400, "Error inserting item");
            }
        }
Esempio n. 9
0
        public async Task<ActionResult> Create(RSNavigationItem rSNavigationItem)
        {
            if (ModelState.IsValid)
            {
                db.Navigation.Add(rSNavigationItem);
                await db.SaveChangesAsync();
                return RedirectToAction("Index");
            }

            return View(rSNavigationItem);
        }
Esempio n. 10
0
        public async Task<ActionResult> Edit(RSNavigationItem rSNavigationItem, int productid)
        {
            if (ModelState.IsValid)
            {
                db.Entry(rSNavigationItem).State = EntityState.Modified;
                await db.SaveChangesAsync();

                rSNavigationItem = db.Navigation.Find(rSNavigationItem.Id);
                rSNavigationItem.ProductLink = await db.Products.FindAsync(productid);
                await db.SaveChangesAsync();

                return RedirectToAction("Index");
            }
            return View(rSNavigationItem);
        }