Esempio n. 1
0
 public AddEmployeeViewModel()
 {
     IsEdit           = false;
     ButtonLabel      = "Add";
     Ranks            = RankService.GetAllBindableCollection();
     Specializations  = SpecializationService.GetAllBindableCollection();
     DateOfEmployment = DateTime.Now;
     NotifyOfPropertyChange(() => DateOfEmployment);
 }
Esempio n. 2
0
        public AddEmployeeViewModel(EmployeeDTO employee)
        {
            IsEdit          = true;
            ButtonLabel     = "Edit";
            Ranks           = RankService.GetAllBindableCollection();
            Specializations = SpecializationService.GetAllBindableCollection();
            int i = 0;

            if (employee.RankId != null)
            {
                while (ActualRank == null)
                {
                    if (Ranks[i].Id == employee.RankId)
                    {
                        ActualRank = i;
                        break;
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            if (employee.SpecializationId != null)
            {
                int j = 0;
                while (ActualSpecialization == null)
                {
                    if (Specializations[j].Id == employee.SpecializationId)
                    {
                        ActualSpecialization = j;
                        break;
                    }
                    else
                    {
                        j++;
                    }
                }
            }

            this.toEdit      = employee;
            NationalId       = employee.NationalId;
            FirstName        = employee.FirstName;
            LastName         = employee.LastName;
            Salary           = employee.Salary;
            DateOfEmployment = employee.DateOfEmployment;
            NotifyOfPropertyChange(() => NationalId);
            NotifyOfPropertyChange(() => FirstName);
            NotifyOfPropertyChange(() => LastName);
            NotifyOfPropertyChange(() => Salary);
            NotifyOfPropertyChange(() => DateOfEmployment);
        }