Пример #1
0
        public async Task <IActionResult> Create([FromForm()] Schoolclass schoolclass)
        {
            if (ModelState.IsValid)
            {
                await _schoolclassService.CreateAsync(schoolclass);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["C_ClassTeacher"] = new SelectList(await _techerService.GetAllAsync(), "T_ID", "T_ID", schoolclass.C_ClassTeacher);
            return(View(schoolclass));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("C_ID,C_Department,C_ClassTeacher")] Schoolclass schoolclass)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _schoolclassService.CreateAsync(schoolclass);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (ServiceLayerException)
                {
                    return(StatusCode(500));
                }
            }
            ViewData["C_ClassTeacher"] = new SelectList(await _techerService.GetAllAsync(), "T_ID", "T_ID", schoolclass.C_ClassTeacher);
            return(View(schoolclass));
        }