示例#1
0
        public JsonNetResult AddEntry(int recordId, TimeRecordEntry entry)
        {
            var timeRecord = _timeRecordRepository.GetNullableById(recordId);

            Check.Require(timeRecord != null, "Invalid time record identifier");

            Check.Require(_timeRecordBLL.HasAccess(CurrentUser, timeRecord),
                          "Current user does not have access to this record");

            timeRecord.AddEntry(entry);//Add the entry to the time record

            Check.Require(entry.IsValid(), "Entry is not valid");

            _timeRecordRepository.EnsurePersistent(timeRecord);

            _timeRecordRepository.DbContext.CommitTransaction();

            var modificationResult = new TimeRecordEntryModificationDto(entry.Id, entry.Hours);

            return new JsonNetResult(modificationResult);
        }
示例#2
0
        public JsonNetResult EditEntry(int entryId, TimeRecordEntry entry)
        {
            var entryRepository = Repository.OfType<TimeRecordEntry>();

            var entryToUpdate = entryRepository.GetNullableById(entryId);

            Check.Require(entryToUpdate != null, "Entry not found");

            var originalHours = entryToUpdate.Hours;

            TransferValuesTo(entryToUpdate, entry);

            Check.Require(entryToUpdate.IsValid(), "Entry is not valid");

            entryRepository.EnsurePersistent(entryToUpdate);

            var modificationResult = new TimeRecordEntryModificationDto(entryToUpdate.Id, entryToUpdate.Hours - originalHours);

            return new JsonNetResult(modificationResult);
        }
示例#3
0
 /// <summary>
 /// Transfer the new values from the given entry to the entry to update.
 /// Currently you can only update the comment, hours, and activity type
 /// </summary>
 private static void TransferValuesTo(TimeRecordEntry entryToUpdate, TimeRecordEntry entry)
 {
     entryToUpdate.Comment = entry.Comment;
     entryToUpdate.Hours = entry.Hours;
     entryToUpdate.ActivityType = entry.ActivityType;
 }
示例#4
0
        private void AddEntry(TimeRecordEntry timeSheetEntry)
        {
            // First find the day matching the time sheet entry
            foreach (TimeRecordCalendarDay d in _days)
            {
                // Match the day and the month
                if (_month == d.Month && timeSheetEntry.Date == d.Day)
                {
                    // Add the entry into the day object
                    d.Entries.Add(timeSheetEntry);

                    // We can end the function now
                    return;
                }
            }
        }