Example #1
0
 public SimilarCustomerMessage(int id, CustomerTemp customerTemp, ICollection<Customer> customers)
 {
     this.id = id;
     this.CustomerTemp = customerTemp;
     this.Customers = customers;
 }
Example #2
0
 public MergeCustomer(CustomerTemp customertemp, int identyfikator)
 {
     this.CustomerTemp = customertemp;
     this.id = identyfikator;
 }
Example #3
0
        public CustomerViewModel(int CustomerID = 0, CustomerTemp ct = null )
        {
            int userId = ApplicationState.GetValue<Int32>("EmployeeID");
            this.ShowView2Command = new RelayCommand(this.ShowView2CommandExecute);  // ??
            this.db = new dbContext();
            this.Items = new Dictionary<string, object>();
            employeer = this.db.Employee.SingleOrDefault(item => item.EmployeeId == userId);

            this.SelectedItems = new Dictionary<string, object>();

            if (CustomerID == 0)
            {

                this.isNew = true;
                this.customer = new Customer();
                if (ct != null)
                {
                    this.ct = ct;
                    this.customer.AccountMarketer = db.Employee.SingleOrDefault(item => item.EmployeeId == userId);
                }
                this.customer.CreateDate = DateTime.Now;
                this.SelectedItems = new Dictionary<string, object>();

            }
            else
            {
                this.isNew = false;
                this.customer = this.db.Customer.Where(s => s.CustomerId == CustomerID).FirstOrDefault<Customer>();
                if (ct != null)
                {
                    this.ct = ct;
                    this.customer.AccountMarketer = db.Employee.SingleOrDefault(item => item.EmployeeId == userId);
                }
            }

            if (this.CustomerContact == null)
            {
                this.CustomerContactList = new ObservableCollection<CustomerContact>();
            }
            else
            {
                this.CustomerContactList = new ObservableCollection<oneCRM.Model.CustomerContact>(this.CustomerContact);
            }

            if (this.LogBook == null)
            {
                this.LogBookList = new ObservableCollection<Model.LogBook>();
            }
            else
            {
                this.LogBookList = new ObservableCollection<Model.LogBook>(this.LogBook);
            }

            if (this.CustomerAktywa == null)
            {
                this.CustomerAktywaList = new ObservableCollection<CustomerAktywa>();
            }
            else
            {
                this.CustomerAktywaList = new ObservableCollection<CustomerAktywa>(this.CustomerAktywa);
            }

            if (this.CustomerZatrudnienie == null)
            {
                this.CustomerZatrudnienieList = new ObservableCollection<CustomerZatrudnienie>();
            }
            else
            {
                this.CustomerZatrudnienieList = new ObservableCollection<CustomerZatrudnienie>(this.CustomerZatrudnienie);
            }

            if (this.CustomerPrzychody == null)
            {
                this.CustomerPrzychodyList = new ObservableCollection<CustomerPrzychody>();
            }
            else
            {
                this.CustomerPrzychodyList = new ObservableCollection<CustomerPrzychody>(this.CustomerPrzychody);
            }

            GetLists();
            Items.Clear();
            foreach (var item in CustomerGroupList)
            {
                Items.Add(item.Name, item);
            }
            SelectedItems.Clear();
            if(this.CustomerGroup != null)
            {
                foreach (CustomerGroup a in this.CustomerGroup.Where(item => item.isSelected == true))
                {
                    this.SelectedItems.Add(a.Name, a);
                }
            }
            db.SaveChanges();
        }