Esempio n. 1
0
 public void StartBout(BoutData boutData)
 {
     if (_bouts.ContainsKey(boutData.BoutId))
     {
         throw new BoutAlreadyRunningException(boutData.BoutId);
     }
     _bouts[boutData.BoutId]      = boutData;
     _boutStates[boutData.BoutId] = new BoutState(boutData);
 }
        public void Save(BoutData boutData)
        {
            _bouts[boutData.BoutId] = boutData;
            var entry = _boutList.FirstOrDefault(x => x.Id == boutData.BoutId);

            if (entry == null)
            {
                _boutList.Add(new BoutListItem
                {
                    Id        = boutData.BoutId,
                    Name      = $"New Bout {DateTime.Now}",
                    TimeStamp = DateTime.Now
                });
            }
            else
            {
                entry.TimeStamp = DateTime.Now;
            }
        }
Esempio n. 3
0
        public void Save(BoutData boutData)
        {
            if (boutData.BoutId == Guid.Empty)
            {
                boutData.BoutId = Guid.NewGuid();
            }
            //TODO: For testing purposes, all bouts are set to the current WFTDA rules on save
            //if (bout.RuleSet == null)
            { boutData.RuleSet = RuleSet.WFTDA; }

            var filePath = $"{_boutDataPath}/{boutData.BoutId}.json";
            var boutJson = JsonConvert.SerializeObject(boutData);

            File.WriteAllText(filePath, boutJson);

            var list  = List();
            var entry = list.FirstOrDefault(x => x.Id == boutData.BoutId);

            if (entry == null)
            {
                list.Add(new BoutListItem
                {
                    Id        = boutData.BoutId,
                    Name      = boutData.Name,
                    TimeStamp = DateTime.Now
                });
            }
            else
            {
                entry.TimeStamp = DateTime.Now;
                entry.Name      = boutData.Name;
            }

            var path     = $"{_boutDataPath}/boutdata.json";
            var listJson = JsonConvert.SerializeObject(list);

            File.WriteAllText(path, listJson);
        }
 public InitializeBoutEvent(BoutData boutData, BoutState boutState) : base(boutState.BoutId)
 {
     BoutData = boutData;
     BoutState = boutState;
 }
Esempio n. 5
0
 public Guid Save(BoutData boutData)
 {
     _boutDataService.Save(boutData);
     return(boutData.BoutId);
 }