Example #1
0
 /// <summary>
 /// Initializes a new instance of the ContentViewDecorator class with view model and data context.
 /// </summary>
 /// <param name="model">The content view model.</param>
 /// <param name="dataContext">The data context object.</param>
 public ContentViewDecorator(ContentView model, IDataContext dataContext)
 {
     Model = model;
     model.CopyTo(this, "Parent", "FieldRefs", "Roles");
     Context = dataContext;
     this.Parent = new ContentListDecorator(dataContext, model.Parent);
 }
 public DevelopmentDefaultData(IOptions<DevelopmentSettings> options, IDataContext dataContext, UserManager<User> userManager, RoleManager<Role> roleManager)
 {
     this.settings = options.Value;
     this.dataContext = dataContext;
     this.userManager = userManager;
     this.roleManager = roleManager;
 }
        public static async Task<FeatureMappingViewModel> GetModel(IDataContext context,
                                                                      FeatureMappingFilter filter)
        {
            FeatureMappingViewModel model;

            if (filter.Action == FeatureMappingAction.Delete 
                || filter.Action == FeatureMappingAction.Mapping
                || filter.Action == FeatureMappingAction.Copy)
            {
                model = await GetFullAndPartialViewModelForFeatureMapping(context, filter);
            }
            else if (filter.Action == FeatureMappingAction.Mappings ||
                filter.Action == FeatureMappingAction.CopyAll)
            {
                model = await GetFullAndPartialViewModelForFeatureMappings(context, filter);
            }
            else if (filter.Action == FeatureMappingAction.FeatureCodes)
            {
                model = await GetFullAndPartialViewModelForFeatureCodes(context, filter);
            }
            else
            {
                model = GetFullAndPartialViewModel(context, filter);
            }
            if (filter.Action != FeatureMappingAction.NotSet)
            {
                model.IdentifierPrefix = Enum.GetName(filter.Action.GetType(), filter.Action);
            }
            return model;
        }
 protected ApplicationApiController(
     IDataContext dataContext,
     Func<int> getUserId)
 {
     this.DataContext = dataContext;
     this.UserId = getUserId();
 }
        /// <summary>
        ///     Sets errors for binding target.
        /// </summary>
        /// <param name="target">The binding target object.</param>
        /// <param name="errors">The collection of errors</param>
        /// <param name="context">The specified context, if any.</param>
        protected override sealed void SetErrors(object target, IList<object> errors, IDataContext context)
        {
            base.SetErrors(target, errors, context);
            var control = target as Control;
            if (control == null)
                return;
            Control rootControl = PlatformExtensions.GetRootControl(control);
            if (rootControl == null)
                return;
            ErrorProvider errorProvider = GetErrorProviderInternal(rootControl);
            if (errorProvider == null)
                return;

            var oldProvider = ServiceProvider
                .AttachedValueProvider
                .GetValue<ErrorProvider>(target, ErrorProviderName, false);
            if (!ReferenceEquals(oldProvider, errorProvider))
            {
                if (oldProvider != null)
                {
                    oldProvider.SetError(control, null);
                    TryDispose(oldProvider);
                }
                ServiceProvider.AttachedValueProvider.SetValue(control, ErrorProviderName, errorProvider);
                if (errorProvider.Tag == null)
                    errorProvider.Tag = 1;
                else if (errorProvider.Tag is int)
                    errorProvider.Tag = (int)errorProvider.Tag + 1;
            }
            SetErrors(control, errorProvider, errors, context);
        }
        void EnsureDataContext()
        {
            if (_dataContext != null)
                return;

            _dataContext = (IDataContext)IoC.GetInstance(null, Key);
        }
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            var textControl = context.GetData(DataConstants.TEXT_CONTROL);
            GC.KeepAlive(textControl);

            DateTime lastInvocation, utcNow = DateTime.UtcNow;
            lock (syncLock)
            {
                lastInvocation = this.lastLocateInvocation;
                this.lastLocateInvocation = utcNow;
            }

            const int doubleKeyPressDelay = 500;
            if (utcNow.Subtract(lastInvocation).TotalMilliseconds < doubleKeyPressDelay)
            {
                var locateFileAction = actionManager.TryGetAction(LocateFileAction.Id) as IExecutableAction;
                if (locateFileAction != null)
                {
                    locateFileAction.Execute(context);
                    return;
                }
            }

            if (lastUnderlyingActionUpdate)
            {
                nextExecute();
            }
        }
        public void RecalculatePoints(IDataContext dataContext, IPointsCalculator pointsCalculator, List<PlayedGameToRecalculate> playedGamesToRecalculate)
        {
            int counter = 0;
            foreach (var playedGame in playedGamesToRecalculate)
            {
                var playerRanks = playedGame.PlayerGameResults.Select(x => new PlayerRank
                {
                    PlayerId = x.PlayerId,
                    GameRank = x.GameRank
                }).ToList();

                var newPoints = pointsCalculator.CalculatePoints(playerRanks, playedGame.BoardGameGeekGameDefinition);

                var applicationUserForThisGamingGroup = new ApplicationUser()
                {
                    CurrentGamingGroupId = playedGame.GamingGroupId
                };

                foreach (var playerGameResult in playedGame.PlayerGameResults)
                {
                    var scorecard = newPoints[playerGameResult.PlayerId];
                    playerGameResult.NemeStatsPointsAwarded = scorecard.BasePoints;
                    playerGameResult.GameDurationBonusPoints = scorecard.GameDurationBonusPoints;
                    playerGameResult.GameWeightBonusPoints = scorecard.GameWeightBonusPoints;
                    dataContext.Save(playerGameResult, applicationUserForThisGamingGroup);
                }

                Debug.WriteLine("{0} games updated... last PlayedGame.Id is {1}", ++counter, playedGame.PlayedGameId);
            }
        }
        private void Compose(IDataContext value)
        {
            foreach(var child in transform)
            {
                var go = ((Transform)child).gameObject;
                go.SetActive(false);
            }

            _composedDataContext = value;

            if(value != null)
            {
                var name = value.GetType().Name;

                foreach(var child in transform)
                {
                    var go = ((Transform)child).gameObject;

                    if (go.name != name)
                        continue;

                    go.SetActive(true);
                    break;
                }
            }

            BroadcastDataContextChange(_composedDataContext);
        }
        /// <summary>
        /// Executes action. Called after Update, that set <c>ActionPresentation.Enabled</c> to true.
        /// </summary>
        /// <param name="solution">The solution.</param>
        /// <param name="context">The context.</param>
        protected override void Execute(ISolution solution, IDataContext context)
        {
            if (!context.CheckAllNotNull(DataConstants.SOLUTION)) {
                return;
            }

            ITextControl textControl = context.GetData(DataConstants.TEXT_CONTROL);
            if (textControl == null) {
                return;
            }

            IElement element = GetElementAtCaret(context);
            if (element == null) {
                return;
            }

            var enumDeclaration = element.ToTreeNode().Parent as IEnumDeclaration;
            if (enumDeclaration == null) {
                return;
            }

            using (ModificationCookie cookie = textControl.Document.EnsureWritable()) {
                if (cookie.EnsureWritableResult != EnsureWritableResult.SUCCESS) {
                    return;
                }

                using (CommandCookie.Create("Context Action Sort Enum By Name")) {
                    PsiManager.GetInstance(solution).DoTransaction(delegate { Execute(solution, enumDeclaration); });
                }
            }
        }
        public void Handle(ref string bindingExpression, IDataContext context)
        {
            foreach (var replaceKeyword in ReplaceKeywords)
                bindingExpression = bindingExpression.Replace(replaceKeyword.Key, replaceKeyword.Value);

            if (!bindingExpression.Contains("$\"") && !bindingExpression.Contains("$'"))
                return;
            Dictionary<string, string> dict = null;
            InterpolatedStringTokenizer.SetSource(bindingExpression);
            while (InterpolatedStringTokenizer.Token != TokenType.Eof)
            {
                int start;
                int end;
                var exp = ParseInterpolatedString(InterpolatedStringTokenizer, out start, out end);
                if (exp != null)
                {
                    if (dict == null)
                        dict = new Dictionary<string, string>();
                    dict[bindingExpression.Substring(start, end - start)] = exp;
                }
            }
            if (dict != null)
            {
                foreach (var s in dict)
                {
                    if (s.Value != null)
                        bindingExpression = bindingExpression.Replace(s.Key, s.Value);
                }
            }
        }
    /// <summary>Executes action. Called after Update, that set ActionPresentation.Enabled to true.</summary>
    /// <param name="context">The data context.</param>
    /// <param name="nextExecute">delegate to call</param>
    public void Execute(IDataContext context, [CanBeNull] DelegateExecute nextExecute)
    {
      if (context == null)
      {
        throw new ArgumentNullException("context");
      }

      if (!AtLeadInWhitespace(context))
      {
        if (nextExecute != null)
        {
          nextExecute();
        }

        return;
      }

      var service = Shell.Instance.GetComponent<AutoTemplatesService>();
      var settings = service.GetSettings();
      if (!settings.GetUseCompleteStatement())
      {
        return;
      }

      var actionManager = Shell.Instance.GetComponent<ActionManager>();
      var action = actionManager.TryGetAction("Generate") as IExecutableAction;
      if (action != null)
      {
        action.Execute(context);
      }
    }
