public ActionResult Create(CourseRegistration courseregistration)
        {
            if (ModelState.IsValid)
            {
                courseregistration.DateCreated = DateTime.Now;
                courseregistration.CreatedByLogin = User.Identity.Name;
                courseregistration.IdCourseRegistration = 1;
                courseregistration.IsAttended = false;
                courseregistration.DateRegistration = DateTime.Now;

                _repo.Add(courseregistration);

                var course = _repo.GetCourseById(courseregistration.IdCourse);
                course.CourseRegistrations.Add(courseregistration);
                _repo.Update(course);

                return RedirectToAction("Index");
            }

            ViewBag.IdCourse = new SelectList(db.Courses, "IdCourse", "NameCourse", courseregistration.IdCourse);
            ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber", courseregistration.IdMember);
            return View(courseregistration);
        }
Exemple #2
0
 public void Update(CourseRegistration courseRegistration)
 {
     _db.Entry(courseRegistration).State = EntityState.Modified;
     _db.SaveChanges();
 }
Exemple #3
0
 public void Remove(CourseRegistration courseRegistration)
 {
     _db.CourseRegistrations.Remove(courseRegistration);
     _db.SaveChanges();
 }
Exemple #4
0
 public void Add(CourseRegistration courseRegistration)
 {
     _db.CourseRegistrations.Add(courseRegistration);
     _db.SaveChanges();
 }
        public ActionResult Edit(CourseRegistration courseregistration)
        {
            if (ModelState.IsValid)
            {
                courseregistration.DateModified = DateTime.Now;
                courseregistration.ModifiedByLogin = User.Identity.Name;

                _repo.Update(courseregistration);
                return RedirectToAction("Index");
            }
            ViewBag.IdCourse = new SelectList(db.Courses, "IdCourse", "NameCourse", courseregistration.IdCourse);
            ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber", courseregistration.IdMember);
            return View(courseregistration);
        }