private Asset ExtractAndValidateAsset() { var temp = new Asset(); if (!string.IsNullOrWhiteSpace(AssetIdBox.Text)) { temp.AssetId = AssetIdBox.Text.ToLower(); } else { Errors.Add("Asset Id Can't be Empty"); } if (!string.IsNullOrWhiteSpace(AssetNameBox.Text)) { temp.AssetName = AssetNameBox.Text.ToLower(); } else { Errors.Add("Asset Name Can't be Empty"); } if (!string.IsNullOrWhiteSpace(AssetNumberBox.Text)) { temp.AssetNumber = AssetNumberBox.Text.ToLower(); } else { Errors.Add("Asset Number Can't be Empty"); } temp.DateOfPurchase = DateOfPurchasePicker.SelectedDate ?? SelectedAsset.DateOfPurchase; if (!string.IsNullOrWhiteSpace(CostOfAssetBox.Text)) { temp.PurchaseCostOfAsset = NumberHelpers.StringToDouble(CostOfAssetBox.Text); } else { temp.PurchaseCostOfAsset = -55555.55555; Errors.Add("Cost Of Assets Can't be Empty"); } if (!string.IsNullOrWhiteSpace(MonthsToDepreciationBox.Text) && NumberHelpers.IsAllDigits(MonthsToDepreciationBox.Text)) { temp.MonthsToDepreciation = Convert.ToInt32(MonthsToDepreciationBox.Text); } else { Errors.Add("Months To Depreciation is Empty or Not correct"); } if (StatusPicker.SelectedItem != null) { switch (StatusPicker.SelectedIndex) { case 0: temp.AssetStatus = Status.Ready; break; case 1: temp.AssetStatus = Status.NeedService; break; case 2: temp.AssetStatus = Status.InService; break; } } else { Errors.Add("Please select the current status of the Asset"); } if (!string.IsNullOrWhiteSpace(ToolTypeBox.Text)) { temp.ToolType = ToolTypeBox.Text.ToLower(); } else { Errors.Add("Tool Type Can't be Empty"); } if (!string.IsNullOrWhiteSpace(PMVCodeBox.Text)) { temp.PMVCode = PMVCodeBox.Text.ToLower(); } if (!string.IsNullOrWhiteSpace(PoNumberBox.Text)) { temp.PoNumber = PoNumberBox.Text.ToLower(); } if (!string.IsNullOrWhiteSpace(PlateSerialNumberBox.Text)) { temp.PlateSerialNumber = PlateSerialNumberBox.Text.ToLower(); } if (!string.IsNullOrWhiteSpace(CalibrationCertificationNumberBox.Text)) { temp.CalibrationCertificationNumber = CalibrationCertificationNumberBox.Text.ToLower(); } temp.CalibrationCertificationDate = CalibrationCertificationDatePicker.SelectedDate ?? SelectedAsset.CalibrationCertificationDate; temp.AssetPictureBase64 = !string.IsNullOrWhiteSpace(AssetImageBase64) ? AssetImageBase64 : SelectedAsset.AssetPictureBase64; temp.CalibrationCertificationPictureBase64 = !string.IsNullOrWhiteSpace(CalibrationCertificateBase64) ? CalibrationCertificateBase64 : SelectedAsset.CalibrationCertificationPictureBase64; temp.AssetPictureFormat = !string.IsNullOrWhiteSpace(AssetImageFormat) ? AssetImageFormat : SelectedAsset.AssetPictureFormat; temp.CalibrationCertificationPictureFormat = !string.IsNullOrWhiteSpace(CalibrationCertificateFormat) ? CalibrationCertificateFormat : SelectedAsset.CalibrationCertificationPictureFormat; return(temp); }