Пример #1
0
 public void SetBreadcrumbs(MenyItem one = null, MenyItem two = null, MenyItem three = null, MenyItem four = null)
 {
     MenyItems items = new MenyItems();
     if (one != null)
     {
         items.Add(one);
     }
     if (two != null)
     {
         items.Add(two);
     }
     if (three != null)
     {
         items.Add(three);
     }
     if (four != null)
     {
         items.Add(four);
     }
     ViewBag.BreadCrumbs = items;
 }
Пример #2
0
        public ActionResult CreateDocument(int? id, string type)
        {
            if (id == null)
            {
                return Redirect("~/Error/?error=Inget Id angett för documentets föräldrar entitet");
            }
            if (type == null)
            {
                return Redirect("~/Error/?error=Inget typ angett för document");
            }

            ViewBag.Id = (int)id;
            ViewBag.Type = type;

            MenyItem item = null;

            switch (type.ToLower())
            {
                case "course":
                    Course course = db.Courses.FirstOrDefault(c => c.Id == (int)id);
                    if (course == null)
                    {
                        return Redirect("~/Error/?error=Ingen kurs funnen");
                    }

                    item = new MenyItem { Link = "~/Teacher/Course/" + id, Text = course.Name };
                    break;
                case "module":
                    Module module = db.Modules.FirstOrDefault(c => c.Id == (int)id);
                    if (module == null)
                    {
                        return Redirect("~/Error/?error=Ingen module funnen");
                    }

                    item = new MenyItem { Link = "~/Teacher/Module/" + id, Text = module.Name };
                    break;
                case "activity":
                    Activity activity = db.Activities.FirstOrDefault(c => c.Id == (int)id);
                    if (activity == null)
                    {
                        return Redirect("~/Error/?error=Ingen activitet funnen");
                    }

                    item = new MenyItem { Link = "~/Teacher/Activity/" + id, Text = activity.Name };
                    break;
                default:
                    return Redirect("~/Error/?error=Fel typ angett för document");
            }

            SetBreadcrumbs(one: new MenyItem { Link = "~/Teacher/", Text = "Se alla kurser" }, two: item);
            Menu(Home: true);

            return View();
        }
Пример #3
0
 public void Menu(bool Home = false, MenyItem Back = null, MenyItem Extra = null)
 {
     MenyItems items = new MenyItems();
     if (Home)
     {
         items.Add(new MenyItem { Text = "Hem", Link = "~/Teacher/" });
     }
     items.AddRange(new List<MenyItem> {
         new MenyItem { Text = "Skapa ny kurs", Link = "~/Teacher/CreateCourse/" },
         new MenyItem { Text = "Skapa ny användare", Link = "~/Teacher/CreateUser/" },
         new MenyItem { Text = "Se äldre kurser", Link = "~/Teacher/OldCourses/" }
     });
     if (Back != null)
     {
         items.Add(Back);
     }
     if (Extra != null)
     {
         items.Add(Extra);
     }
     ViewBag.Menu = items;
 }