コード例 #1
0
        public MainWindowViewModel()
        {
            Repository         = new Repository();
            CreateNewProject   = new RelayCommand(ExecuteCreateNewProject);
            CreateNewTask      = new RelayCommand(ExecuteCreateNewTask, _ => SelectedProjectId != null);
            StartStopRecording = new RelayCommand(ExecuteStartStopRecording,
                                                  _ => SelectedProjectId.HasValue && SelectedTaskId.HasValue);
            DateStepBack      = new RelayCommand(ExecuteDateStepBack);
            DateStepForward   = new RelayCommand(ExecuteDateStepForward);
            SelectToday       = new RelayCommand(_ => SelectedDate = DateTime.Today, _ => SelectedDate != DateTime.Today);
            ExportCommand     = new RelayCommand(_ => SelectedTransitionIndex = Pages.ExportToExcel);
            SettingsCommand   = new RelayCommand(_ => SelectedTransitionIndex = Pages.Settings);
            QuickAdd          = new RelayCommand(ExecuteQuickAdd, _ => SelectedProjectId.HasValue && SelectedTaskId.HasValue);
            ExportViewModel   = new ExportViewModel(this);
            SettingsViewModel = new SettingsViewModel(this);
            LoadProjects();
            SelectedDate = DateTime.Today;
            var tr = Repository.GetLastTimeRecord();

            timer           = new DispatcherTimer();
            timer.Tick     += TimerOnTick;
            timer.Interval += TimeSpan.FromSeconds(1);

            if (tr != null && tr.EndTime == null)
            {
                var trVm = TimeRecords.FirstOrDefault(x => x.TimeRecord.Id == tr.Id) ??
                           new TimeRecordViewModel(tr, this);
                SelectedProjectId = tr.ProjectId;
                SelectedTaskId    = tr.TaskId;
                CurrentTimeRecord = trVm;
            }

            _ = SettingsViewModel.CheckForUpdateSequence();
        }
コード例 #2
0
            public async Task <bool> Handle(SaveTimeOutCommand request, CancellationToken cancellationToken)
            {
                var _timeOut = new TimeRecords
                {
                    EmployeeDetailsID = request.EmployeeID,
                    RecordType        = RecordType.TimeOut,
                    Time = DateTime.Now
                };

                dbContext.TimeRecords.Add(_timeOut);
                await dbContext.SaveChangesAsync();

                return(true);
            }
コード例 #3
0
        internal void Munge(List <WorkItemTimeRecord> records)
        {
            if (!records.All(x => records.First().Item == x.Item))
            {
                throw new InvalidOperationException("Records are not all from the same work item & cannot be munged");
            }
            var earliest  = records.OrderBy(x => x.StartTime).First();
            var latest    = records.OrderBy(x => x.EndTime).Last();
            var newRecord = new WorkItemTimeRecord()
            {
                StartTime     = earliest.StartTime,
                StartRevision = earliest.StartRevision,
                EndTime       = latest.EndTime,
                EndRevision   = earliest.EndRevision,
                Item          = earliest.Item
            };

            records.ForEach(x => TimeRecords.Remove(x));
            TimeRecords.Add(newRecord);
            TimeRecords = new ObservableCollection <TimeRecordBase>(TimeRecords.OrderBy(x => x.StartTime));
        }
コード例 #4
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + Id.GetHashCode();

                if (Number != null)
                {
                    hash = hash * 59 + Number.GetHashCode();
                }

                if (Status != null)
                {
                    hash = hash * 59 + Status.GetHashCode();
                }

                if (Equipment != null)
                {
                    hash = hash * 59 + Equipment.GetHashCode();
                }

                if (Project != null)
                {
                    hash = hash * 59 + Project.GetHashCode();
                }

                if (RentalAgreementRates != null)
                {
                    hash = hash * 59 + RentalAgreementRates.GetHashCode();
                }

                if (RentalAgreementConditions != null)
                {
                    hash = hash * 59 + RentalAgreementConditions.GetHashCode();
                }

                if (TimeRecords != null)
                {
                    hash = hash * 59 + TimeRecords.GetHashCode();
                }

                if (Note != null)
                {
                    hash = hash * 59 + Note.GetHashCode();
                }

                if (EstimateStartWork != null)
                {
                    hash = hash * 59 + EstimateStartWork.GetHashCode();
                }

                if (DatedOn != null)
                {
                    hash = hash * 59 + DatedOn.GetHashCode();
                }

                if (EstimateHours != null)
                {
                    hash = hash * 59 + EstimateHours.GetHashCode();
                }

                if (EquipmentRate != null)
                {
                    hash = hash * 59 + EquipmentRate.GetHashCode();
                }

                if (RatePeriod != null)
                {
                    hash = hash * 59 + RatePeriod.GetHashCode();
                }

                if (RateComment != null)
                {
                    hash = hash * 59 + RateComment.GetHashCode();
                }

                return(hash);
            }
        }
コード例 #5
0
        /// <summary>
        /// Returns true if RentalAgreement instances are equal
        /// </summary>
        /// <param name="other">Instance of RentalAgreement to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(RentalAgreement other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Number == other.Number ||
                     Number != null &&
                     Number.Equals(other.Number)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     Equipment == other.Equipment ||
                     Equipment != null &&
                     Equipment.Equals(other.Equipment)
                 ) &&
                 (
                     Project == other.Project ||
                     Project != null &&
                     Project.Equals(other.Project)
                 ) &&
                 (
                     RentalAgreementRates == other.RentalAgreementRates ||
                     RentalAgreementRates != null &&
                     RentalAgreementRates.SequenceEqual(other.RentalAgreementRates)
                 ) &&
                 (
                     RentalAgreementConditions == other.RentalAgreementConditions ||
                     RentalAgreementConditions != null &&
                     RentalAgreementConditions.SequenceEqual(other.RentalAgreementConditions)
                 ) &&
                 (
                     TimeRecords == other.TimeRecords ||
                     TimeRecords != null &&
                     TimeRecords.SequenceEqual(other.TimeRecords)
                 ) &&
                 (
                     Note == other.Note ||
                     Note != null &&
                     Note.Equals(other.Note)
                 ) &&
                 (
                     EstimateStartWork == other.EstimateStartWork ||
                     EstimateStartWork != null &&
                     EstimateStartWork.Equals(other.EstimateStartWork)
                 ) &&
                 (
                     DatedOn == other.DatedOn ||
                     DatedOn != null &&
                     DatedOn.Equals(other.DatedOn)
                 ) &&
                 (
                     EstimateHours == other.EstimateHours ||
                     EstimateHours != null &&
                     EstimateHours.Equals(other.EstimateHours)
                 ) &&
                 (
                     EquipmentRate == other.EquipmentRate ||
                     EquipmentRate != null &&
                     EquipmentRate.Equals(other.EquipmentRate)
                 ) &&
                 (
                     RatePeriod == other.RatePeriod ||
                     RatePeriod != null &&
                     RatePeriod.Equals(other.RatePeriod)
                 ) &&
                 (
                     RateComment == other.RateComment ||
                     RateComment != null &&
                     RateComment.Equals(other.RateComment)
                 ));
        }