Beispiel #1
0
        public async virtual Task <LessonXStudent> Create(LessonXStudent item)
        {
            this.Context.Set <LessonXStudent>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
Beispiel #2
0
        public async void Create()
        {
            Mock <ILogger <LessonXStudentRepository> > loggerMoc = LessonXStudentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonXStudentRepositoryMoc.GetContext();
            var repository = new LessonXStudentRepository(loggerMoc.Object, context);

            var entity = new LessonXStudent();
            await repository.Create(entity);

            var record = await context.Set <LessonXStudent>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Beispiel #3
0
        public async virtual Task Delete(
            int id)
        {
            LessonXStudent record = await this.GetById(id);

            if (record == null)
            {
                return;
            }
            else
            {
                this.Context.Set <LessonXStudent>().Remove(record);
                await this.Context.SaveChangesAsync();
            }
        }
Beispiel #4
0
        public async virtual Task Update(LessonXStudent item)
        {
            var entity = this.Context.Set <LessonXStudent>().Local.FirstOrDefault(x => x.Id == item.Id);

            if (entity == null)
            {
                this.Context.Set <LessonXStudent>().Attach(item);
            }
            else
            {
                this.Context.Entry(entity).CurrentValues.SetValues(item);
            }

            await this.Context.SaveChangesAsync();
        }
Beispiel #5
0
        public async void Get()
        {
            Mock <ILogger <LessonXStudentRepository> > loggerMoc = LessonXStudentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonXStudentRepositoryMoc.GetContext();
            var repository = new LessonXStudentRepository(loggerMoc.Object, context);

            LessonXStudent entity = new LessonXStudent();

            context.Set <LessonXStudent>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
Beispiel #6
0
        public async void Delete()
        {
            Mock <ILogger <LessonXStudentRepository> > loggerMoc = LessonXStudentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonXStudentRepositoryMoc.GetContext();
            var            repository    = new LessonXStudentRepository(loggerMoc.Object, context);
            LessonXStudent entity        = new LessonXStudent();

            context.Set <LessonXStudent>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            LessonXStudent modifiedRecord = await context.Set <LessonXStudent>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
Beispiel #7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <LessonXStudentRepository> > loggerMoc = LessonXStudentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonXStudentRepositoryMoc.GetContext();
            var            repository    = new LessonXStudentRepository(loggerMoc.Object, context);
            LessonXStudent entity        = new LessonXStudent();

            context.Set <LessonXStudent>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new LessonXStudent());

            var modifiedRecord = context.Set <LessonXStudent>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }
        public void Migrate()
        {
            var adminItem1 = new Admin();

            adminItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", 1, "A", "A", 1);
            this.context.Admins.Add(adminItem1);

            var familyItem1 = new Family();

            familyItem1.SetProperties(1, "A", "A", "A", "A", "A", 1);
            this.context.Families.Add(familyItem1);

            var lessonItem1 = new Lesson();

            lessonItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1m, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, "A");
            this.context.Lessons.Add(lessonItem1);

            var lessonStatusItem1 = new LessonStatus();

            lessonStatusItem1.SetProperties(1, "A", 1);
            this.context.LessonStatus.Add(lessonStatusItem1);

            var lessonXStudentItem1 = new LessonXStudent();

            lessonXStudentItem1.SetProperties(1, 1, 1);
            this.context.LessonXStudents.Add(lessonXStudentItem1);

            var lessonXTeacherItem1 = new LessonXTeacher();

            lessonXTeacherItem1.SetProperties(1, 1, 1);
            this.context.LessonXTeachers.Add(lessonXTeacherItem1);

            var rateItem1 = new Rate();

            rateItem1.SetProperties(1m, 1, 1, 1);
            this.context.Rates.Add(rateItem1);

            var spaceItem1 = new Space();

            spaceItem1.SetProperties("A", 1, "A", 1);
            this.context.Spaces.Add(spaceItem1);

            var spaceFeatureItem1 = new SpaceFeature();

            spaceFeatureItem1.SetProperties(1, "A", 1);
            this.context.SpaceFeatures.Add(spaceFeatureItem1);

            var spaceXSpaceFeatureItem1 = new SpaceXSpaceFeature();

            spaceXSpaceFeatureItem1.SetProperties(1, 1, 1);
            this.context.SpaceXSpaceFeatures.Add(spaceXSpaceFeatureItem1);

            var stateItem1 = new State();

            stateItem1.SetProperties(1, "A");
            this.context.States.Add(stateItem1);

            var studentItem1 = new Student();

            studentItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", true, 1, "A", 1, true, "A", "A", true, 1);
            this.context.Students.Add(studentItem1);

            var studentXFamilyItem1 = new StudentXFamily();

            studentXFamilyItem1.SetProperties(1, 1, 1);
            this.context.StudentXFamilies.Add(studentXFamilyItem1);

            var studioItem1 = new Studio();

            studioItem1.SetProperties("A", "A", "A", 1, "A", 1, "A", "A");
            this.context.Studios.Add(studioItem1);

            var teacherItem1 = new Teacher();

            teacherItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", 1, "A", "A", 1);
            this.context.Teachers.Add(teacherItem1);

            var teacherSkillItem1 = new TeacherSkill();

            teacherSkillItem1.SetProperties(1, "A", 1);
            this.context.TeacherSkills.Add(teacherSkillItem1);

            var teacherXTeacherSkillItem1 = new TeacherXTeacherSkill();

            teacherXTeacherSkillItem1.SetProperties(1, 1, 1);
            this.context.TeacherXTeacherSkills.Add(teacherXTeacherSkillItem1);

            this.context.SaveChanges();
        }