Ejemplo n.º 1
0
        public ActionResult ConfirmEnroll(int id)
        {
            CoursesOfStudent cos = new CoursesOfStudent();
            Subject          ss  = db.Subjects.Where(p => p.SubjectId == id).FirstOrDefault();

            cos.CourseName = ss.SubjectName;
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            cos.StudentName = Session["Username"].ToString();
            cos.CourseId    = id;
            cos.TeacherId   = ss.TeacherId;

            db.CoursesOfStudents.Add(cos);
            ss.StudentCount += 1;
            db.SaveChanges();

            Registration re = new Registration();

            re.SubjectId   = ss.SubjectId;
            re.StudentName = Session["Username"].ToString();
            re.Fee         = ss.Price;
            db.Registrations.Add(re);
            db.SaveChanges();
            return(RedirectToAction("AllCourses"));
        }
Ejemplo n.º 2
0
        public ActionResult Enroll(int id)
        {
            CoursesOfStudent cos = new CoursesOfStudent();
            Subject          ss  = db.Subjects.Where(p => p.SubjectId == id).FirstOrDefault();

            cos.CourseName = ss.SubjectName;
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            cos.StudentName = Session["Username"].ToString();

            return(View(cos));
        }
Ejemplo n.º 3
0
        public IHttpActionResult PostEnroll([FromBody] CoursesOfStudent cos)
        {
            string Name = Thread.CurrentPrincipal.Identity.Name;

            int     subid = cos.CourseId;
            Subject ss    = subRepo.GetSubDetaileById(subid);

            ss.StudentCount += 1;
            subRepo.Edit(ss);

            cos.TeacherId = ss.TeacherId;
            cosRepo.Insert(cos);

            Registration reg = new Registration();

            reg.SubjectId   = cos.CourseId;
            reg.StudentName = Name;
            reg.Fee         = ss.Price;
            regRepo.Insert(reg);

            return(Ok(cos));
        }