Пример #1
0
        public virtual async Task <ActionResult> Create(AddApplicantViewModel viewModel)
        {
            if (!viewModel.NationalCode.IsValidNationalCode())
            {
                this.AddErrors("NationalCode", "لطفا کد ملی را به شکل صحیح وارد کنید");
            }

            if (await _applicantService.IsApplicantNationalCodeExist(viewModel.NationalCode, null))
            {
                this.AddErrors("NationalCode", "یک متقاضی بااین کد ملی قبلا در سیستم ثبت شده است");
            }

            if (!ModelState.IsValid)
            {
                await _applicantService.FillAddViewMoel(viewModel, IranCitiesPath);

                return(View(viewModel));
            }

            _applicantService.Create(viewModel);
            await _unitOfWork.SaveAllChangesAsync(auditUserId : _userManager.GetCurrentUserId());

            this.NotyInformation("متقاضی جدید با موفقیت ثبت شد.");
            return(RedirectToAction(MVC.Applicant.Create()));
        }
Пример #2
0
        public async Task <AddApplicantViewModel> GetForCreate(string path)
        {
            var viewModel = new AddApplicantViewModel
            {
                StatesForBirthPlace = _stateService.GetAsSelectListItemAsync(null, path)
            };

            return(viewModel);
        }
Пример #3
0
        public async Task FillAddViewMoel(AddApplicantViewModel viewModel, string path)
        {
            viewModel.StatesForBirthPlace = viewModel.BirthPlaceState == null
                ? new List <SelectListItem>()
                : _stateService.GetAsSelectListItemAsync(viewModel.BirthPlaceState, path);


            viewModel.CitiesForBirthPlace = viewModel.BirthPlaceState == null
                ? new List <SelectListItem>()
                : viewModel.BirthPlaceCity == null
                    ? new List <SelectListItem>()
                    : _cityService.GetAsSelectListByStateNameAsync(viewModel.BirthPlaceState,
                                                                   viewModel.BirthPlaceCity, path);
        }
Пример #4
0
        public void Create(AddApplicantViewModel viewModel)
        {
            var applicant = _mappingEngine.Map <Applicant>(viewModel);

            if (viewModel.PhotoScan.HasValue())
            {
                applicant.Photo = Convert.FromBase64String(viewModel.PhotoScan).ResizeImageFile(150, 150);
            }
            else if (viewModel.PhotoFile.HasFile())
            {
                applicant.Photo = viewModel.PhotoFile.InputStream.ResizeImageFile(150, 150);
            }
            else
            {
                applicant.Photo = ImageManage.ResizeImageFile(_httpContextBase.Server.MapPath(DefaultAvatarPath), 150, 150);
            }

            if (viewModel.CopyOfBirthCertificateScan.HasValue())
            {
                applicant.CopyOfBirthCertificate = Convert.FromBase64String(viewModel.CopyOfBirthCertificateScan).ResizeImageFile(A5Width, A5Height);
            }
            else if (viewModel.CopyOfBirthCertificateFile.HasFile())
            {
                applicant.CopyOfBirthCertificate = viewModel.CopyOfBirthCertificateFile.InputStream.ResizeImageFile(A5Width, A5Height);
            }

            if (viewModel.CopyOfNationalCardScan.HasValue())
            {
                applicant.CopyOfNationalCard = Convert.FromBase64String(viewModel.CopyOfNationalCardScan).ResizeImageFile(A6Width, A6Height);
            }
            else if (viewModel.CopyOfNationalCardFile.HasFile())
            {
                applicant.CopyOfNationalCard = viewModel.CopyOfNationalCardFile.InputStream.ResizeImageFile(A6Width, A6Height);
            }
            _applicants.Add(applicant);
        }