Ejemplo n.º 1
0
        private void SyncSections()
        {
            var data = _database.GetSections(_enviroment.CurrentUser.ID);

            //Если у нас ничего нет то нам нужно доставть все книги
            if (data.Count() == 0)
            {
                var element = _communication.GetSections(_enviroment.UserToken, source.Token);

                foreach (var section in element.Sections)
                {
                    _database.AddSection(section);
                }

                _enviroment.RemoteSectionCursor = element.LastHistory;
            }
            else
            {
                //Отправить
                var toSend = _database.GetSectionHistory(_enviroment.LocalSectionCursor);
                _communication.SetSectionHistory(_enviroment.UserToken, toSend, source.Token);

                //Получаем
                var element = _communication.GetHistory(_enviroment.UserToken, "Section", _enviroment.RemoteSectionCursor, source.Token);

                if (element.Records.Count() > 0)
                {
                    _database.UpdateSectionByHistory(element.Records, element.Details);
                    _enviroment.RemoteSectionCursor = element.Records.Last().ID;
                }
            }
        }
Ejemplo n.º 2
0
        private void OnAddCommand(object param)
        {
            AddBox box = new AddBox();

            box.ShowDialog();

            string result = box.GetResult;

            if (!string.IsNullOrWhiteSpace(result))
            {
                Section section = _database.GetSections(_currentBookId).Where(f => f.Name == result).FirstOrDefault();
                if (section == null)
                {
                    section = new Section()
                    {
                        Name        = result,
                        Description = "",
                        Book        = _currentBookId
                    };
                    _database.AddSection(section);
                    Sections.Add(section);
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Sections)));
                }
            }
        }
Ejemplo n.º 3
0
 public void AddLocalSection(Section value)
 {
     _db.AddSection(value);
 }