public ComponentTestingPropertyWrapViewModel(ControlSystemComponentTestingProperty componentTestingProperty, ControlSystemComponentTestingPropertyValue propertyValue)
 {
     mComponentTestingProperty = componentTestingProperty;
     mType = (CommonUtils.PropertyType)Enum.Parse(typeof(CommonUtils.PropertyType), componentTestingProperty.Type, true);
     var name = componentTestingProperty.Name;
     mRequired = componentTestingProperty.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);
 }
        public DbOperationResult<ControlSystemComponentTestingProperty> SaveControlSystemComponentTestingProperty(ControlSystemComponentTestingProperty property)
        {
            DbOperationResult<ControlSystemComponentTestingProperty> result = new DbOperationResult<ControlSystemComponentTestingProperty>();

            try
            {
                using (var cee = new CmsEntities())
                {
                    var original = (from x in cee.ControlSystemComponentTestingProperties where x.Id == property.Id select x).FirstOrDefault();

                    if (original == null)
                    {
                        cee.ControlSystemComponentTestingProperties.Add(property);
                        cee.SaveChanges();
                        result.EntityResult = property;
                    }
                    else
                    {
                        cee.Entry(original).CurrentValues.SetValues(property);
                        cee.SaveChanges();
                        result.EntityResult = original;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("", ex, ex.ToString());
                result.ServerErrorMessages.Add(string.Format("Could not Save Control System Component Testing Property.{0}{1}", Environment.NewLine, ex.Message));
            }
            return result;
        }