using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
using System.Windows;
using System.IO;

namespace BPASmartClient.ViewModel
{
    public class NewShopWindowModel : ObservableObject
    {

        public NewShopWindowModel()
        {
            CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CloseWindow"); });
            DefineCommand = new RelayCommand(() =>
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
                var files = directoryInfo.GetFiles();
                if (files != null && files.FirstOrDefault(p => p.FullName.Contains(ShopName)) != null)
                {
                    ErrorInfo = "已存在该店铺，请重新输入！";
                    return;
                }
                ActionManage.GetInstance.Send("ShopPar", new string[] { ShopName, ShopId });
                ActionManage.GetInstance.Send("OkCloseWindow");
            });
        }

        //public RelayCommand CloseWindowCommand { get; set; }

        public RelayCommand CancelCommand { get; set; }

        public RelayCommand DefineCommand { get; set; }

        public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } }
        private string _mShopName;

        public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } }
        private string _mShopId;

        public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
        private string _mErrorInfo;




    }
}
