using System.ComponentModel;
using System.Windows;
using OrderEntryEngine;
using OrderEntrySystem.Reflection;

namespace OrderEntrySystem
{
    public class LocationViewModel : EntityViewModel<Location>, IDataErrorInfo
    {
        public LocationViewModel(Location location)
            : base("New location", location)
        {
        }

        public string Error
        {
            get
            {
                return this.Entity.Error;
            }
        }

        [EntityControl(ControlType.TextBox, "Name", 1), EntityColumn("Name", 1)]
        public string Name
        {
            get
            {
                return this.Entity.Name;
            }

            set
            {
                this.Entity.Name = value;
                this.OnPropertyChanged("Name");
            }
        }

        [EntityControl(ControlType.TextBox, "Description", 2), EntityColumn("Description", 2)]
        public string Description
        {
            get
            {
                return this.Entity.Description;
            }

            set
            {
                this.Entity.Description = value;
                this.OnPropertyChanged("Description");
            }
        }

        [EntityControl(ControlType.TextBox, "City", 3), EntityColumn("City", 3)]
        public string City
        {
            get
            {
                return this.Entity.City;
            }

            set
            {
                this.Entity.City = value;
                this.OnPropertyChanged("City");
            }
        }

        [EntityControl(ControlType.TextBox, "State", 4), EntityColumn("State", 4)]
        public string State
        {
            get
            {
                return this.Entity.State;
            }

            set
            {
                this.Entity.State = value;
                this.OnPropertyChanged("State");
            }
        }

        public string this[string propertyName]
        {
            get
            {
                return this.Entity[propertyName];
            }
        }
    }
}