Esempio n. 1
0
        public async Task<ActionResult> Create(SpecializationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var specialization = new Specialization
                {
                    Code = model.Code,
                    DisplayName = model.DisplayName
                };

                await _specializationService.CreateAsync(specialization);
                return RedirectToAction("Index");
            }

            return View(model);
        }
Esempio n. 2
0
        public async Task<ActionResult> Edit(int id)
        {
            var specialization = await _specializationService.GetByIdAsync(id);
            if (specialization == null)
            {
                return HttpNotFound("specialization not found");
            }

            var specializationViewModel = new SpecializationViewModel
            {
                Id = specialization.Id,
                Code = specialization.Code,
                DisplayName = specialization.DisplayName
            };

            return View(specializationViewModel);
        }
Esempio n. 3
0
        public async Task<ActionResult> Edit(int id, SpecializationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var specialization = await _specializationService.GetByIdAsync(id);
                if (specialization == null)
                {
                    return HttpNotFound("specialization not found");
                }

                specialization.Code = model.Code;
                specialization.DisplayName = model.DisplayName;
                await _specializationService.UpdateAsync(specialization);

                return RedirectToAction("Index");
            }

            return View(model);
        }