public async Task <IActionResult> Edit(int id, [Bind("TeacherInSubjectId,TeacherId,SsubjectId")] TeacherInSubject teacherInSubject)
        {
            if (id != teacherInSubject.TeacherInSubjectId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacherInSubject);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherInSubjectExists(teacherInSubject.TeacherInSubjectId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SsubjectId"] = new SelectList(_context.Ssubject, "SsubjectId", "SsubjectName", teacherInSubject.SsubjectId);
            ViewData["TeacherId"]  = new SelectList(_context.Teacher, "TeacherId", "FirstName", teacherInSubject.TeacherId);
            return(View(teacherInSubject));
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["UserId"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "UserView", new { area = "" }));
            }
            TeacherInSubject teacherInSubject = db.TeacherInSubjects.Find(id);

            db.TeacherInSubjects.Remove(teacherInSubject);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create([Bind("TeacherInSubjectId,TeacherId,SsubjectId")] TeacherInSubject teacherInSubject)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teacherInSubject);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SsubjectId"] = new SelectList(_context.Ssubject, "SsubjectId", "SsubjectName", teacherInSubject.SsubjectId);
            ViewData["TeacherId"]  = new SelectList(_context.Teacher, "TeacherId", "FirstName", teacherInSubject.TeacherId);
            return(View(teacherInSubject));
        }
Example #4
0
 public ActionResult Edit([Bind(Include = "Id,UserId,SubjectId")] TeacherInSubject teacherInSubject)
 {
     if (Session["UserId"] == null && Session["UserName"] == null)
     {
         return(RedirectToAction("Login", "UserView", new { area = "" }));
     }
     if (ModelState.IsValid)
     {
         db.Entry(teacherInSubject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SubjectId = new SelectList(db.Subjects.Where(x => x.IsActive == true), "Id", "Name", teacherInSubject.SubjectId);
     ViewBag.UserId    = new SelectList(db.Users.Where(x => x.RoleId == 3 && x.IsActive == true), "UserId", "FirstName", teacherInSubject.UserId);
     return(View(teacherInSubject));
 }
Example #5
0
        public ActionResult Create([Bind(Include = "Id,UserId,SubjectId")] TeacherInSubject teacherInSubject)
        {
            if (Session["UserId"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "UserView", new { area = "" }));
            }
            if (ModelState.IsValid)
            {
                db.TeacherInSubjects.Add(teacherInSubject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SubjectId = new SelectList(db.Subjects.Where(x => x.IsActive == true), "Id", "Name", teacherInSubject.SubjectId);
            // List<User> List = db.Users.Where(u => u.RoleId != 1 && u.RoleId != 2 && u.RoleId != 4).ToList();
            ViewBag.UserId = new SelectList(db.Users.Where(x => x.RoleId == 3 && x.IsActive == true), "UserId", "FirstName", teacherInSubject.UserId);
            return(View(teacherInSubject));
        }
Example #6
0
        /// <summary>
        /// To show Details of Each teacher with their Subject
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(int?id)
        {
            if (Session["UserId"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "UserView", new { area = "" }));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TeacherInSubject teacherInSubject = db.TeacherInSubjects.Find(id);

            if (teacherInSubject == null)
            {
                return(HttpNotFound());
            }
            return(View(teacherInSubject));
        }
Example #7
0
        public ActionResult AssignSubject(TeacherInSubject objTeacherInSubject)
        {
            if (Session["Login"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            List <User> List = obj.Users.Where(u => u.RoleId != 1 && u.RoleId != 2 && u.RoleId != 4).ToList();

            ViewBag.TeacherList = new SelectList(List, "UserId", "FirstName", objTeacherInSubject.UserId);

            List <Subject> Lists = obj.Subjects.ToList();

            ViewBag.SubjectList = new SelectList(Lists, "SubjectId", "SubjectName", objTeacherInSubject.SubjectId);

            obj.TeacherInSubjects.Add(objTeacherInSubject); //Insert data
            obj.SaveChanges();                              //Save data in database

            //return View(objTeacherInSubject);
            return(RedirectToAction("TeacherSubjectList"));
        }
Example #8
0
        /// <summary>
        /// GET Method: To edit Subjectand Teachers
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int?id)
        {
            if (Session["UserId"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "UserView", new { area = "" }));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TeacherInSubject teacherInSubject = db.TeacherInSubjects.Find(id);

            if (teacherInSubject == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SubjectId = new SelectList(db.Subjects.Where(x => x.IsActive == true), "Id", "Name", teacherInSubject.SubjectId);
            ViewBag.UserId    = new SelectList(db.Users.Where(x => x.RoleId == 3 && x.IsActive == true), "UserId", "FirstName", teacherInSubject.UserId);
            return(View(teacherInSubject));
        }
Example #9
0
        public ActionResult AssignSubjectToTeacher(TeacherInSubject objTeacherInSubject)
        {
            if (Session["UserId"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }

            List <User> List = db.User.Where(u => u.RoleId != 1 && u.RoleId != 2 && u.RoleId != 4).ToList();

            ViewBag.TeacherList = new SelectList(List, "UserId", "FirstName", objTeacherInSubject.UserId);


            List <Subject> Lists = db.Subjects.ToList();

            ViewBag.SubjectList = new SelectList(Lists, "SubjectId", "SubjectName", objTeacherInSubject.SubjectId);

            db.TeacherInSubjects.Add(objTeacherInSubject);
            db.SaveChanges();


            return(RedirectToAction("TeacherAndSubjectList"));
        }
        public ActionResult AssignSubjectToTeacher(AssignSubjectToTeacher assignSubjectToTeacher)
        {
            try
            {
                TeacherInSubject teacherInSubject = new TeacherInSubject();
                var objUserRegistration           = db.UserRegistrations.Where(val => val.UserId == assignSubjectToTeacher.UserId).FirstOrDefault();
                if (objUserRegistration != null)
                {
                    teacherInSubject.UserId    = assignSubjectToTeacher.UserId;
                    teacherInSubject.SubjectId = assignSubjectToTeacher.SubjectId;
                    db.TeacherInSubjects.Add(teacherInSubject);
                    db.SaveChanges();
                    return(RedirectToAction("Dashboard", "SuperAdmin"));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception source: {0}", ex.Message);
                return(View("Dashboard", null));
            }

            return(View("SubjectTeacher"));
        }
Example #11
0
        public ActionResult SubjectAssign(int id, FilterViewModel objFilterViewModel)
        {
            {
                ViewBag.Subject = new SelectList(objEntities.Subjects.ToList(), "SubjectId", "SubjectName");
                try
                {
                    if (ModelState.IsValid)
                    {
                        var getUser = (from d in objEntities.Address
                                       join c in objEntities.NetUsers on d.UserId equals c.UserId
                                       join s in objEntities.UserRole on c.UserId equals s.UserId
                                       where d.UserId == id
                                       select new FilterViewModel
                        {
                            UserId = c.UserId,
                            FirstName = c.FirstName
                        }).FirstOrDefault();

                        TeacherInSubject objTeacherInSubject = new TeacherInSubject
                        {
                            UserId    = getUser.UserId,
                            SubjectId = objFilterViewModel.SubjectId,
                        };
                        objEntities.TeacherInSubject.Add(objTeacherInSubject);
                        objEntities.SaveChanges();
                        ModelState.Clear();
                        return(RedirectToAction("TeacherInSubjectlist", "TeacherInfo"));
                    }
                    return(View(objFilterViewModel));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception source: {0} user is failed to register", ex.Message);
                    return(View(ex));
                }
            }
        }