public async Task EditAsync(EditApplicantViewModel viewModel) { var applicant = await _applicants.FirstAsync(a => a.Id == viewModel.Id); _mappingEngine.Map(viewModel, applicant); 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); } 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); } }
public async Task FillEditViewMoel(EditApplicantViewModel 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); }