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

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
        public async virtual Task Delete(
            int id)
        {
            TeacherTeacherSkill record = await this.GetById(id);

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

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

            await this.Context.SaveChangesAsync();
        }
Exemple #4
0
        public async void Create()
        {
            Mock <ILogger <TeacherTeacherSkillRepository> > loggerMoc = TeacherTeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherTeacherSkillRepositoryMoc.GetContext();
            var repository = new TeacherTeacherSkillRepository(loggerMoc.Object, context);

            var entity = new TeacherTeacherSkill();

            entity.SetProperties(default(int), 1, 1);
            await repository.Create(entity);

            var records = await context.Set <TeacherTeacherSkill>().ToListAsync();

            records.Count.Should().Be(2);
        }
Exemple #5
0
        public async void Get()
        {
            Mock <ILogger <TeacherTeacherSkillRepository> > loggerMoc = TeacherTeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherTeacherSkillRepositoryMoc.GetContext();
            var repository = new TeacherTeacherSkillRepository(loggerMoc.Object, context);

            TeacherTeacherSkill entity = new TeacherTeacherSkill();

            entity.SetProperties(default(int), 1, 1);
            context.Set <TeacherTeacherSkill>().Add(entity);
            await context.SaveChangesAsync();

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

            record.Should().NotBeNull();
        }
Exemple #6
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TeacherTeacherSkillRepository> > loggerMoc = TeacherTeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherTeacherSkillRepositoryMoc.GetContext();
            var repository             = new TeacherTeacherSkillRepository(loggerMoc.Object, context);
            TeacherTeacherSkill entity = new TeacherTeacherSkill();

            entity.SetProperties(default(int), 1, 1);
            context.Set <TeacherTeacherSkill>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <TeacherTeacherSkill>().ToListAsync();

            records.Count.Should().Be(2);
        }
Exemple #7
0
        public virtual async Task Migrate()
        {
            var adminItem1 = new Admin();

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

            var eventItem1 = new Event();

            eventItem1.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1m, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A");
            this.Context.Events.Add(eventItem1);

            var eventStatusItem1 = new EventStatus();

            eventStatusItem1.SetProperties(1, "A");
            this.Context.EventStatus.Add(eventStatusItem1);

            var eventStudentItem1 = new EventStudent();

            eventStudentItem1.SetProperties(1, 1, 1);
            this.Context.EventStudents.Add(eventStudentItem1);

            var eventTeacherItem1 = new EventTeacher();

            eventTeacherItem1.SetProperties(1, 1, 1);
            this.Context.EventTeachers.Add(eventTeacherItem1);

            var familyItem1 = new Family();

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

            var rateItem1 = new Rate();

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

            var spaceItem1 = new Space();

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

            var spaceFeatureItem1 = new SpaceFeature();

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

            var spaceSpaceFeatureItem1 = new SpaceSpaceFeature();

            spaceSpaceFeatureItem1.SetProperties(1, 1, 1);
            this.Context.SpaceSpaceFeatures.Add(spaceSpaceFeatureItem1);

            var studentItem1 = new Student();

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

            var studioItem1 = new Studio();

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

            var teacherItem1 = new Teacher();

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

            var teacherSkillItem1 = new TeacherSkill();

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

            var teacherTeacherSkillItem1 = new TeacherTeacherSkill();

            teacherTeacherSkillItem1.SetProperties(1, 1, 1);
            this.Context.TeacherTeacherSkills.Add(teacherTeacherSkillItem1);

            var userItem1 = new User();

            userItem1.SetProperties(1, "A", "A");
            this.Context.Users.Add(userItem1);

            await this.Context.SaveChangesAsync();
        }