Ejemplo n.º 1
0
        public virtual async Task <ActionResult> Create(PatientCreateViewModel viewModel)
        {
            // Check
            if (viewModel == null)
            {
                return(View(MVC.Error.Views.BadRequest));
            }

            // Validation
            if (ModelState.IsValid == false)
            {
                return(View(MVC.Patient.Views.Create));
            }
            var validattor = await _patientValidator.CreateValidationAsync(viewModel.NationalCode);

            if (validattor != null)
            {
                ModelState.AddModelError("1", "کدملی تکراری است");
                return(View(MVC.Patient.Views.Create));
            }

            // Result
            await _patientService.CreateByViewModelAsync(viewModel);

            this.AddToastMessage("افزودن بیمار با موفقیت انجام شد", "", ToastType.Success);
            return(RedirectToAction(MVC.Document.Create(viewModel.NationalCode)));
        }