Source

main / Source / Excel / Excel.AddIn / Excel.AddIn / ViewModels / ParameterMetadataViewModel.cs

Diff from to

File Source/Excel/Excel.AddIn/Excel.AddIn/ViewModels/ParameterMetadataViewModel.cs

-
+using System;
+using System.ComponentModel;
+
 namespace DataUp.Excel.Addin
 {
-    public class ParameterMetadataViewModel : ViewModelBase
+    public class ParameterMetadataViewModel : ViewModelBase, IDataErrorInfo
     {
+        private string entityName;
+        private string entityDescription;
         private string name;
         private string description;
         private string type;
 
         private bool enableUnits;
 
+        public string EntityName
+        {
+            get { return this.entityName; }
+            set
+            {
+                this.entityName = value;
+                OnNotifyPropertyChanged("EntityName");
+            }
+        }
+
+        public string EntityDescription
+        {
+            get { return this.entityDescription; }
+            set
+            {
+                this.entityDescription = value;
+                OnNotifyPropertyChanged("EntityDescription");
+            }
+        }
+
         public string Name
         {
             get
                 OnNotifyPropertyChanged("EnableUnits");
             }
         }
+
+        public bool Validate()
+        {
+            if (String.IsNullOrEmpty(this.Name))
+            {
+                return false;
+            }
+            
+            return true;
+        }
+
+        #region IDataErrorInfo Members
+
+        public string Error
+        {
+            get { return string.Empty; }
+        }
+
+        public string this[string columnName]
+        {
+            get {
+                string errorMsg = null;
+                switch(columnName)
+                {
+                    case "Name":
+                        if (String.IsNullOrEmpty(Name))
+                        {
+                            errorMsg = "Name is required.";
+                        }
+                        break;
+                }
+                return errorMsg;
+            }
+        }
+
+        #endregion
     }
 }