Пример #1
0
        /// <summary>
        /// Creates a Timeentry, assigned to the given task
        /// </summary>
        /// <param name="task">The task.</param>
        /// <returns></returns>
        /// <exception cref="MandatoryParameterMissingException"></exception>
        public static TimeEntry Create(Task task, TimeEntryType timeEntryType)
        {
            return(Create(
                       System.Guid.NewGuid(),
                       task,
                       timeEntryType,
                       0d,
                       0d,
                       string.Empty,
                       DateTime.Now,
                       DateTime.Now,
                       0d,
                       false,
                       string.Empty,
                       true,

                       false));
        }
Пример #2
0
        private void FixupTimeEntryType(TimeEntryType previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.TimeEntries.Contains(this))
            {
                previousValue.TimeEntries.Remove(this);
            }

            if (TimeEntryType != null)
            {
                if (!TimeEntryType.TimeEntries.Contains(this))
                {
                    TimeEntryType.TimeEntries.Add(this);
                }

                TimeEntryTypeId = TimeEntryType.TimeEntryTypeId;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("TimeEntryType") &&
                    (ChangeTracker.OriginalValues["TimeEntryType"] == TimeEntryType))
                {
                    ChangeTracker.OriginalValues.Remove("TimeEntryType");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("TimeEntryType", previousValue);
                }
                if (TimeEntryType != null && !TimeEntryType.ChangeTracker.ChangeTrackingEnabled)
                {
                    TimeEntryType.StartTracking();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Creates the specified timeentry, by the given parameters.
        /// </summary>
        /// <param name="guid">The GUID.</param>
        /// <param name="task">The task.</param>
        /// <param name="timeSpent">The time spent.</param>
        /// <param name="billableTime">The billable time.</param>
        /// <param name="description">The description.</param>
        /// <param name="createDate">The create date.</param>
        /// <param name="startTime">The start time.</param>
        /// <param name="endTime">The end time.</param>
        /// <param name="pricePrHour">The price pr hour.</param>
        /// <param name="isSynced">if set to <c>true</c> [is synced].</param>
        /// <param name="syncResponse">The sync response.</param>
        /// <param name="billable">if set to <c>true</c> [billable].</param>
        /// <returns></returns>
        /// <exception cref="MandatoryParameterMissingException"></exception>
        public static TimeEntry Create(Guid guid, Task task, TimeEntryType timeEntryType, double timeSpent, double billableTime, string description, DateTime startTime, DateTime endTime, double pricePrHour, bool isSynced, string syncResponse, bool billable, bool isStopped)
        {
            //if (task == null)
            //    throw new MandatoryParameterMissingException("Error creating Timeentry: Task cannot be null");

            return(new TimeEntry
            {
                Guid = guid,
                TimeEntryType = timeEntryType,
                BillableTime = billableTime,
                TimeSpent = timeSpent,
                Description = description,
                Task = task,
                IsStopped = isStopped,

                Price = 0d,
                //CreatedDate = createDate,
                StartTime = startTime,
                EndTime = endTime,
                IsSynced = isSynced,

                Billable = billable,
            });
        }