Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,ClassName,TeacherId,Created")] SchoolClass schoolClass)
        {
            if (ModelState.IsValid)
            {
                schoolClass.Id = Guid.NewGuid();
                _context.Add(schoolClass);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(schoolClass));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("StudentId,SchoolClassId")] SchoolClassStudent schoolClassStudent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(schoolClassStudent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SchoolClassId"] = new SelectList(_context.SchoolClasses, "Id", "ClassName", schoolClassStudent.SchoolClassId);
            return(View(schoolClassStudent));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Id,ClassName,ProgramManagerId,Created")] SchoolClass schoolClass)
        {
            if (ModelState.IsValid)
            {
                schoolClass.Id = Guid.NewGuid();
                _context.Add(schoolClass);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProgramManagerId"] = new SelectList(_context.Set <AppUser>(), "Id", "Id", schoolClass.ProgramManagerId);
            return(View(schoolClass));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,ClassName,TeacherId,Created")] SchoolClass schoolClass)
        {
            var checkIfClassNameExists = _context.SchoolClasses.Where(sc => sc.ClassName == schoolClass.ClassName);

            if (checkIfClassNameExists.Count() == 1)
            {
                return(RedirectToAction("ClassAlreadyExists", "Admins"));
            }
            ;

            if (ModelState.IsValid)
            {
                schoolClass.Id      = Guid.NewGuid();
                schoolClass.Created = DateTime.Now;
                _context.Add(schoolClass);
                await _context.SaveChangesAsync();

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