Example #13
0
        /// <summary>
        /// Updates the property value.
        /// </summary>
        /// <param name="dataContext">
        /// The data context.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        public void Update(IDataContext dataContext, object target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            Property.SetValue(target, ValueCalculator.GetValue(dataContext));
        }
        private static string GetSessionId(IDataContext context)
        {
            UnitTestSession session = GetUnitTestSession(context);
            if (session == null)
                return null;

#if ! RESHARPER_50_OR_NEWER || RESHARPER_60_OR_NEWER
            return session.ID;
#else
            // HACK: Get the last RunId for correlation instead of the SessionId because the SessionId is
            // not available to the task runner in R# 5.0 but the RunId is, so we use that for correlation.
            // Unfortunately runs are transient so they are deleted after tests finish.  However before that
            // happens, the Update method will be called many times to update UI state so we should be able
            // to catch the run in flight and save it for later.
            //
            // I have asked JetBrains to provide SessionId info to TaskRunners in a future release
            // as it was done in R# 3.1. -- Jeff.
            foreach (IUnitTestRun run in session.Runs)
            {
                string runId = run.ID;
                LastRunIdCache[session.ID] = runId;
                return runId;
            }

            string lastRunId;
            LastRunIdCache.TryGetValue(session.ID, out lastRunId);
            return lastRunId;
#endif
        }
 public UnitOfWork(IDataContext dataContext, IUnitOfWorkManager manager)
 {
     State = UnitOfWorkState.Active;
     DataContext = dataContext;
     Manager = manager;
     Manager.Add(this);
 }
 public ControllerBase(IDataContext context)
 {
     DataContext = context;
     
     PageIndex = 0;
     PageSize = ConfigurationSettings.GetInteger("DefaultPageSize");
 }
