public async Task <IActionResult> Create([Bind("Id,Name,Description,CreatedAt,ExpiredAt,Status")] Course course, int[] courseId)
        {
            if (HttpContext.Session.GetString("currentLogin") == null)
            {
                return(Redirect("/Authentication/Login"));
            }
            if (ModelState.IsValid)
            {
                foreach (var id in courseId)
                {
                    var             courseClass    = _context.ClassRoom.Find(id);
                    ClassRoomCourse CourseCategory = new ClassRoomCourse()
                    {
                        ClassRoom = courseClass,
                        Course    = course
                    };
                    _context.Add(CourseCategory);
                }
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Email,Password,Salt,Gender,Phone,Address,DoB,CreatedAt,UpdatedAt,Status")] Student student, int[] ClassRoomId)
        {
            if (HttpContext.Session.GetString("currentLogin") == null)
            {
                return(Redirect("/Authentication/Login"));
            }
            if (ModelState.IsValid)
            {
                foreach (var id in ClassRoomId)
                {
                    var classroom       = _context.ClassRoom.Find(id);
                    StudentClassRoom sc = new StudentClassRoom
                    {
                        ClassRoom = classroom,
                        Student   = student
                    };
                    _context.Add(sc);
                }
                student.GenerateSalt();
                student.EncryptPassword();
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
        public async Task <IActionResult> Create([Bind("Id,Type,Value,CreatedAt,UpdateAt,CourseId,StudentId,Status")] Mark mark)
        {
            if (HttpContext.Session.GetString("currentLogin") == null)
            {
                return(Redirect("/Authentication/Login"));
            }
            var checkMark = _context.Mark.Where(a => a.StudentId == mark.StudentId).Where(m => m.Type == mark.Type)
                            .Where(d => d.CourseId == mark.CourseId).FirstOrDefault();

            if (checkMark != null)
            {
                TempData["Fail"] = "Học sinh đã có điểm này";
                return(RedirectToAction(nameof(Create)));
            }

            if (ModelState.IsValid)
            {
                if (mark.Value > 5)
                {
                    mark.Status = MarkStatus.PASS;
                }
                else
                {
                    mark.Status = MarkStatus.FAIL;
                }
                _context.Add(mark);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Course, "Id", "Name", mark.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Student, "Id", "Name", mark.StudentId);
            return(View(mark));
        }
Esempio n. 4
0
        public Note AddNotes(Note note)
        {
            _dbcontext.Add(note);
            _dbcontext.SaveChanges();

            return(note);
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("Id,Name,LogoPath")] TeamEntity teamEntity)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teamEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(teamEntity));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Email,Password,CreatedAt,UpdatedAt,Status")] Teacher teacher)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teacher);
                await _context.SaveChangesAsync();

                return(Redirect("/Authentication/Login"));
            }
            return(View(teacher));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,CreatedAt,UpdatedAt,Status")] ClassRoom classRoom)
        {
            if (HttpContext.Session.GetString("currentLogin") == null)
            {
                return(Redirect("/Authentication/Login"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(classRoom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(classRoom));
        }