Exemplo n.º 1
0
        public void AddTeacherPayrollRecord(object t)
        {
            var teacher = t as Teacher;

            var record = new PayrollRecord {
                Teacher = teacher, HoursCount = 0, Rate = teacher.Rate, Payroll = _payroll, Retenu = 0.15
            };

            if (_payroll.Records == null)
            {
                _payroll.Records = new List <PayrollRecord>();
            }
            _payroll.Records.Add(record);
            if (_payroll.Records.FirstOrDefault(r => r.TeacherId == teacher.Id) == null)
            {
                context.PayrollRecords.Add(record);
                context.SaveChanges();
            }

            if (teacher.Status == TeacherStatus.Permanent)
            {
                return;
            }
            if (_payrollRecords == null)
            {
                _payrollRecords = new ObservableCollection <PayrollRecordViewModel>();
            }
            _payrollRecords.Add(PayrollRecordViewModel.FromPayrollRecord(record));

            if (PropertyChanged != null)
            {
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(PayrollRecords)));
            }
        }
Exemplo n.º 2
0
        public void UpdatePayrollRecord(PayrollRecordViewModel payrollRecordVM)
        {
            if (_payrollRecords == null)
            {
                return;
            }
            var pr = _payrollRecords.FirstOrDefault(pr => pr.Id == payrollRecordVM.Id);

            if (pr != null)
            {
                pr.HoursCount        = payrollRecordVM.HoursCount;
                pr.Record.HoursCount = payrollRecordVM.HoursCount;
            }
            else
            {
                _payroll.Records.Add(payrollRecordVM.Record);
                _payrollRecords.Add(payrollRecordVM);
            }
        }