Пример #1
0
        public IDictionary <StatusChange, TimeSpan> TimeBetweenStatusChanges(IEnumerable <DocumentHistoryEntry> history)
        {
            var result = new Dictionary <StatusChange, TimeSpan>();
            DocumentHistoryEntry previousEntry = null;

            foreach (var nextEntry in history)
            {
                if (previousEntry != null && previousEntry.Status.HasValue)
                {
                    if (nextEntry.Status.HasValue)
                    {
                        var change = new StatusChange(previousEntry.Status.Value, nextEntry.Status.Value);
                        var time   = nextEntry.Created - previousEntry.Created;

                        if (!result.ContainsKey(change))
                        {
                            result[change] = time;
                        }
                        else
                        {
                            result[change] += time;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                previousEntry = nextEntry;
            }
            return(result);
        }
 public async Task WriteEntry(Document document, PersonProfile profile, string description, Repository baseRepository)
 {
     var repository = new Repository <DocumentHistoryEntry>(baseRepository);
     var entry      = new DocumentHistoryEntry()
     {
         Document    = document,
         Status      = document.Status,
         ChangedBy   = profile,
         Date        = DateTime.Now,
         Description = description
     };
     await repository.InsertAsync(entry);
 }