コード例 #1
0
        public async virtual Task <SpaceFeature> Create(SpaceFeature item)
        {
            this.Context.Set <SpaceFeature>().Add(item);
            await this.Context.SaveChangesAsync();

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

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

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

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async virtual Task Delete(
            int id)
        {
            SpaceFeature record = await this.GetById(id);

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

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

            await this.Context.SaveChangesAsync();
        }
コード例 #5
0
        public async void Get()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var repository = new SpaceFeatureRepository(loggerMoc.Object, context);

            SpaceFeature entity = new SpaceFeature();

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

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

            record.Should().NotBeNull();
        }
コード例 #6
0
        public async void Delete()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var          repository      = new SpaceFeatureRepository(loggerMoc.Object, context);
            SpaceFeature entity          = new SpaceFeature();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
コード例 #7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var          repository      = new SpaceFeatureRepository(loggerMoc.Object, context);
            SpaceFeature entity          = new SpaceFeature();

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

            await repository.Update(new SpaceFeature());

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

            modifiedRecord.Should().NotBeNull();
        }
コード例 #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();
        }