示例#1
0
        public async Task DeleteControllerProfileAsync(ControllerProfile controllerProfile)
        {
            using (await _asyncLock.LockAsync())
            {
                var parent = controllerProfile.Creation;
                await _creationRepository.DeleteControllerProfileAsync(controllerProfile);

                parent.ControllerProfiles.Remove(controllerProfile);
            }
        }
        public async Task <ControllerProfile> AddControllerProfileAsync(Creation creation, string controllerProfileName)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerProfile = new ControllerProfile {
                    Name = controllerProfileName
                };
                await _creationRepository.InsertControllerProfileAsync(creation, controllerProfile);

                return(controllerProfile);
            }
        }
示例#3
0
        public async Task<ControllerEvent> AddOrGetControllerEventAsync(ControllerProfile controllerProfile, GameControllerEventType eventType, string eventCode)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerEvent = controllerProfile.ControllerEvents.FirstOrDefault(ce => ce.EventType == eventType && ce.EventCode == eventCode);
                if (controllerEvent == null)
                {
                    controllerEvent = new ControllerEvent { EventType = eventType, EventCode = eventCode };
                    await _creationRepository.InsertControllerEventAsync(controllerProfile, controllerEvent);
                }

                return controllerEvent;
            }
        }
示例#4
0
        private async Task InsertControllerProfileAsync(ControllerProfile controllerProfile)
        {
            await _databaseConnection.InsertAsync(controllerProfile);

            // insert all available events as well as it's present for a profile when it's imported only
            if (controllerProfile.ControllerEvents.Any())
            {
                foreach (var controllerEvent in controllerProfile.ControllerEvents)
                {
                    await InsertControllerEventAsync(controllerEvent);
                }
                await _databaseConnection.UpdateWithChildrenAsync(controllerProfile);
            }
        }
        public async Task InsertControllerProfileAsync(Creation creation, ControllerProfile controllerProfile)
        {
            using (await _lock.LockAsync())
            {
                await _databaseConnection.InsertAsync(controllerProfile);

                if (creation.ControllerProfiles == null)
                {
                    creation.ControllerProfiles = new ObservableCollection <ControllerProfile>();
                }

                creation.ControllerProfiles.Add(controllerProfile);
                await _databaseConnection.UpdateWithChildrenAsync(creation);
            }
        }
        public async Task InsertControllerEventAsync(ControllerProfile controllerProfile, ControllerEvent controllerEvent)
        {
            using (await _lock.LockAsync())
            {
                await _databaseConnection.InsertAsync(controllerEvent);

                if (controllerProfile.ControllerEvents == null)
                {
                    controllerProfile.ControllerEvents = new ObservableCollection <ControllerEvent>();
                }

                controllerProfile.ControllerEvents.Add(controllerEvent);
                await _databaseConnection.UpdateWithChildrenAsync(controllerProfile);
            }
        }