public ControlTestingPropertyWrapViewModel(ControlSystemTestingProperty controlTestingProperty, ControlSystemTestingPropertyValue propertyValue) { mControlTestingProperty = controlTestingProperty; mType = (CommonUtils.PropertyType) Enum.Parse(typeof (CommonUtils.PropertyType), controlTestingProperty.Type, true); var name = controlTestingProperty.Name; mRequired = controlTestingProperty.Required; mPropertyValue = propertyValue; mErrorNumbericalValidationResult = new ValidationResult(string.Format("Field {0} is numerical", name)); mErrorRequiredValidationResult = new ValidationResult(string.Format("Field {0} is required", name)); AcceptCommand = new DelegateCommand<object>(AcceptCommandHandler, CanModifyHandler); }
private ControlSystemTestingPropertyValue GetPropertyValue(ControlSystem controlSystem, ControlSystemTypeTestingProperty typeTestingProperty) { ControlSystemTestingPropertyValue propertyValue = (from x in controlSystem.ControlSystemTestingPropertyValues where x.TestPropertyId == typeTestingProperty.TestPropertyId && x.ContolSystemId == controlSystem.Id select x).FirstOrDefault(); if (propertyValue == null && typeTestingProperty.TestPropertyId.HasValue) { propertyValue = new ControlSystemTestingPropertyValue { ContolSystemId = controlSystem.Id, TestPropertyId = typeTestingProperty.TestPropertyId.Value, Value = typeTestingProperty.ControlSystemTestingProperty.DefaultValue }; controlSystem.ControlSystemTestingPropertyValues.Add(propertyValue); } return propertyValue; }
private bool BuildPropertyValueFailed(ControlSystem controlSystem, ControlSystemTestingProperty testingProperty, TestResult testResult, CmsEntities cee, ControlModule cm, out ControlSystemTestingPropertyValue pv) { pv = new ControlSystemTestingPropertyValue { ContolSystemId = controlSystem.Id, TestPropertyId = testingProperty.Id, }; if (testResult.Notes != null && !string.IsNullOrEmpty(testResult.Notes.Trim())) { pv.Notes = testResult.Notes; //sets the new Notes property. } //Numerical if (testingProperty.Type.Equals(TestingType.Numerical.ToString(), StringComparison.CurrentCultureIgnoreCase)) { pv.Value = GetNumbers(testResult.Entry); //sets the Numerical checkbox value. } //VerifiedCheckBox else if (testingProperty.Type.Equals(TestingType.VerifiedCheckBox.ToString(), StringComparison.CurrentCultureIgnoreCase)) { pv.Value = testResult.Tested.ToString(); //sets the verified checkbox value. if (testResult.TestedDate.HasValue && testResult.TestedUserId.HasValue) { var user = (from x in cee.Users where x.Id == testResult.TestedUserId.Value select x).FirstOrDefault(); if (user == null) { Logger.Out(string.Format("Warning: Control {0} - No matchng User found in CMS using USer.Idn = '{1}'.", cm.Tag, testResult.TestedUserId.Value)); return true; } pv.VerifiedUserDate = string.Format("{0} by {1} {2}", testResult.TestedDate.Value.ToString(DATE_FORMAT), user.FirstName, user.LastName); } } return false; }