public async Task <IActionResult> Edit(string id, [FromForm()] Schoolclass schoolclass)
        {
            if (id != schoolclass.C_ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _schoolclassService.EditAsync(id, schoolclass);
                }
                catch (KeyNotFoundException)
                {
                    return(NotFound());
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["C_ClassTeacher"] = new SelectList(await _techerService.GetAllAsync(), "T_ID", "T_ID", schoolclass.C_ClassTeacher);
            return(View(schoolclass));
        }
Beispiel #2
0
        public async Task <IActionResult> Post(string id, [FromBody] Schoolclass schoolclass)
        {
            if (id != schoolclass.C_ID)
            {
                return(Conflict());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _schoolclassService.EditAsync(id, schoolclass);
                }
                catch (KeyNotFoundException)
                {
                    return(NotFound());
                }
                catch (ServiceLayerException)
                {
                    return(StatusCode(500));
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["C_ClassTeacher"] = new SelectList(await _techerService.GetAllAsync(), "T_ID", "T_ID", schoolclass.C_ClassTeacher);
            return(View(schoolclass));
        }