Beispiel #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            CourseTopic coursetopic = db.CourseTopics.Find(id);

            db.CourseTopics.Remove(coursetopic);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "Id,CourseId,TopicId")] CourseTopic coursetopic)
 {
     if (ModelState.IsValid)
     {
         db.Entry(coursetopic).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", coursetopic.CourseId);
     ViewBag.TopicId  = new SelectList(db.Topics, "Id", "Name", coursetopic.TopicId);
     return(View(coursetopic));
 }
Beispiel #3
0
        // GET: /CourseTopic/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseTopic coursetopic = db.CourseTopics.Find(id);

            if (coursetopic == null)
            {
                return(HttpNotFound());
            }
            return(View(coursetopic));
        }
Beispiel #4
0
        // GET: /CourseTopic/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseTopic coursetopic = db.CourseTopics.Find(id);

            if (coursetopic == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", coursetopic.CourseId);
            ViewBag.TopicId  = new SelectList(db.Topics, "Id", "Name", coursetopic.TopicId);
            return(View(coursetopic));
        }
 public void SaveTopic(CourseTopic topic)
 {
     if (topic.ID == Guid.Empty)
     {
         _context.CourseTopics.Add(topic);
     }
     else
     {
         CourseTopic dbEntry = _context.CourseTopics.Find(topic.ID);
         if (dbEntry != null)
         {
             dbEntry.Name = topic.Name;
             dbEntry.OrderNumber = topic.OrderNumber;
         }
     }
     _context.SaveChanges();
 }
Beispiel #6
0
 public void Insert(CourseTopic obj)
 {
     service.Post <CourseTopicValidator>(obj);
 }
Beispiel #7
0
 public void Update(CourseTopic obj)
 {
     service.Put <CourseTopicValidator>(obj);
 }
        public ActionResult CreateNewTopic(int?idCourse, int?idClass, int?idTopic, [Bind(Include = "Id,Name,CourseId")] Topic topic, [Bind(Include = "Id,CourseId,TopicId")] CourseTopic coursetopic)
        {
            var teacher = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();

            ViewData["Teacher"] = teacher;

            if (ModelState.IsValid)
            {
                db.Topics.Add(topic);
                db.SaveChanges();
                db.CourseTopics.Add(coursetopic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CourseId = idCourse;
            ViewBag.TopicId  = idTopic;
            return(View(topic));
        }