Esempio n. 1
0
        public async Task <IActionResult> Create(DegreeEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var degree = new EducationDegreeModel
            {
                DegreeName     = model.DegreeName,
                DegreeNameThai = model.DegreeNameThai
            };

            await _degreeService.AddAsync(degree);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id)
        {
            var degree = await _degreeService.GetByIdAsync(id);

            if (degree == null)
            {
                return(NotFound());
            }

            var editModel = new DegreeEditViewModel
            {
                DegreeId       = degree.DegreeId,
                DegreeName     = degree.DegreeName,
                DegreeNameThai = degree.DegreeNameThai
            };

            return(View(editModel));
        }