public async virtual Task <TeacherXTeacherSkill> Create(TeacherXTeacherSkill item)
        {
            this.Context.Set <TeacherXTeacherSkill>().Add(item);
            await this.Context.SaveChangesAsync();

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

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

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

            record.Should().NotBeNull();
        }
        public async virtual Task Delete(
            int id)
        {
            TeacherXTeacherSkill record = await this.GetById(id);

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

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

            await this.Context.SaveChangesAsync();
        }
        public async void Get()
        {
            Mock <ILogger <TeacherXTeacherSkillRepository> > loggerMoc = TeacherXTeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherXTeacherSkillRepositoryMoc.GetContext();
            var repository = new TeacherXTeacherSkillRepository(loggerMoc.Object, context);

            TeacherXTeacherSkill entity = new TeacherXTeacherSkill();

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

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

            record.Should().NotBeNull();
        }
        public async void Delete()
        {
            Mock <ILogger <TeacherXTeacherSkillRepository> > loggerMoc = TeacherXTeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherXTeacherSkillRepositoryMoc.GetContext();
            var repository = new TeacherXTeacherSkillRepository(loggerMoc.Object, context);
            TeacherXTeacherSkill entity = new TeacherXTeacherSkill();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TeacherXTeacherSkillRepository> > loggerMoc = TeacherXTeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherXTeacherSkillRepositoryMoc.GetContext();
            var repository = new TeacherXTeacherSkillRepository(loggerMoc.Object, context);
            TeacherXTeacherSkill entity = new TeacherXTeacherSkill();

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

            await repository.Update(new TeacherXTeacherSkill());

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

            modifiedRecord.Should().NotBeNull();
        }
Ejemplo n.º 8
0
        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();
        }