public List <UserStoryAttachment> CloseSprint(Sprint sprint, string userId)
        {
            var diagrams = new List <UserStoryAttachment>();
            TransactionOptions _transcOptions = new TransactionOptions();

            _transcOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required, _transcOptions, EnterpriseServicesInteropOption.Full))
            {
                try
                {
                    uRepository.Close(sprint, userId);
                    #region lock diagrams
                    DiagramService dService = (DiagramService) new ServiceLocator <Attachment>().locate();
                    diagrams = dService.FindBySprint(sprint.Id);
                    dService.LockDiagrams(diagrams, userId);
                    #endregion
                    sc.Complete();
                }
                catch (Exception ex)
                {
                    throw new BadRequestException(AppConstants.EXCEPTION_SPRINT_CLOSE_ERROR);
                }
                finally
                {
                    sc.Dispose();
                }
            }
            return(diagrams);
        }
        public void OpenSprint(Sprint sprint, string userId)
        {
            sprint.state = AppConstants.SPRINT_STATUS_OPEN;
            TransactionOptions _transcOptions = new TransactionOptions();

            _transcOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required, _transcOptions, EnterpriseServicesInteropOption.Full))
            {
                try
                {
                    uRepository.UpdateStateAndVersion(sprint);
                    #region unlock diagrams
                    DiagramService dService = (DiagramService) new ServiceLocator <Attachment>().locate();
                    var            diagrams = dService.FindBySprint(sprint.Id);
                    dService.UnLockDiagrams(diagrams, userId);
                    #endregion
                    sc.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    sc.Dispose();
                }
            }
        }
        public void FinishStory(UserStory story, string userId)
        {
            TransactionOptions _transcOptions = new TransactionOptions();

            _transcOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required, _transcOptions, EnterpriseServicesInteropOption.Full))
            {
                try
                {
                    story.state = AppConstants.USERSTORY_STATUS_FINISIHED;
                    uRepository.UpdateState(story);

                    #region Save to history
                    uRepository.SaveToHistory(story, userId);
                    #endregion
                    #region lock diagrams
                    DiagramService dService = (DiagramService) new ServiceLocator <Attachment>().locate();
                    var            diagrams = dService.FindByUserStory(story.Id);
                    dService.LockDiagrams(diagrams, userId);
                    #endregion


                    sc.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(AppConstants.EXCEPTION_GLOBAL);
                }
                finally
                {
                    sc.Dispose();
                }
            }
        }