Ejemplo n.º 1
0
        private void DeleteDiscipline()
        {
            if (this.SelectedDiscipline == null)
            {
                return;
            }
            var messageBoxResult = MessageBox.Show(Localization["Вы уверены, что хотите удалить дисциплину?"],
                                                   Localization["Подтверждение удаления"], MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (messageBoxResult != MessageBoxResult.Yes)
            {
                return;
            }
            _db.Disciplines.Remove(this.SelectedDiscipline);
            _db.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task <Guid> CreateRunAsync(Guid experimentId, string gitCommitHash = "")
        {
            using (var db = new LocalDbContext())
            {
                var run = new Run(experimentId)
                {
                    GitCommitHash = gitCommitHash
                };

                await db.Runs.AddAsync(run);

                await db.SaveChangesAsync();

                return(run.Id);
            }
        }
Ejemplo n.º 3
0
        private void DeleteGroup()
        {
            if (this.SelectedGroupEntity == null)
            {
                return;
            }
            var messageBoxResult = MessageBox.Show(Localization["Вы уверены, что хотите удалить группу?"],
                                                   Localization["Подтверждение удаления"], MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (messageBoxResult != MessageBoxResult.Yes)
            {
                return;
            }
            _db.Groups.Remove(this.SelectedGroupEntity);
            _db.SaveChangesAsync();
        }
Ejemplo n.º 4
0
        private async Task DeleteStream()
        {
            if (this.SelectedStream == null)
            {
                return;
            }
            var messageBoxResult = MessageBox.Show(Localization["Вы уверены, что хотите удалить поток?"],
                                                   Localization["Подтверждение удаления"], MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (messageBoxResult != MessageBoxResult.Yes)
            {
                return;
            }
            _db.Streams.Remove(this.SelectedStream);
            await _db.SaveChangesAsync();
        }
Ejemplo n.º 5
0
        private void DeleteDepartment()
        {
            if (this.SelectedDepartment == null)
            {
                return;
            }
            var messageBoxResult = MessageBox.Show(Localization["Вы уверены, что хотите удалить факультет?"],
                                                   Localization["Подтверждение удаления"], MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (messageBoxResult != MessageBoxResult.Yes)
            {
                return;
            }
            _db.Departments.Remove(this.SelectedDepartment);
            _db.SaveChangesAsync();
        }
Ejemplo n.º 6
0
        public async Task Save(Settings settings)
        {
            using (var db = new LocalDbContext())
            {
                if (settings.Id > 0)
                {
                    db.Settings.Update(settings);
                }
                else
                {
                    await db.Settings.AddAsync(settings);
                }

                Settings.SetCurrent(settings);

                await db.SaveChangesAsync();
            }
        }
        private async Task Save()
        {
            this.Group.Students = this.GroupStudents
                                  .Cast <StudentViewModel>()
                                  .Select(item => item.Student)
                                  .ToList();
            if (this.Group.Id == 0)
            {
                _db.Groups.Add(this.Group);
            }
            else
            {
                var group = _db.Groups.Find(this.Group.Id);
                group?.Apply(this.Group);
            }

            await _db.SaveChangesAsync();

            _token.Deactivate();
        }
        private async Task Save()
        {
            _entity.Name           = this.StreamName;
            _entity.Groups         = this.ChosenGroups.Cast <GroupEntity>().ToList();
            _entity.Discipline     = this.SelectedDiscipline;
            _entity.Department     = this.SelectedDepartment.Id == DefaultDepartment.Id ? null : this.SelectedDepartment;
            _entity.ExpirationDate = this.ExpirationDate;
            _entity.IsActive       = this.IsActive;
            _entity.LectureCount   = this.LectureCount;
            _entity.LabCount       = this.LaboratoryCount;
            _entity.PracticalCount = this.PracticeCount;
            _entity.Description    = this.Description;
            _entity.Course         = this.SelectedCourse.Value == DefaultCourse.Value ? (int?)null : this.SelectedCourse.Value;
            if (_entity.Id == default)
            {
                _context.Streams.Add(_entity);
            }

            await _context.SaveChangesAsync();

            _token.Deactivate();
        }
Ejemplo n.º 9
0
        private async Task SaveAsync()
        {
            var persistentEntity = _isCreationMode
                ? _detachedEntity
                : await _context.Disciplines.FindAsync(_detachedEntity.Id);

            if (persistentEntity == null)
            {
                var exception = new Exception("Cannot save discipline: item not found");
                Logger.Log(LogLevel.Error, exception);
                throw exception;
            }

            persistentEntity.Name        = this.DisciplineName;
            persistentEntity.Description = this.DisciplineDescription;
            if (_isCreationMode)
            {
                _context.Disciplines.Add(persistentEntity);
            }
            await _context.SaveChangesAsync();

            _token.Deactivate();
        }
 public void Add(Phrase phrase)
 {
     context.Add(phrase);
     context.SaveChangesAsync();
 }
Ejemplo n.º 11
0
        private const string WavStartMetadata  = "RIFF"; // wav start metadata
        public async Task Migrate(LocalDbContext context)
        {
            var count = await context.LessonTypes.CountAsync();

            var isLessonTypesMissed = count < 5 && count >= 3;

            if (isLessonTypesMissed)
            {
                context.LessonTypes.Add(new LessonTypeEntity {
                    Name = "Аттестация"
                });
                context.LessonTypes.Add(new LessonTypeEntity {
                    Name = "Экзамен"
                });
                await context.SaveChangesAsync();
            }

            await context.Database.ExecuteSqlCommandAsync(RemoveUncascadedStudentLessons);

            await context.Database.ExecuteSqlCommandAsync("PRAGMA foreign_keys=off;");

            await context.Database.ExecuteSqlCommandAsync
            (
                @"
                CREATE TABLE GROUP_TYPE2 (
                     id INTEGER PRIMARY KEY AUTOINCREMENT,
                     name TEXT
                );
                INSERT INTO GROUP_TYPE2 (id, name)
                    SELECT id, name FROM GROUP_TYPE;
                DROP TABLE GROUP_TYPE;
                ALTER TABLE GROUP_TYPE2 RENAME TO GROUP_TYPE;
                PRAGMA foreign_keys=off;
                CREATE TABLE STUDENT_LESSON2 (
	                id	INTEGER PRIMARY KEY AUTOINCREMENT,
	                student_id	INTEGER,
	                lesson_id	INTEGER,
	                registered	INTEGER DEFAULT 0,
	                registration_time	TEXT,
	                registration_type	TEXT,
	                mark	TEXT,
	                mark_time	TEXT,
	                FOREIGN KEY(lesson_id) REFERENCES LESSON(id) ON DELETE CASCADE,
	                FOREIGN KEY(student_id) REFERENCES STUDENT(id) ON DELETE CASCADE
                );
                INSERT INTO STUDENT_LESSON2
                    SELECT * FROM STUDENT_LESSON;
                DROP TABLE STUDENT_LESSON;
                ALTER TABLE STUDENT_LESSON2 RENAME TO STUDENT_LESSON;
            ");

            await context.Database.ExecuteSqlCommandAsync(@"
                CREATE TABLE `ALARM2` (
	                `id`	INTEGER PRIMARY KEY AUTOINCREMENT,
	                `active`	INTEGER DEFAULT 0,
	                `time`	INTEGER,
	                `volume`	DECIMAL ( 1 , 1 ),
	                `sound`	BLOB,
	                `discriminator` TEXT,
	                `resource_name` TEXT
                );
                
                INSERT INTO ALARM2 (id, active, time, volume, sound)
                    SELECT id, active, time, volume, sound FROM ALARM;
                
                DROP TABLE ALARM;
                ALTER TABLE ALARM2 RENAME TO ALARM;
            ");

            await context.Database.ExecuteSqlCommandAsync("PRAGMA foreign_keys=on;");

            await TrySetAudioDiscriminator(context);

            await context.Database.ExecuteSqlCommandAsync($"PRAGMA user_version={this.To};");
        }