public bool IsValid(InsurancePolicyDto insurance, out string message) { if (insurance == null) { throw new ArgumentNullException(nameof(insurance)); } if (string.IsNullOrEmpty(insurance.ChasisNo)) { message = $"{nameof(InsurancePolicyDto.ChasisNo)}IsEmpty"; return(false); } if (string.IsNullOrEmpty(insurance.InsurerNo)) { message = $"{nameof(InsurancePolicyDto.InsurerNo)}IsEmpty"; return(false); } if (string.IsNullOrEmpty(insurance.PlateNumber)) { message = $"{nameof(InsurancePolicyDto.PlateNumber)}IsEmpty"; return(false); } insurance.PlateNumber = insurance.PlateNumber.Trim(); //if (!IsValidIranianNationalCode(customer.NationalCode)) //{ // message = $"{nameof(CustomerDto.NationalCode)}IsInvalid"; // return false; //} if (string.IsNullOrEmpty(insurance.VIN)) { message = $"{nameof(InsurancePolicyDto.VIN)}IsEmpty"; return(false); } message = null; return(true); }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { insuranceCancellationTokenSource?.Cancel(); insuranceCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: insuranceCancellationTokenSource.Cancel)) { await syncData(); parameters.TryGetValue("Method", out method); if (parameters.TryGetValue("Policy", out InsurancePolicyDto policy)) { Policy = new InsurancePolicyDto { CarId = policy.CarId, ChasisNo = policy.ChasisNo, ColorId = policy.ColorId, CustomerId = policy.CustomerId, Id = policy.Id, InsuranceType = policy.InsuranceType, InsurerId = policy.InsurerId, InsurerNo = policy.InsurerNo, ExpirationDate = policy.ExpirationDate, PlateNumber = policy.PlateNumber, VIN = policy.VIN }; SelectedDate = Policy.ExpirationDate.DateTime; SelectedColor = Colors.FirstOrDefault(c => c.PrmID == Policy.ColorId); SelectedCar = Cars.FirstOrDefault(c => c.PrmID == Policy.CarId); SelectedInsuranceType = InsuranceTypes.FirstOrDefault(c => c.InsuranceType == Policy.InsuranceType); SelectedInsurer = Insurers.FirstOrDefault(c => c.ID == Policy.InsurerId); License = _licenseHelper.ConvertToItemSource(policy.PlateNumber); SelectedAlphabet = Alphabets.FirstOrDefault(a => a.Name == License.Alphabet); } } }