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

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

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

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

            record.Should().NotBeNull();
        }
        public async void Get()
        {
            Mock <ILogger <VEventRepository> > loggerMoc = VEventRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VEventRepositoryMoc.GetContext();
            var repository = new VEventRepository(loggerMoc.Object, context);

            VEvent entity = new VEvent();

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

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

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

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

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

            await this.Context.SaveChangesAsync();
        }
        public async void Delete()
        {
            Mock <ILogger <VEventRepository> > loggerMoc = VEventRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VEventRepositoryMoc.GetContext();
            var    repository            = new VEventRepository(loggerMoc.Object, context);
            VEvent entity = new VEvent();

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new VEvent());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async 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 eventItem1 = new Event();

            eventItem1.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", "A");
            this.context.Events.Add(eventItem1);

            var eventStatusItem1 = new EventStatus();

            eventStatusItem1.SetProperties(1, "A");
            this.context.EventStatuses.Add(eventStatusItem1);

            var familyItem1 = new Family();

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

            var rateItem1 = new Rate();

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

            var spaceItem1 = new Space();

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

            var spaceFeatureItem1 = new SpaceFeature();

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

            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 studioItem1 = new Studio();

            studioItem1.SetProperties("A", "A", "A", 1, "A", "A", "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");
            this.context.TeacherSkills.Add(teacherSkillItem1);

            var tenantItem1 = new Tenant();

            tenantItem1.SetProperties(1, "A");
            this.context.Tenants.Add(tenantItem1);

            var userItem1 = new User();

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

            var vEventItem1 = new VEvent();

            vEventItem1.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"));
            this.context.VEvents.Add(vEventItem1);

            await this.context.SaveChangesAsync();
        }