コード例 #1
0
        public async Task <IActionResult> Create(MedicalItemViewModel medicalItemViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(medicalItemViewModel));
            }

            await _repository.AddAsync(medicalItemViewModel.MedicalItem);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(MedicalItemViewModel medicalItemViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _repository.UpdateAsync(medicalItemViewModel.MedicalItem);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicalItemExists(medicalItemViewModel.MedicalItem.MedItemId))
                    {
                        return(NotFound());
                    }
                    throw;
                }

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

            return(View(medicalItemViewModel));
        }