Example #17
0
        public void insert()
        {
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                insertKategorijeGimnasticara();
                insertKluboviIMesta();
                insertDrzave();
                insertGimnasticari();
                insertRegistrovaniGimnasticari();
                insertSudije();

                dataContext.Commit();
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
        public static async Task<DerivativeViewModel> GetModel(IDataContext context, DerivativeFilter derivativeFilter)
        {
            DerivativeViewModel model = null;

            if (derivativeFilter.Action == DerivativeAction.Delete || derivativeFilter.Action == DerivativeAction.Derivative)
            {
                model = await GetFullAndPartialViewModelForDerivative(context, derivativeFilter);
            }
            else if (derivativeFilter.Action == DerivativeAction.Derivatives)
            {
                model = await GetFullAndPartialViewModelForDerivatives(context, derivativeFilter);
            }
            else if (derivativeFilter.Action == DerivativeAction.OxoDerivatives)
            {
                model = GetFullAndPartialViewModelForOxoDerivatives(context, derivativeFilter);
            }
            else
            {
                model = GetFullAndPartialViewModel(context, derivativeFilter);
            }
            if (derivativeFilter.Action != DerivativeAction.NotSet)
            {
                model.IdentifierPrefix = Enum.GetName(derivativeFilter.Action.GetType(), derivativeFilter.Action);
            }
           
            return model;
        }
 private static async Task<DerivativeViewModel> GetFullAndPartialViewModelForDerivative(IDataContext context,
                                                                                        DerivativeFilter filter)
 {
     var model = new DerivativeViewModel()
     {
         PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1,
         PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : Int32.MaxValue,
         Configuration = context.ConfigurationSettings
     };
     var derivative = await context.Vehicle.GetFdpDerivative(filter);
     var programmeFilter = new ProgrammeFilter()
     {
         ProgrammeId = derivative.ProgrammeId,
         Gateway = derivative.Gateway
     };
     HydrateModelWithCommonProperties(model, context, programmeFilter);
     
     if (!(derivative is EmptyFdpDerivative))
     {
         derivative.Programme = model.Programmes.FirstOrDefault(p => p.Id == derivative.ProgrammeId.GetValueOrDefault());
         derivative.Body = model.Bodies.FirstOrDefault(b => b.Id == derivative.BodyId);
         derivative.Engine = model.Engines.FirstOrDefault(e => e.Id == derivative.EngineId);
         derivative.Transmission = model.Transmissions.FirstOrDefault(t => t.Id == derivative.TransmissionId);
     }
     model.Derivative = derivative;
    
     return model;
 }
 public static IEnumerable<ValidationResult> Persist(IDataContext context,
     TakeRateFilter filter,
     FluentValidation.Results.ValidationResult results,
     bool global)
 {
     return context.TakeRate.PersistValidationErrors(filter, results, global);
 }
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            var injector = PlatformObsoleteStatics.Instance.GetComponent<FileInjectedLayers>();
            if (injector == null)
            {
                throw new ApplicationException("Could not get FileInjectedLayers instance!");
            }

            var file = new FileSystemPath(SettingsFilePath);

            var settingsLayers = PlatformObsoleteStatics.Instance.GetComponent<UserInjectedSettingsLayers>();
            if (settingsLayers == null)
            {
                throw new ApplicationException("Could not get UserInjectedSettingsLayers instance!");
            }

            var layers = settingsLayers.GetUserInjectedLayersFromHost(_globalSettings.ProductGlobalLayerId);
            foreach (var layer in layers)
            {
                // TODO: find out if there's an easier way to check if this is layer we want, e.g. by id
                settingsLayers.TurnInjectedLayerOnOff(layer.Id, layer.Name == LayerName);
            }

            if (!injector.IsLayerInjected(_globalSettings.ProductGlobalLayerId, file))
            {
                injector.InjectLayer(_globalSettings.ProductGlobalLayerId, file);
            }
        }
 protected override string GenerateContent(IDataContext context, string outputFolder)
 {
     var bound = context.GetComponent<ISettingsStore>().BindToContextTransient(ContextRange.ApplicationWide);
       foreach (TemplateApplicability applicability in Enum.GetValues(typeof(TemplateApplicability)))
     CreateXml(applicability, bound, outputFolder, GeneralHelpers.GetCurrentVersion(), context);
       return "Code templates";
 }
        public override bool IsAvailable(IDataContext context)
        {
            IList<ITypeMember> typeMembers;
            ITypeElement ownerType;
            var moveStaticMembersIsAvailable = IsAvailable(context, out typeMembers, out ownerType);
            if (!moveStaticMembersIsAvailable) return false;
            Methods = new List<IMethod>();

            foreach (var typeMember in typeMembers) {
                var method = typeMember != null ? typeMember as IMethod : null;
                if (method == null) return false;

                // Do a quick check to see if Extension Methods are allowed.
                var methodDeclaration = method.GetDeclarations().FirstOrDefault();
                if (methodDeclaration != null) {
                    var treeNode = methodDeclaration.CreateTreeElementPointer().GetTreeNode();
                    if (treeNode != null && !treeNode.IsVB9Supported()) return false;
                }

                if (!method.IsStatic || method.Parameters.None() || method.Parameters.First().Kind != ParameterKind.VALUE) return false;
                if (method.IsExtensionMethod ^ Direction == WorkflowDirection.ExtensionToShared) return false;

                Methods.Add(method);
            }

            return true;
        }
        //[OperationBehavior(Impersonation=ImpersonationOption.Required)]
        public async Task<ImportQueue> ProcessQueuedItem(int importQueueId)
        {
            Console.WriteLine("ProcessQueuedItem: {0}", importQueueId);

            DataContext = DataContextFactory.CreateDataContext(WindowsIdentity.GetCurrent().Name);
            return await DataContext.Import.GetImportQueue(new ImportQueueFilter(importQueueId));
        }
 public static EngineCodeMappingViewModel GetModel(IDataContext context)
 {
     return new EngineCodeMappingViewModel()
     {
         Configuration = context.ConfigurationSettings
     };
 }
 private static async Task<MarketMappingViewModel> GetFullAndPartialViewModelForMarketMapping
 (
     IDataContext context,
     MarketMappingFilter filter
 )
 {
     var baseModel = SharedModelBase.GetBaseModel(context);
     var model = new MarketMappingViewModel()
     {
         PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1,
         PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : Int32.MaxValue,
         Configuration = context.ConfigurationSettings,
         CurrentUser = baseModel.CurrentUser,
         CurrentVersion = baseModel.CurrentVersion
     };
     var marketMapping = await context.Market.GetFdpMarketMapping(filter);
     var programmeFilter = new ProgrammeFilter()
     {
         ProgrammeId = marketMapping.ProgrammeId,
         Gateway = marketMapping.Gateway,
         Code = model.MarketMapping.Programme.VehicleName // In order to filter the gateways specific to the programme
     };
     HydrateModelWithCommonProperties(model, context, programmeFilter);
     model.Gateways = context.Vehicle.ListGateways(programmeFilter);
     
     if (!(marketMapping is EmptyFdpMarketMapping))
     {
         marketMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == marketMapping.ProgrammeId.GetValueOrDefault());
     }
     model.MarketMapping = marketMapping;
    
     return model;
 }
 // Hides the menu item if it's not a Unity project
 public override bool IsAvailable(IDataContext dataContext)
 {
     var project = dataContext.GetData(ProjectModelDataConstants.PROJECT);
     if (project == null || !project.IsUnityProject())
         return false;
     return base.IsAvailable(dataContext);
 }
        private static ITypeElement GetOriginTypeElement(IDataContext dataContext, DeclaredElementTypeUsageInfo initialTarget)
        {
            var data = dataContext.GetData(DataConstants.REFERENCES);
            if (data == null) {
                return null;
            }

            foreach (var current in data.OfType<IQualifiableReference>()) {
                if (!Equals(current.Resolve().DeclaredElement, initialTarget)) {
                    continue;
                }

                var qualifierWithTypeElement = current.GetQualifier() as IQualifierWithTypeElement;

                if (qualifierWithTypeElement == null) {
                    continue;
                }

                var qualifierTypeElement = qualifierWithTypeElement.GetQualifierTypeElement();
                if (qualifierTypeElement != null) {
                    return qualifierTypeElement;
                }
            }
            return null;
        }
        public void initialize(Nullable<Gimnastika> gimnastika)
        {
            initializing = true;
            this.gimnastika = gimnastika;
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();
                loadData();
                initUI();

                //dataContext.Commit();

                initializing = false;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
        public bool IsAvailable(IDataContext dataContext)
        {
            // todo make this resolvable also via the AllTypes... line
            var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();

            return cachedRegistrations.Any(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
        }
Example #31
0
 /// <summary>
 /// Initializes a new instance of the RoleManager with data context.
 /// </summary>
 /// <param name="context">The data context object.</param>
 public RoleManager(IDataContext context)
 {
     this.DataContext = context;
 }
 public AccountRepository(IDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Example #33
0
 public static string GetFKName <T>(this IDataContext self, string listFieldName) where T : class
 {
     return(GetFKName(self, typeof(T), listFieldName));
 }
Example #34
0
 public DealerService(IDataContext context, SecurityContext security) : base(context, security)
 {
 }
 public GameDefinitionRetriever(IDataContext dataContext, IPlayerRepository playerRepository, IBoardGameGeekGameDefinitionInfoRetriever boardGameGeekGameDefinitionInfoRetriever)
 {
     _dataContext      = dataContext;
     _playerRepository = playerRepository;
     _boardGameGeekGameDefinitionInfoRetriever = boardGameGeekGameDefinitionInfoRetriever;
 }
Example #36
0
 public VesselScheduleService(IDataContext dataContext) : base(dataContext)
 {
 }
Example #37
0
 public QuestionNotification(
     IByDisciplinesNotifiable notifiable,
     IDataContext context)
     : base(notifiable, context, context.QuestionNewsStorage)
 {
 }
        protected override ISourceValue ResolveObjectInternal(object target, string name, IDataContext context, out bool keepValue)
        {
            var value = base.ResolveObjectInternal(target, name, context, out keepValue);

            if (value != null)
            {
                return(value);
            }

            keepValue = true;
            var item = TryFindResource(target, name);

            if (item != null)
            {
                return(new BindingResourceObject(item, true));
            }

            var rootMember = BindingServiceProvider.VisualTreeManager.GetRootMember(target.GetType());

            if (rootMember != null)
            {
                return(new XamlResourceWrapper(target, name, rootMember, GetOrAddDynamicResource(name, false)));
            }
            return(null);
        }
Example #39
0
 protected virtual IWindowViewMediator CreateWindowViewMediator([NotNull] IViewModel viewModel, Type viewType, [NotNull] IDataContext context)
 {
     return(TryCreateMediatorFromFactory(viewModel, viewType, context));
 }
 internal BlogSqlDataProvider(IDataContext context, IModelDataService <DataModel.VPost> modelDataService)
     : base(context)
 {
     _modelDataService = modelDataService ?? throw new ArgumentNullException(nameof(modelDataService));
 }
Example #41
0
 public Task WaitCurrentNavigationAsync(IDataContext context = null)
 {
     return(_currentTask ?? Empty.Task);
 }
Example #42
0
 private void Show(IWindowViewMediator viewMediator, IAsyncOperation operation, IDataContext context, TaskCompletionSource <bool> tcs)
 {
     try
     {
         CallbackManager.Register(OperationType.WindowNavigation, viewMediator.ViewModel, operation.ToOperationCallback(), context);
         var task = viewMediator.ShowAsync(context);
         _currentTask = task;
         tcs.TrySetFromTask(task);
     }
     catch (Exception e)
     {
         tcs.TrySetException(e);
         throw;
     }
 }
Example #43
0
 public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate)
 {
     // return true or false to enable/disable this action
     return(true);
 }
Example #44
0
 protected IWindowViewMediator TryCreateMediatorFromFactory([NotNull] IViewModel viewModel, Type viewType, [NotNull] IDataContext context)
 {
     lock (_mediatorRegistrations)
     {
         for (int i = 0; i < _mediatorRegistrations.Count; i++)
         {
             var mediator = _mediatorRegistrations[i].Invoke(viewModel, viewType, context);
             if (mediator != null)
             {
                 return(mediator);
             }
         }
     }
     return(null);
 }
Example #45
0
 public GetAllDepartmentHandler(IDataContext dataContext,
                                IMapper mapper,
                                ICurrentUserProvider currentUserProvider) : base(dataContext, mapper, currentUserProvider)
 {
 }
Example #46
0
 public NodeRepository(IDataContext context) : base(context)
 {
     _context = context;
 }
Example #47
0
        public override GameDefinition Execute(CreateGameDefinitionRequest createGameDefinitionRequest, ApplicationUser currentUser, IDataContext dataContextWithTransaction)
        {
            ValidateNotNull(createGameDefinitionRequest);

            ValidateGameDefinitionNameIsNotNullOrWhitespace(createGameDefinitionRequest.Name);

            int gamingGroupId = createGameDefinitionRequest.GamingGroupId ?? currentUser.CurrentGamingGroupId;

            BoardGameGeekGameDefinition boardGameGeekGameDefinition = null;

            if (createGameDefinitionRequest.BoardGameGeekGameDefinitionId.HasValue)
            {
                boardGameGeekGameDefinition = _boardGameGeekGameDefinitionCreator.CreateBoardGameGeekGameDefinition(
                    createGameDefinitionRequest.BoardGameGeekGameDefinitionId.Value,
                    currentUser);
            }

            var existingGameDefinition = dataContextWithTransaction.GetQueryable <GameDefinition>()
                                         .FirstOrDefault(game => game.GamingGroupId == gamingGroupId &&
                                                         game.Name == createGameDefinitionRequest.Name);

            if (existingGameDefinition == null)
            {
                var newGameDefinition = new GameDefinition
                {
                    Name = createGameDefinitionRequest.Name,
                    BoardGameGeekGameDefinitionId = boardGameGeekGameDefinition?.Id,
                    Description   = createGameDefinitionRequest.Description,
                    GamingGroupId = gamingGroupId
                };

                new Task(() => _eventTracker.TrackGameDefinitionCreation(currentUser, createGameDefinitionRequest.Name)).Start();

                return(dataContextWithTransaction.Save(newGameDefinition, currentUser));
            }

            ValidateNotADuplicateGameDefinition(existingGameDefinition);

            existingGameDefinition.Active = true;
            existingGameDefinition.BoardGameGeekGameDefinitionId = boardGameGeekGameDefinition?.Id;
            if (!string.IsNullOrWhiteSpace(createGameDefinitionRequest.Description))
            {
                existingGameDefinition.Description = createGameDefinitionRequest.Description;
            }
            return(dataContextWithTransaction.Save(existingGameDefinition, currentUser));
        }
 private static void OnViewCleared(IViewManager viewManager, IViewModel viewModel, object arg3, IDataContext arg4)
 {
     ClearBindingsRecursively(arg3 as DependencyObject);
 }
 public PlayerAchievementRetriever(IDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Example #50
0
 public GetUserRequestHandler(
     IDataContext context)
 {
     _context = context;
 }
Example #51
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="contextBase"></param>
 public Repository(IDataContext contextBase)
 {
     _contextBase = contextBase;
 }
 /// <summary>
 ///     Raised after the view model navigation.
 /// </summary>
 /// <param name="viewModel">The specified view model.</param>
 /// <param name="mode">The specified navigation mode.</param>
 /// <param name="context">The specified <see cref="IDataContext" />.</param>
 public virtual void OnNavigated(IViewModel viewModel, NavigationMode mode, IDataContext context)
 {
     OnNavigated(new NavigationContext(mode, CurrentViewModel, viewModel, this, context));
 }
Example #53
0
 public static int Delete <T>([NotNull] this IDataContext dataContext, T obj)
 {
     return(Query <T> .Delete(DataContextInfo.Create(dataContext), obj));
 }
Example #54
0
 /// <summary>
 /// Set context.
 /// </summary>
 /// <param name="context"></param>
 public override void SetContext(IDataContext context)
 {
     _contextBase = context;
     _context     = (DbContext)_contextBase;
 }
Example #55
0
 public static object InsertWithIdentity <T>(this IDataContext dataContext, T obj)
 {
     return(Query <T> .InsertWithIdentity(DataContextInfo.Create(dataContext), obj));
 }
 public StickyController(IStickyService stickyService, IDataContext context) : base(context)
 {
     this.stickyService = stickyService;
 }
Example #57
0
 public static int InsertOrUpdate <T>(this IDataContext dataContext, T obj)
 {
     return(InsertOrReplace(dataContext, obj));
 }
Example #58
0
 public static int Update <T>(this IDataContext dataContext, T obj)
 {
     return(Query <T> .Update(DataContextInfo.Create(dataContext), obj));
 }
Example #59
0
 static public Table <T> GetTable <T>(this IDataContext dataContext)
     where T : class
 {
     return(new Table <T>(dataContext));
 }
Example #60
0
 public static int InsertOrReplace <T>(this IDataContext dataContext, T obj)
 {
     return(Query <T> .InsertOrReplace(DataContextInfo.Create(dataContext), obj));
 }