public void UpdateTransitionHistory(Guid id, string currentState, string nextState, string command, Guid?employeeId)
        {
            using (var context = new Business.DataModelDataContext())
            {
                var historyItem =
                    context.DocumentTransitionHistories.FirstOrDefault(
                        h => h.DocumentId == id && !h.TransitionTime.HasValue &&
                        h.InitialState == currentState && h.DestinationState == nextState);

                if (historyItem == null)
                {
                    historyItem = new Business.DocumentTransitionHistory
                    {
                        Id = Guid.NewGuid(),
                        AllowedToEmployeeNames = string.Empty,
                        DestinationState       = nextState,
                        DocumentId             = id,
                        InitialState           = currentState
                    };

                    context.DocumentTransitionHistories.InsertOnSubmit(historyItem);
                }

                historyItem.Command        = command;
                historyItem.TransitionTime = DateTime.Now;
                historyItem.EmployeeId     = employeeId;

                context.SubmitChanges();
            }
        }
        public void WriteTransitionHistory(Guid id, string currentState, string nextState, string command, IEnumerable <string> identities)
        {
            using (var context = new Business.DataModelDataContext())
            {
                var historyItem = new Business.DocumentTransitionHistory
                {
                    Id = Guid.NewGuid(),
                    AllowedToEmployeeNames = GetEmployeesString(identities, context),
                    DestinationState       = nextState,
                    DocumentId             = id,
                    InitialState           = currentState,
                    Command = command
                };

                context.DocumentTransitionHistories.InsertOnSubmit(historyItem);
                context.SubmitChanges();
            }
        }