Esempio n. 1
0
        public void Delete(Guid presetId, Guid regionId)
        {
            var regions = GetAllRegions(presetId).ToList();
            var region  = regions.RemoveAll(x => x.Id == regionId);

            File.WriteAllText(PresetFile.ResolvePresetFilePath(presetId), JsonConvert.SerializeObject(regions));
        }
Esempio n. 2
0
        public async Task UpdateAsync(Guid presetId, RegionViewModel regionViewModel)
        {
            var regions = (await GetAllRegionsAsync(presetId)).ToList();
            var index   = regions.IndexOf(regions.First(x => x.Id == regionViewModel.Id));

            regions[index] = _mapper.Map <RegionConfig>(regionViewModel);

            await File.WriteAllTextAsync(PresetFile.ResolvePresetFilePath(presetId), JsonConvert.SerializeObject(regions));
        }
Esempio n. 3
0
        public void Update(Guid presetId, RegionViewModel regionViewModel)
        {
            var regions = GetAllRegions(presetId).ToList();
            var region  = regions.FirstOrDefault(x => x.Id == regionViewModel.Id);

            region = _mapper.Map <RegionConfig>(regionViewModel);

            File.WriteAllText(PresetFile.ResolvePresetFilePath(presetId), JsonConvert.SerializeObject(regions));
        }
Esempio n. 4
0
        public RegionViewModel Create(Guid presetId, string regionName)
        {
            var newRegion = new RegionConfig
            {
                Id   = Guid.NewGuid(),
                Name = regionName
            };

            var regions = GetAllRegions(presetId).ToList();

            regions.Add(newRegion);
            File.WriteAllText(PresetFile.ResolvePresetFilePath(presetId), JsonConvert.SerializeObject(regions));

            return(_mapper.Map <RegionViewModel>(newRegion));
        }
Esempio n. 5
0
        public async Task <IEnumerable <RegionConfig> > GetAllRegionsAsync(Guid presetId)
        {
            var contents = await File.ReadAllTextAsync(PresetFile.ResolvePresetFilePath(presetId));

            return(JsonConvert.DeserializeObject <IEnumerable <RegionConfig> >(contents));
        }
Esempio n. 6
0
 public IEnumerable <RegionConfig> GetAllRegions(Guid presetId)
 {
     return(JsonConvert.DeserializeObject <IEnumerable <RegionConfig> >(File.ReadAllText(PresetFile.ResolvePresetFilePath(presetId))));
 }