public TuningPropertyWrapViewModel(ControlSystemTuningProperty tuningProperty, ControlSystemTuningPropertyValue propertyValue)
 {
     mTuningProperty = tuningProperty;
     mType = (CommonUtils.PropertyType)Enum.Parse(typeof(CommonUtils.PropertyType),tuningProperty.Type, true);
     mName = tuningProperty.Name;
     mRequired = tuningProperty.Required;
     mPropertyValue = propertyValue;
     mErrorNumbericalValidationResult = new ValidationResult(string.Format("Field {0} is numerical", mName));
     mErrorRequiredValidationResult = new ValidationResult(string.Format("Field {0} is required", mName));
     AcceptCommand = new DelegateCommand<object>(AcceptCommandHandler, CanModifyHandler);
 }
        public ControlSystemTuningProperty SaveControlSystemTuningProperty(ControlSystemTuningProperty controlSystemTuningProperty)
        {
            using (var cee = new CmsEntities())
            {
                var original = (from x in cee.ControlSystemTuningProperties where x.Id == controlSystemTuningProperty.Id select x).FirstOrDefault();

                if (original == null)
                {
                    cee.ControlSystemTuningProperties.Add(controlSystemTuningProperty);
                }
                else
                {
                    cee.Entry(original).CurrentValues.SetValues(controlSystemTuningProperty);
                }

                cee.SaveChanges();
            }
            return controlSystemTuningProperty;
        }