Exemple #1
0
        public ActionResult AddContent(String description, String title, int id, String[] header, int[] order)
        {
            updateCourse(description, title, id);

            if (!((header == null || order == null) || (header.Length == 0 || order.Length == 0)))
            {
                updateContentGroups(header, order, id);
            }

            CourseSearchController cs = new CourseSearchController();
            List <ContentGroup>    sortedGroupedContentGroups = cs.processContentGroups(id);

            List <int> counterList = new List <int>();

            for (int i = 0; i < sortedGroupedContentGroups.Count(); i++)
            {
                counterList.Add(sortedGroupedContentGroups[i].ContentElements.Count());
            }

            ViewBag.CounterList       = counterList;
            ViewBag.CourseId          = id;
            ViewBag.CourseDescription = description;
            ViewBag.CourseTitle       = title;

            return(View(sortedGroupedContentGroups));
        }
Exemple #2
0
        public ActionResult SaveContentElements(int CGId, String[] description, int[] order, String[] type, String[] url)
        {
            if (!((description.Length == 0 || url.Length == 0) || (type.Length == 0 || order.Length == 0)))
            {
                updateContentElements(CGId, description, url, order, type);
            }

            CourseSearchController cs = new CourseSearchController();
            List <ContentGroup>    sortedGroupedContentGroups = cs.processContentGroups(db.Courses.OrderByDescending(p => p.Id).FirstOrDefault().Id);

            return(View("~/Views/AddCourse/AddContent.cshtml", sortedGroupedContentGroups));
        }
        public ActionResult EditCourse(int?id)
        {
            if (id == null)
            {
                return(View("~/Views/Home/Index.cshtml"));
            }
            else
            {
                CourseSearchController cs = new CourseSearchController();
                Course course             = db.Courses.Find(id);
                List <ContentGroup> sortedGroupedContentGroups = cs.processContentGroups((int)id);

                ViewBag.CourseTitle       = course.Title;
                ViewBag.CourseId          = course.Id;
                ViewBag.CourseDescription = course.Description;

                return(View(sortedGroupedContentGroups));
            }
        }
Exemple #4
0
        public ActionResult AddCourse(String CourseTitle, String Description, String Tags)
        {
            //new added
            Course course = new Course();

            course.Title       = CourseTitle;
            course.Description = Description;
            Microsoft.AspNet.Identity.UserManager <ApplicationUser> us = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
            course.Owner = us.FindById(User.Identity.GetUserId());
            WebApplication.Models.Enrollment En = new WebApplication.Models.Enrollment();
            En.Datetime        = DateTime.Now;
            En.CourseId        = course.Id;
            En.Course          = course;
            En.ApplicationUser = us.FindById(User.Identity.GetUserId());
            LinkedList <Enrollment> Enrollments = new LinkedList <Enrollment>();

            Enrollments.AddFirst(En);
            course.Enrollments = Enrollments;
            db.Enrollments.Add(En);

            //old
            char delimiter = ',';

            string[] tg = Tags.Split(delimiter);

            LinkedList <Assignment> AssigC = new LinkedList <Assignment>();
            List <Tag> AllTags             = new List <Tag>();

            int count   = 0;
            Tag Element = new Tag();

            foreach (var subString in tg)
            {
                string     Temp   = Regex.Replace(subString, @"(\s)", string.Empty);
                Assignment assign = new Assignment();

                assign.Course   = course;
                assign.CourseId = course.Id;
                AllTags         = db.Tags.ToList();

                count = db.Tags.Count();
                for (int i = 0; i <= count; i++)
                {
                    if (count != 0 && i != count)
                    {
                        Element = AllTags.ElementAt(i);
                    }

                    if (i != count && count != 0 && (Element.Name == Temp))
                    {
                        assign.Tag   = Element;
                        assign.TagId = Element.Id;

                        db.Tags.Find(Element.Id).Assignments.Add(assign);

                        AssigC.AddFirst(assign);

                        db.Assignments.Add(assign);
                        db.SaveChanges();

                        break;
                    }
                    else if (i == count)
                    {
                        WebApplication.Models.Tag tag = new WebApplication.Models.Tag();
                        tag.Name     = Temp;
                        assign.Tag   = tag;
                        assign.TagId = tag.Id;

                        AssigC.AddFirst(assign);
                        LinkedList <Assignment> AssignT = new LinkedList <Assignment>();
                        tag.Assignments = AssignT;

                        tag.Assignments.Add(assign);

                        db.Tags.Add(tag);

                        db.Assignments.Add(assign);
                        db.SaveChanges();
                    }
                }
            }

            ViewBag.CourseTitle       = CourseTitle;
            ViewBag.CourseDescription = Description;
            ViewBag.CourseId          = course.Id;

            db.SaveChanges();

            CourseSearchController cs = new CourseSearchController();
            List <ContentGroup>    sortedGroupedContentGroups = cs.processContentGroups(course.Id);

            return(View(sortedGroupedContentGroups));;
        }